1

Hi I'm making some changes to a bespoke ICT system and am struggling to set a idoc script variable.

<$ dDocID = <script> document.getElementById("docID") </script>$>
<$ dDocID = $> <script> document.getElementById("docID") </script>

I have had success setting javascript variables to the values of idoc script variables but not the other way around.

Any suggestions or even syntax guesses would be appreciated.

MajorTennis
  • 78
  • 1
  • 9
  • @quentin: Is this actually a duplicate? See: http://meta.stackexchange.com/questions/207207/different-questions-for-same-problem-in-different-language-duplicate-or-not – Guffa Feb 06 '15 at 11:00
  • @Guffa — Yes, the answers focus on the theory of having some code on the client and some on the server. The PHP used in the examples is really trivial and a small part of the answers. – Quentin Feb 06 '15 at 11:06

1 Answers1

1

You can't do that.

The idoc script runs on the server to generate the page. When the idoc script is finished the page is sent to the browser, where the Javascript runs. You can't send any information from the Javascript to the idoc script that created the page, because by the time the Javascript runs, the idoc script is already done.

To send any information from the browser to an idoc script, you have to make a new request back to the server, so that a new idoc script starts.

Guffa
  • 687,336
  • 108
  • 737
  • 1,005