Jump to content

pass text field value into javascript function


phppaper

Recommended Posts

Hello all,

 

I would like to pass a textfield value into a javascript function:

 

Here is the function:

 

<script type="text/javascript">

function changetext(){

document.getElementById('text').value='TEXTFIELD textB's value'}

</script>

 

HTML Form:

 

Onclick, the value of textfield "text" will change to whatever textfield "textB"'s value

<input type="button"  value="change" onclick="changetext();" />

 

I want to get this value and pass to the function:

<input type="text" value="This is what to get" name="textB" id="textB" />

 

<input type="text" name="text" id="text" />

 

 

 

Please help

 

 

 

If you want to actually pass the value as a function argument, that's one thing.

 

If you're just throwing that terminology around because it's what you heard, then there's an easier way. See that document.getElementById function? See what it does? Think about it and try using it.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.