Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
106
rated 0 times [  111] [ 5]  / answers: 1 / hits: 36520  / 11 Years ago, sat, march 9, 2013, 12:00:00

I have an input text field (name: qtyText) to which a user enters a value. I would like to set this value as the value for another hidden field (name: qtyTextHidden) using JavaScript. How can I go about it?



HTML



<input name = qtyText type = textbox size = 2 value =  />
<input type=hidden value = name=qtyTextHidden/>


My efforts to set the field value using JS work, but I am unable to send the value to the servlet. So I am attempting to directly set the value using a function and then try and send it to the servlet. I would like to have a value = someJSFunction() kind. The function needs to trigger upon onChange in the qtyText input field.


More From » jquery

 Answers
17

Using jQuery:



$(document).ready(function() {
$('input:text[name=qtyText]').keyup(function() {
$('input:hidden[name=qtyTextHidden]').val( $(this).val() );
});
});


Using JavaScript:



window.onload = function() {
if(document.readyState == 'complete') {
document.getElementsByTagName('input')[0].onkeyup = function() {
document.getElementsByTagName('input')[1].value = this.value;
};
}
}:

[#79708] Friday, March 8, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
aiyanakatelinp

Total Points: 578
Total Questions: 110
Total Answers: 111

Location: New Caledonia
Member since Thu, Mar 23, 2023
1 Year ago
;