I have a hidden input field defined in the html. I’m accessing the value of the input field but getting undefined.
HTML
<html>
<head>
<script src="js/jquery-1.6.4.js" type="text/javascript"></script>
<script src="js/myjquery.js" type="text/javascript"></script>
</head>
<body>
<form>
<input type="hidden" name="hidden1" value="test" id="hidden1">
</form>
</body>
</html>
UPDATED HTML
<html>
<head>
<script src="js/jquery-1.6.4.js" type="text/javascript"></script>
</head>
<body>
<form>
<script src="js/myjquery.js" type="text/javascript"></script>
<input type="hidden" name="hidden1" value="test" id="hidden1">
</form>
</body>
</html>
UPDATED 2 HTML
<html>
<head>
<script src="js/jquery-1.6.4.js" type="text/javascript"></script>
</head>
<body>
<form>
<script src="js/myjquery.js" type="text/javascript"></script>
<input type="hidden" name="sk.hidden1" value="test" id="sk.hidden1">
</form>
</body>
</html>
JQuery
$(document).ready(function () {
var inputParam = $("input#sk.hidden1").val();
alert(inputParam);
});
Wild guessing here but seams that you are probably not including jQuery correctly.
Try to include jQuery in the following fashion:
Edit:
Even though your ID is valid it is frowned uppon because jQuery will treat that as id.class.
Meaning it is looking for a field that has ID =
skclass =hidden1.If you must work it that way you should have your selector with an escape:
But I would sugest you rename your ID to someting else and discard the usage of dots in ID’s or classes. Use the
-or_as both are supported.The rules to name an ID are pretty simple: