How do I get the value of a textfield without posting the form
Is there anyway I can get the value of a text field without posting a form. I would like to use the value somewhere else in开发者_高级运维 the same page.
The answer is to use some sort of client-side scripting.
With plain old Javascript, if your text field has ID 'textField':
document.getElementById('textField').value;
Or with jQuery:
$('#textField').text();
You can use JavaScript. textarea
elements have a value
property that holds whatever text is in them.
You can call a javascript function on any events (By example when your text field loose focus) and get the text field value by using the value
property.
var t=document.getElementById('textField').value;
alert(t);
精彩评论