So I have a hidden field on my form which contains a URL (EG - http://www.domain.com?asset=)
What I need to do is on form submit extract the value from a checkbox and append it to the value in my hidden form so that the result will look something like:
http://www.domain.com?asset=123abc
Thanks in advance!
3 Answers 3
var url = 'http://www.domain.com?asset=',
jq_checkbox = $('input#my-check-box'), // suppose id of your checkbox is my-check-box
jq_hidden = $("input#my-hidden-field"), // and id of your hidden field is my-hidden-field
jq_form = $('form#my-form') // and id of your form is my-form
.submit(function(){
jq_hidden.val(url + jq_checkbox.val());
});
answered Jul 18, 2012 at 4:37
craftsman
15.7k17 gold badges74 silver badges87 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
$("hiddenfield").val($("hiddenfield").val() + "123abc");
answered Jul 18, 2012 at 4:10
Bishnu Paudel
2,0891 gold badge22 silver badges39 bronze badges
Comments
Simple call this function on form submir or click event you want you get your desired output here i check output by alert
<script>
function check(){
var checkbox= $("#checkbox").val();
var hidden_val= $("#url").val()+checkbox;
alert(hidden_val);
}
</script>
here
checkbox is checkbox ID url is hideen item ID
hope it will help you
Comments
lang-js
.val()can be used to get/set the value of an input element. Give it a try :)