DigiMartKe Posted November 3, 2015 Share Posted November 3, 2015 I have written the following code; <label for="System">Symptom</label> <label for="Symptom"> <select name="Symptom" id="SymptomId" onchange="Symselect()"> <p id="demo"></p> <script> function Symselect() { var x = document.getElementById("Symptomid").value; document.getElementById("demo").innerHTML = "You selected: " + x; } </script> This is not working. When a select an item on the dropbox , it should display the selection. Similar to http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_onchange. Kindly assist . Azhar Quote Link to comment https://forums.phpfreaks.com/topic/299053-php-selection-not-showing-on-selction-on-dropbox/ Share on other sites More sharing options...
Ch0cu3r Posted November 3, 2015 Share Posted November 3, 2015 The code you posted is not PHP. What you posted is HTML/Javascript. The PHP Help forum is for getting help with your PHP code not HTML/Javascript. We have specific forums sections for those languages. Quote Link to comment https://forums.phpfreaks.com/topic/299053-php-selection-not-showing-on-selction-on-dropbox/#findComment-1525328 Share on other sites More sharing options...
Solution cyberRobot Posted November 3, 2015 Solution Share Posted November 3, 2015 You're using "SymptomId" here: <select name="Symptom" id="SymptomId" onchange="Symselect()"> And "Symptomid" here: var x = document.getElementById("Symptomid").value; Those values need to match. Note: the values are case sensitive. Note that I moved the topic to the JavaScript forum. Quote Link to comment https://forums.phpfreaks.com/topic/299053-php-selection-not-showing-on-selction-on-dropbox/#findComment-1525339 Share on other sites More sharing options...
cyberRobot Posted November 3, 2015 Share Posted November 3, 2015 (edited) Also, note that the code posted isn't complete. Perhaps you just didn't post it all, but you're missing the <option> tags and the end </select> tag. And for what it's worth, you should consider reviewing the documentation for the <label> tag. https://developer.mozilla.org/en-US/docs/Web/HTML/Element/label Edited November 3, 2015 by cyberRobot Quote Link to comment https://forums.phpfreaks.com/topic/299053-php-selection-not-showing-on-selction-on-dropbox/#findComment-1525340 Share on other sites More sharing options...
DigiMartKe Posted November 4, 2015 Author Share Posted November 4, 2015 (edited) Thanks , your hints worked Edited November 4, 2015 by DigiMartKe Quote Link to comment https://forums.phpfreaks.com/topic/299053-php-selection-not-showing-on-selction-on-dropbox/#findComment-1525409 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.