Reputation: 151
I'm afraid I don't do a lot of work with JQuery, and was unable to find an answer to this in the documentation. I am trying to use JQuery to pass multiple text inputs to a hidden field. So far I have got the following:
<script type="text/javascript">
$(function(){
$('#textinput1').blur(function() {
$('input[name=hiddenField]').val($('#textinput1').val());
});
});
</script>
This works fine for pulling a single line over to the hidden field. However, I have two additional fields that I need to also display in the hidden field so that the value of the hidden field represents all three of these text inputs. Any thoughts?
Upvotes: 1
Views: 1356
Reputation: 11461
This answers your exact question.
$(function(){
$('#textinput1,#textinput2,#textinput3').blur(function() {
$('input[name=hiddenField]').val(
$('#textinput1').val() + " " +
$('#textinput2').val() + " " +
$('#textinput3').val());
});
});
But generally speaking, unless there's a good reason not to, we'd want a different hidden fields for each one of these.
Upvotes: 3