Home > DeveloperSection > Forums > Select value to Hidden input using HTML and javascript
john rob

Total Post:108

Points:756
Posted on    August-16-2013 6:52 AM

 JavaScript JavaScript 
Ratings:


 1 Reply(s)
 871  View(s)
Rate this:
Hi Mindstick!

I know there's already lots of topics about this and i think i read them all but i still can't get it to work. 

I need to update the choosen value from my select to a hidden input field. 

When i try this code for example it doesn't work. When i check the source code the value is still empty. 

What am i doing wrong? 

 <form>

    <select id="dropdown" name="dropdown" onchange="changeHiddenInput(this)">

        <option value="j.hotmail.com">Jens</option>

        <option value="a.hotmail.com">Adam</option>

        <option value="d.homtail.com">Dan</option>

    </select>

    <input type="hidden" name="hiddenInput" id="hiddenInput" value="" />

 </form> 

    function changeHiddenInput (objDropDown)

    {

        var objHidden = document.getElementById("hiddenInput");

        objHidden.value = objDropDown.value;

    }   

Lot's of thanks in advance!



shreesh chandra shukla
shreesh chandra shukla

Total Post:105

Points:735
Posted on    August-17-2013 6:28 AM

Hi!
 you should to try this.

You can use jQuery its much easier:

var objHidden = $('#hiddenInput').val(objDropDown);

thanks


Don't want to miss updates? Please click the below button!

Follow MindStick