Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

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

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

New User

5+ Year Member

joined:Sept 25, 2009
votes: 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?

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

Preferred Member

10+ Year Member

joined:Nov 22, 2005
votes: 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?


Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members