Roch
Roch

Reputation: 22041

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.

Upvotes: 0

Views: 1382

Answers (4)

var t=document.getElementById('textField').value;  
alert(t);

Upvotes: 0

Matt Ball
Matt Ball

Reputation: 359906

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();

Upvotes: 3

Patrice Bernassola
Patrice Bernassola

Reputation: 14426

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.

Upvotes: 0

slikts
slikts

Reputation: 8158

You can use JavaScript. textarea elements have a value property that holds whatever text is in them.

Upvotes: 1

Related Questions