7

Hi have an hidden input into an display:none div . I need to chenge the value of my input hidden but i can't.. I try this:

<div style='display:none'>
   <input id='hidden_input' name='xxx' type='hidden' value='' />
</div>

$("#hidden_input").val('test');

Hey help??

2
  • This should work. What happens or doesn't happen? When are you calling the script? Commented May 18, 2011 at 7:32
  • 3
    Works for me. Commented May 18, 2011 at 7:33

3 Answers 3

14

Have you included the jQuery library in your page, and put that line changing the value in the correct place?

Something like this:

<script type="text/javascript" src="location/of/jquery.js"></script>
<script type="text/javascript">
    $(function() {
        $("#hidden_input").val('test');
    });
</script>
Sign up to request clarification or add additional context in comments.

Comments

2

see this, could help you http://jsfiddle.net/g2fsQ/

Comments

2

The code you wrote should work. You also may have forgotten this bit of code :

$(document).ready(function(){
    // your code here
});

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.