Re: select data from a drop down box in a form
| From: | Gary Huntress | Date: | Mon, 02 Apr 2001 03:42:54 +0000 |
| Subject: | Re: select data from a drop down box in a form | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-8108@lists.php.net to get a copy of this message | ||
There are probably a million ways to do this... here is one :)
(note that the file should be named "fieldtest.php"
--
Regards,
Gary "SuperID" Huntress
=======================================================
FreeSQL.org offering free database hosting to developers
Visit http://superid.dyndns.org:8080/freesql/index.php
<html>
<body>
<script language=javascript>
function copyfield()
{ var ind;
ind=document.myform.myfield.selectedIndex;
window.navigate("formtest.php?otherfield="
+document.myform.myfield[ind].text);
}
</script>
<form name=myform>
<select name=myfield onchange=copyfield();>
<?
$db = mysql_connect("localhost",$username,$password);
$rs=mysql_db_query( $databasename, "select myfield from mytable");
while($row=mysql_fetch_array($rs))
{
echo "<option>$row[0]</option>";
}
?>
<p>
<input type=text name=otherfield value="<? echo "$otherfield";?>">
</form>
</body>
</html>
""Petra"" <petra@kewl.com.au> wrote in message
news:9a8qou$bp3$1@toye.p.sourceforge.net...
> I like to select data out of a drop down box in my form field from a mysql
> database. While I do that I also like that it reloads the page and put the
> relevant products of that drop down box in another field.
> Ex:
> Category 1
> Category 2
> Category 3
> are in the drop down box
> and when I choose
> Category 1
> I like to display another field which displays me all the products which
are
> in that categorie. I know it can be down just not to sure how?
>
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net
> For additional commands, e-mail: php-db-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>