-2
<span id="abc">MY_Data</span>

I want "MY_Data" as value in a php variable Any help will be greatly appretiated Note this value"MY_Data" is dynamic as it is generated through javascript function Thanks in Advance Swapnil

Swapnil
  • 151
  • 1
  • 3
  • 9
  • 1
    PHP is server side, so it can't directly read dynamic javascript entered text, you could post the contents to a php file with ajax maybe and store it in a session, just an idea – Dale Feb 01 '13 at 08:02

1 Answers1

0

PHP cannot read html elements. But there are many ways to send data to your php page. Use JavaScript for this ; or if you are using a form, store this value in a hidden field like this :

<input type="hidden" value="MY_Data" name="abc" />

If you do not have a form, but a link, you could also add a parameter to your url, like

<a href="page.php?abc=MY_Data">link</a>

and then retrieve it with $_GET['abc'].

Vianney Dupoy de Guitard
  • 2,254
  • 1
  • 14
  • 10
  • http://stackoverflow.com/questions/8779682/retrieve-data-contained-a-certain-span-class this link might give u an idea as i was unable to understand the code – Swapnil Feb 01 '13 at 09:04
  • @Swapnil That can't be applied in your case since you said that the `span` content is generated by JavaScript, which runs on the visitors' browser, which is long after all PHP processes are complete. – rlatief Feb 01 '13 at 11:02