I have resorted to everything I can think of and I can't get a PHP variable to go into a form that is onclicked with a Javascript Function...

Here is my attempts thus far:

  1. Give the div that contains the onclick function the php variable as an id, and then attempt to extract the id in the Javascript function. I can't get the javascript to pull the id of the div using this.parentNode.id or getElementsByTagName.id or related methods.

    <div id="tom" getID()>

    function getID(){
    var id = document.getElementsByTagName("div")


    function getID{
    var id=this.parentNode.id

Pulling my hair out I only have a few left..

Recommended Answers

All 2 Replies


Need a bit more to go on:

  • "get a PHP variable" : How served; as part of the original page or in response to an AJAX call?
  • "to go into a form": What part of the form; as an attribute of the form tag, as a value of an input element, ...?
  • "that is onclicked with a Javascript Function": What is clicked? It's not particularly normal to attach an onclick event to a form.

What are acually trying to achieve?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.