Friday, May 17, 2024
 Popular · Latest · Hot · Upcoming
109
rated 0 times [  116] [ 7]  / answers: 1 / hits: 180227  / 15 Years ago, fri, december 25, 2009, 12:00:00

How to get value of the get or post variable on page load using JavaScript?


More From » javascript

 Answers
19

You can't get the value of POST variables using Javascript, although you can insert it in the document when you process the request on the server.



<script type=text/javascript>
window.some_variable = '<?=$_POST['some_value']?>'; // That's for a string
</script>


GET variables are available through the window.location.href, and some frameworks even have methods ready to parse them.


[#97989] Tuesday, December 22, 2009, 15 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
daytonm

Total Points: 519
Total Questions: 83
Total Answers: 89

Location: Saudi Arabia
Member since Mon, Sep 5, 2022
2 Years ago
;