lilywong Posted February 22, 2006 Share Posted February 22, 2006 This is a simply drop down box with three selections, one, two and three. while i try to select option two, i need a message box pop up showing two, if i select option three, the message box will show three. However i got the below error while i select it. Any problem with this simple codes ?[b]Error: 'document.form1.select.value' is null or not an object[/b]==================================================================<?print_r($_POST); print"<br>";print_r($_GET);print"<br>";$a = $_GET[select];print $a;?><select name='select' onchange='go(this)'><option value='one'>one</option><option value='two'>two</option><option value='three'>three</option></select><form name='form1'><input type='hidden' name='txtSelect' value='select'></form><script type="text/javascript">function go(opt){ var name = document.form1.select.value; alert (name);}</script> Link to comment https://forums.phpfreaks.com/topic/3529-drop-down-list-problem/ Share on other sites More sharing options...
kenrbnsn Posted February 22, 2006 Share Posted February 22, 2006 This is a Javascript question, not a PHP question.Create a normal hard coded HTML form and get your javascript working, then put in your PHP.Ken Link to comment https://forums.phpfreaks.com/topic/3529-drop-down-list-problem/#findComment-12159 Share on other sites More sharing options...
hitman6003 Posted February 22, 2006 Share Posted February 22, 2006 Change your onchange to this:onchange="javascript: go(this, this.selectedIndex);"Change your JS function to this:<script type="text/javascript">function go(x, y) { alert (x[y].value);}</script>Please post your questions in the proper forum in the future...this should be in the Javascript forum. Link to comment https://forums.phpfreaks.com/topic/3529-drop-down-list-problem/#findComment-12204 Share on other sites More sharing options...
AndyB Posted February 23, 2006 Share Posted February 23, 2006 vroom - moved to javascript forum Link to comment https://forums.phpfreaks.com/topic/3529-drop-down-list-problem/#findComment-12214 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.