|
Posted by KDawg44 on 03/07/07 20:43
On Mar 7, 3:16 pm, "KDawg44" <KDaw...@gmail.com> wrote:
> Hi,
>
> I am writing a PHP website. When I am taking some input from a user,
> I write some static radio buttons for a category, and then also write
> some more that are generated based on a query to a database. I would
> like to have a text box for a description of the category. I would
> like that to be able to be typed in if the user selects on of the
> static options but automatically filled in by data from the database
> if they select one of the radio buttons that are DB generated. I
> would also like to be able to prevent the user from changing the text
> box if it is filled in with DB data (if possible, not that big of a
> deal if too difficult).
>
> Thanks.
I see how to set this with JavaScript. Can I pass the results of a
PHP query into a javascript? Something like this?
while ($row = mysql_fetch_row($rs) {
echo "<input type = radio name = radio1 value = '" . $row[0] . "'
onclick = 'fillTextBox(" . $row[0] . "," . $row[1] . ")'>";
}
and then have a JavaScript function something like:
function fillTextBox(var cat, var dbData) {
document.getElementById(cat).value = dbData;
}
THanks.
[Back to original message]
|