damindor Posted February 24, 2014 Share Posted February 24, 2014 Hello why have I never head of option list?Is it deprecated? Also this dont work I copied it directly from the book <!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> <title>Dynamically Change Option List</title> <script language="Javascript" type="text/javascript"> <!-- function ResetOptionList(ElementValue) { with (document.forms.Contact) if (ElementValue == 1) { OptionList [0].text = "Classic" OptionList [0].value = 1 OptionList [1].text = "Police Cruiser" OptionList [1].value = 2 } if (ElementValue == 2) { OptionList [0].text = "Ford" OptionList [0].value = 1 OptionList [1].text = "Chevy" OptionList [1].value = 2 } } } --> </script> </head> <body> <FORM name="Contact" action="http://www.jimkeogh.com" method="post"> <P> <select name="OptionList" size="2"> <option Value=1>Classic <option Value=2>Police Cruiser </select> <BR> <INPUT TYPE="radio" name="vehicles" checked="true" value=1 onclick =" ResetOptionList(this.value)">Motorcycles <INPUT TYPE="radio" name="vehicles" Value=2 onclick=" ResetOptionList(this.value)">Cars <BR> <INPUT name="Submit" value="Submit" type="submit"/> <INPUT name="Reset" value="Reset" type="reset"> </P> </FORM> </body> </html> Link to comment Share on other sites More sharing options...
0 jamieakers Posted February 24, 2014 Share Posted February 24, 2014 Got some mismatched brackets in there specifically no opening "{" after the "with" statement... fixed up and works fine. Tabbing the code and using the JavaScript console (F12 for developer tools) shows the error. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR...nsitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Dynamically Change Option List</title> <script language="Javascript" type="text/javascript"> <!-- function ResetOptionList(ElementValue) { with (document.forms.Contact) { if (ElementValue == 1) { OptionList[0].text = "Classic" OptionList[0].value = 1 OptionList[1].text = "Police Cruiser" OptionList[1].value = 2 } if (ElementValue == 2) { OptionList[0].text = "Ford" OptionList[0].value = 1 OptionList[1].text = "Chevy" OptionList[1].value = 2 } } } --> </script> </head> <body> <FORM name="Contact" action="http://www.jimkeogh.com" method="post"> <P> <select name="OptionList" size="2"> <option Value=1>Classic <option Value=2>Police Cruiser </select> <BR> <INPUT TYPE="radio" name="vehicles" checked="true" value=1 onclick ="ResetOptionList(this.value)">Motorcycles <INPUT TYPE="radio" name="vehicles" Value=2 onclick="ResetOptionList(this.value)">Cars <BR> <INPUT name="Submit" value="Submit" type="submit"/> <INPUT name="Reset" value="Reset" type="reset"> </P> </FORM> </body> </html> ACTIONpack, +Kyle and riahc3 3 Share Link to comment Share on other sites More sharing options...
0 riahc3 Posted February 24, 2014 Share Posted February 24, 2014 Hello, jamieakers fixed it for you but there is something in your code missing... Link to comment Share on other sites More sharing options...
0 damindor Posted February 25, 2014 Author Share Posted February 25, 2014 OK cool I will try it I copied it directly from the text book so if its not written correctly I am just gonn move on Link to comment Share on other sites More sharing options...
0 jamieakers Posted February 26, 2014 Share Posted February 26, 2014 OK cool I will try it I copied it directly from the text book so if its not written correctly I am just gonn move on A lot of learning to program (regardless of language) is understanding the code of others, it's faults, and how to improve it. Rather than copy and paste mindlessly, take the time to understand what's happening. You'll learn a lot faster from the buggy code of others ! Link to comment Share on other sites More sharing options...
Question
damindor
Hello
why have I never head of option list?Is it deprecated?
Also this dont work I copied it directly from the book
Link to comment
Share on other sites
4 answers to this question
Recommended Posts