Jump to content

PHP Selection not showing on selction on dropbox


DigiMartKe
Go to solution Solved by cyberRobot,

Recommended Posts

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

Link to comment
Share on other sites

  • Solution

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.  :happy-04:

Link to comment
Share on other sites

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 by cyberRobot
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.