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

B

Ben Brown

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
 
E

Erwin Moller

Ben said:
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
 
T

tomtom.wozniak

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top