PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
hello all, been racking my brains on this one decided to finally chuck it up to the higher powers...
I have a SELECT form object that is filled by the name and address of elements in a database table.
When I SELECT one of these names & addresses, I want 3 corresponding textfields to be filled with more detailed information than just the name and address. The other information is vendor_number, sc_number, and brc_number.
Heres my snippet:
Thanks, help would be wonderful. I've tried putting the values into an array in the loop then putting them up in onChange, that doesnt work, I tried doing mysql queries in the onChange part, that didnt work. Totally clueless.
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
You could store the extra data in the value attribute of the option. This can be accomplished by using the Javascript string method called split, that functions much like explode()
once i concatenate the items,
they have a period "." between them.
i still cannot figure out how to split them and send the appropriate part to the appropriate text field in the on Change section.
by the way thanks for the formatting help.
cheers,
tony
<?php
print(" <OPTION SELECTED VALUE=\"00\">— Select a Vendor —\n");
while($row = mysql_fetch_array($result))
{
// Concatenates all of my required info into VALUE field.
print(" <OPTION VALUE=$row[vnumber].$row[vid].$row[sc_number].$row[brc_number]>$row[name]\n,$row[address]\n");
}
print(" </SELECT>\n");
?>
function split_and_display(this)
{
var mytool_array=this.split("."); //splits this.value at periods
this.form.vendor_number.value = mytool_array[0];
this.form.sc_number.value = mytool_array[1];
this.form.brc_number.value = mytool_array[2];
}
<?php
print(" <OPTION SELECTED VALUE=\"00\">— Select a Vendor —\n");
while($row = mysql_fetch_array($result))
{
// Concatenates all of my required info into VALUE field.
print(" <OPTION VALUE=\"$row[vnumber].$row[vid].$row[sc_number].$row[brc_number]\">$row[name]\n,$row[address]\n</OPTION>");
}
print(" </SELECT>\n");
?>