getting javascript-generated input element values with POST (php)

Discussion in 'Javascript' started by Ben Brown, Jan 24, 2008.

  1. Ben Brown

    Ben Brown Guest

    I'm having some problems.. I have some javascript generated input
    elements with dynamic names and values.

    ex:
    <input name = "t1Name" .../>
    <input name = "t2Name" .../>
    .....
    <input name = "tnName".../>


    On submission, i'm trying to get the values in a php script using
    $_POST and I can't get any values out of them.. always getting null.

    Is it even possible to get javascript-generated input values using
    php?

    Thanks,
    Ben
     
    Ben Brown, Jan 24, 2008
    #1
    1. Advertising

  2. Ben Brown

    Erwin Moller Guest

    Re: getting javascript-generated input element values with POST(php)

    Ben Brown wrote:
    > I'm having some problems.. I have some javascript generated input
    > elements with dynamic names and values.
    >
    > ex:
    > <input name = "t1Name" .../>
    > <input name = "t2Name" .../>
    > ....
    > <input name = "tnName".../>
    >
    >
    > On submission, i'm trying to get the values in a php script using
    > $_POST and I can't get any values out of them.. always getting null.
    >
    > Is it even possible to get javascript-generated input values using
    > php?
    >
    > Thanks,
    > Ben


    Hi Ben,

    From PHP (where the action in the form posts to), try this:
    echo "Post contains:<pre>";
    print_r($_POST);
    echo "</pre>";
    exit;

    That way you will see WHAT the form has posted.

    If you do not see your t1Name in that array, your form DIDN'T post it at
    all.

    Good luck.

    Regards,
    Erwin Moller
     
    Erwin Moller, Jan 25, 2008
    #2
    1. Advertising

  3. Ben Brown

    Guest

    Re: getting javascript-generated input element values with POST (php)

    On Jan 24, 3:58 pm, Ben Brown <> wrote:
    > I'm having some problems.. I have some javascript generated input
    > elements with dynamic names and values.
    >
    > ex:
    > <input name = "t1Name" .../>
    > <input name = "t2Name" .../>
    > ....
    > <input name = "tnName".../>
    >
    > On submission, i'm trying to get the values in a php script using
    > $_POST and I can't get any values out of them.. always getting null.
    >
    > Is it even possible to get javascript-generated input values using
    > php?
    >
    > Thanks,
    > Ben


    Image: http://www.postyourimage.com/view_image.php?img_id=MdhEIVLatVeHlcN1201301635

    If you can figure out ahead of time how many boxes you need to create,
    you can output the spans, shown below, from PHP. Using a bit of
    javascript at the bottom of your html page, you simply insert your
    input boxes using innerHTML.

    <!-- save as dynamic.html -->
    <span id="span001"></span><br>
    <span id="span002"></span><br>
    <span id="span003"></span><br>
    <span id="span004"></span><br>
    <span id="span005"></span><br>
    <span id="span006"></span><br>
    <span id="span007"></span><br>
    <span id="span008"></span><br>
    <input type="button" value="Get Dynamic Value"
    onClick="alert( document.getElementById('dynamo1').value );" />
    <script>
    for ( var i=1; i < 9; i++ ) {
    var key = 'span00'+i;
    var val = '<input id="dynamoDIGIT" type="textbox" value="This is
    field DIGIT." />'.replace(/DIGIT/g,i);
    document.getElementById(key).innerHTML = val;
    }
    </script>

    Let me know if this helps!

    -Tom Woz
     
    , Jan 25, 2008
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Good Man
    Replies:
    1
    Views:
    980
    Good Man
    Mar 3, 2006
  2. Replies:
    3
    Views:
    403
  3. Rajive Narain
    Replies:
    0
    Views:
    1,990
    Rajive Narain
    Sep 18, 2009
  4. Replies:
    3
    Views:
    228
    frothpoker
    Sep 4, 2006
  5. M. Strobel
    Replies:
    1
    Views:
    229
    The Natural Philosopher
    Mar 5, 2013
Loading...

Share This Page