homepage Welcome to WebmasterWorld Guest from 107.20.25.215
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
How to fill a <input type="hidden"> using Javascript
Wicketywick




msg:4015514
 10:59 am on Oct 29, 2009 (gmt 0)

I want to complete my form with a bit of Javascript (which I know next to nothing about, to fill out a hidden input field).

The input field is:

<input type="hidden" name='field[537,0]' value='' />

the dropdown selection positions are:

<select name='field[539,0] >
<option value='Herr'>Herr</option>
<option value='Frau'>Frau</option>

the command I am looking for would be:

if "Herr" is selected, add "sehr geehrter" to
"field[537,0]" and if "Frau" is selected add "sehr geehrte".

How does that get done?

 

inveni0




msg:4015683
 4:40 pm on Oct 29, 2009 (gmt 0)

Add something like this to your <select> tag:

<select name="field[539,0]" id="field[539,0]" onChange="updateHidden(this.value);">

Then you need a function to do the updating...something like:

function updateHidden (choice) {
hiddenField = document.getElementById('fieldid');
if(choice == "Herr") { hiddenField.value = "sehr geehrter"; }
if(choice == "Frau") { hiddenField.value = "sehr geehrte"; }
}

Not tested. But you get the idea, right?

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved