Forum Moderators: open

Message Too Old, No Replies

How to access this field for an update?

         

grtzs

8:30 pm on Nov 10, 2005 (gmt 0)

10+ Year Member



I've the following hidden field in my contact form:


<form name='contact'>
<input type='hidden' name='s0[cmd]' value=''>
</form>

How can I update the value? I tried things like:


document.contact.s0['cmd'].value = 'new value';

But that does not work :S

ajkimoto

8:57 pm on Nov 10, 2005 (gmt 0)

10+ Year Member



grtzs,

First of all:

Welcome to Webmaster World!

As for your question, you should probably rewrite your code like this:

<form name='contact'>
<input type='hidden' name='s0[cmd]' id='s0[cmd]' value='' />
<button onclick="document.getElementById('s0[cmd]').value='new value'">clickme</button>
</form>

That should do the trick with all modern browsers at least--you need an id attribute on the form element for this to work. It doen't have to have to be the same as the name attribute, but it is less confusing to do so.

Hope this helps,

ajkimoto

grtzs

9:20 pm on Nov 10, 2005 (gmt 0)

10+ Year Member



Thnx a million! Sometimes solutions can be so simple :)