1

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!

1
  • api.jquery.com/val -- .val() can be used to get/set the value of an input element. Give it a try :) Commented Jul 18, 2012 at 4:10

3 Answers 3

1
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());
        });
Sign up to request clarification or add additional context in comments.

Comments

1
$("hiddenfield").val($("hiddenfield").val() + "123abc");

Comments

0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.