Log in

View Full Version : OUTPUT contents of an <input> to JS variable



arataon
07-13-2012, 06:00 PM
Hi ,

I've looked on Google for a solution to this but I'm not sure what to search for.

Basically I have a website that has a form and I want to pass a variable of the form to a JS popup box (Tinybox 2) which uses Ajax to post data to PHP. However, I can't work out how I would get the contents of:


<input name="welcomeboxInputA" type="text">


to the following code which posts in PHP to the popup box:


<a onclick="TINY.box.show({url:'post.php',post:'title=**TITLE FROM THE INPUT BOX** ' })">


Thanks for your help :-)

jscheuer1
07-13-2012, 06:13 PM
This:


<a onclick="TINY.box.show({url:'post.php',post:'title=' + document.getElementsByName('welcomeboxInputA')[0].value });">

should do it.

The browser cache may need to be cleared and/or the page refreshed to see changes.

If you want more help, please include a link to the page on your site that contains the problematic code so we can check it out.

arataon
07-13-2012, 06:37 PM
Hi John,

Thanks for that, just what I needed! Works a treat! :-)

Thanks again!

Best,

Cobain.