Sunday, 8 September 2013

Changing the Forms text and Hidden Value by specifying the Form and Field Names

Changing the Forms text and Hidden Value by specifying the Form and Field
Names

<form id="dasForm" method="post" action="bootcamp.php">
<input type="text" class="dasName" name="dasName" value=""
autocomplete="off">
<input type="hidden" class="dasHandle" name="dasHandle" value="default">
<input value="Submit" id="dasAddThis" class="dasAddThis" type="submit">
</form>
<div class="temp">Temp Link</div>
I'm trying to set the values for a text field and a hidden field by
specifying the form name and the text and hidden field in the form since
there are many form on the page and things may be mixed up if I do not do
so.
I'm doing it this way as follows, but nothing changes. If you can see
where I go wrong, can you please help me out?
$(document).ready(function() {
$('.temp').click(function() {
$('#dasForm .input[name=dasName]').val('New Name');
$('#dasForm .input[name=dasHandle]').val('Das New Value');
});
});

No comments:

Post a Comment