This content has been marked as final.
Show 1 reply
-
1. Re: How to have pop-up populate other field
rlinsurf1 May 1, 2009 3:00 PM (in response to rlinsurf1)Ok. I've added some javascript I found by googling the problem and made a new page which has the following code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Untitled Document</title><script type="text/javascript"> var colors = new Array(); colors["apple"] = "red"; colors["grape"] = "purple"; colors["milk"] = "white"; colors["cheese"] = "yellow"; colors["chicken"] = "white"; colors["beef"] = "red"; var groups = new Array(); groups["apple"] = "fruit"; groups["grape"] = "fruit"; groups["milk"] = "diary"; groups["cheese"] = "diary"; groups["chicken"] = "meat"; groups["beef"] = "meat"; function printColorAndGroup(){ var value = document.getElementByName('food').options[document.getElementByName('food').selectedIndex].value; document.getElementByName('food_group').value = groups[text]; document.getElementByName('food_color').value = colors[text]; } </script> </head> <body> Food: <select name="food" onchange="printColorAndGroup()"> <option>apple</option> <option>grape</option> <option>milk</option> <option>cheese</option> <option>chicken</option> <option>beef</option> </select> Group: <input type="text" name="food_group"> Color: <input type="text" name="food_color"> </body> </html>But when I run this, nothing happens. I've also, btw, tried this with the script in the body.
What am I doing wrong?
Thanks.

