php - Javascript scope and sequentiality issue -


i want id query , display in html.

i want keep things in separate javascript files, because in future, retrieve json php , filter based on checkboxes, radio buttons, etc. , display result.

in moment, blank page, , id value not shown, i'm doing wrong.

http://localhost:10600/js1/index.php?id=5 

index.php

<html> <head> <script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js'></script> </head>     <body>         <div class="results"></div>     </body> </html>  <script type="text/javascript" src="config.js"></script> <script type="text/javascript" src="display.js"></script> <script type="text/javascript" src="sequence.js"></script> 

config.js

function getid() {     id = "<?php echo $_get['id']; ?>"; } 

display.js

function updatehtml() { window.onload = function() {     document.queryselector('.results').innerhtml = id; } } 

sequence.js

function seq() {     getid();     updatehtml();    } seq(); 

please try following: index.php

<html> <head> <script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js'></script> </head>     <body>         <div class="results"></div>     </body> </html>  <script type="text/javascript"> var id; function getid() {     id = "<?php echo $_get['id']; ?>"; }  </script> <script type="text/javascript" src="display.js"></script> <script type="text/javascript" src="sequence.js"></script> 

Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -