Jump to content

Getting PHP variables


sseeley

Recommended Posts

I have a number of text boxes which are given their IDs dynamically as the page loads.  This enables me to have 5 text boxes which I can then post to a database.  An example of the name would be

 

$name = "name" . $incrementNo;

 

Name would would then be Name 1, 2, 3, 4, 5 etc...I am trying to validate these with some javascript code and I am trying to use var name1 = document.getElementById("<?php echo $name; ?>").value; however the PHP page will not pass back the $name?

 

Any idea how I can get this working?

 

Thanks in advance.

 

Stuart

Link to comment
https://forums.phpfreaks.com/topic/204530-getting-php-variables/
Share on other sites

I have a number of text boxes which are given their IDs dynamically as the page loads.  This enables me to have 5 text boxes which I can then post to a database.

 

It would be easier to use your text boxes as array though. Take a look at the following post.

http://www.phpfreaks.com/forums/index.php/topic,299599.0.html

 

Name would would then be Name 1, 2, 3, 4, 5 etc...I am trying to validate these with some javascript code and I am trying to use var name1 = document.getElementById("<?php echo $name; ?>").value; however the PHP page will not pass back the $name?

What does the complete php look like where you are trying to fetch the $name var?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.