phppaper Posted February 15, 2011 Share Posted February 15, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/227694-pass-text-field-value-into-javascript-function/ Share on other sites More sharing options...
requinix Posted February 15, 2011 Share Posted February 15, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/227694-pass-text-field-value-into-javascript-function/#findComment-1174339 Share on other sites More sharing options...
phppaper Posted February 15, 2011 Author Share Posted February 15, 2011 case solved Quote Link to comment https://forums.phpfreaks.com/topic/227694-pass-text-field-value-into-javascript-function/#findComment-1174344 Share on other sites More sharing options...
phppaper Posted February 15, 2011 Author Share Posted February 15, 2011 case solved, thank you for requinix's idea Quote Link to comment https://forums.phpfreaks.com/topic/227694-pass-text-field-value-into-javascript-function/#findComment-1174347 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.