breezy
breezy

Reputation: 1918

Changing the value of a form input field with jquery

how can i change the value of this input field using jquery?

<input type="hidden" name="emailaddress" value="[email protected]">

Upvotes: 1

Views: 554

Answers (2)

thecodeparadox
thecodeparadox

Reputation: 87073

$('input:hidden[name=emailaddress]').val('something');

Here,

input:hidden point to hidden input

[name=emailaddress] check for name attribute.

so totally

$('input:hidden[name=emailaddress]') select the input which is hidden and with name attribute emailaddress.

.val() used to set/get value to input field. With parameter it acts as a setter and getter without it.

Upvotes: 5

GreenGiant
GreenGiant

Reputation: 521

you need to give the input an id and then reference the id and change it. below is what i have used to change the value of a radio button. this uses JS

     document.getElementById('ID').value = somevalue;

Along with

    <input type="hidden" name="emailaddress" id ='ID'value="[email protected]">

Upvotes: 1

Related Questions