Results 1 to 3 of 3

Thread: OUTPUT contents of an <input> to JS variable

  1. #1
    Join Date
    Jul 2012
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post OUTPUT contents of an <input> to JS variable

    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 :-)

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    29,025
    Thanks
    44
    Thanked 3,210 Times in 3,172 Posts
    Blog Entries
    12

    Default

    This:

    Code:
    <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.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Jul 2012
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hi John,

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

    Thanks again!

    Best,

    Cobain.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •