|
Posted by Jerry Stuckle on 03/08/07 04:35
KDawg44 wrote:
> 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.
>
Yep, you'll need to use javascript for anything happening client-side.
And sure - it doesn't matter how the JS is generated - from a page or
echoed from PHP, for instance. The browser has no idea.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
[Back to original message]
|