set an input value from jquery function
Posted
by
user1499220
on Stack Overflow
See other posts from Stack Overflow
or by user1499220
Published on 2012-08-31T09:36:42Z
Indexed on
2012/08/31
9:38 UTC
Read the original article
Hit count: 152
I'm simply trying to set a value for an input but it doesn't work. Here is my jquery function :
function display_form()
{ try {
$('#start_date').val('2012/08/21');
}catch (e){
alert('error');
}
window.alert( $('[name=start_date]').val() );
}
This shows "undefined". Here is my form :
<input id="start_date" name="start_date" type="text" size="6" />
Should I put somewhere the id of the form that I want to use? I just followed what is said in the documentation of jquery but it doesn't seem to work. Could anyone help me ?
© Stack Overflow or respective owner