Reply to Re: Filling a text box when radio button is clicked

Your name:

Reply:


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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация