Why won't this set the value of a hidden input?
- Code: Select all
HTML:
<input type="hidden" name="foo" id="foo">
jQuery JS:
$("#foo").val('bar');
Moderators: Timko, Solty, Frank Delicious, Blake_T, Fritz, Booter
HTML:
<input type="hidden" name="foo" id="foo">
jQuery JS:
$("#foo").val('bar');
$(input[name=foo]).val('bar');
Frank Delicious wrote:Are you sure there is a value for it to pull?
chiggins wrote:1. are you running Firebug in Firefox?
2. if you are, when the page loads, if you go to the console and put:
$("#foo").val('bar');
What's it return?
SkaBob wrote:
- Code: Select all
>>> $('#betaClientFormKey')
<html>
<head>
<script src="jquery.js"></script>
<script>
$(document).ready(function(){
alert("value of #foo before setting: " + $("#foo").val());
$("#foo").val("bar");
alert("value of #foo after setting: " + $("#foo").val());
});
</script>
</head>
<body>
<form>
<input type="hidden" name="foo" id="foo" value="not bar" />
</form>
</body>
</html>
>>> $("#foo")
[input#foo bar]
>>> $("#food")
[]
$("#vendorInterface").submit(function() {
$(this).ajaxSubmit({
beforeSubmit: validateForm,
cache: false,
success: function(xml) {
var fileMode = 'new' // <-- this is populated in perl because I got fed up with jQuery ignoring all of my hidden fields
if (fileMode == 'new') {
var newRequestId = $("request_id", xml).text();
var editURL = 'VendorInterfaceTracking.cgi?mode=edit&requestNum=' + newRequestId;
window.location = editURL;
}
},
error: function(xml) {
alert('There was a problem saving this request. Please file a support ticket.');
}
});
return false;
});
Content-Type: text/xml
Expires: Mon, 26 Jul 1997 05: 00: 00 GMT
<filer_response>
<request_id>88</request_id>
</filer_response>
SkaBob wrote:Hey chiggins...I got another funky one for ya...it's drivin' me up the wall and ruining my friday
Return to Off-Topic, Miscellaneous, etc.
Users browsing this forum: No registered users and 2 guests