Jump to content

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?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.