I am asking two things.
The first question is am I doing this correctly? I am putting together a li开发者_如何学编程nk with javascript variables
http://google.com/test.php?var="+class4
And then I am using php to get the values of the variables from the URL
Can I use a link at all to do the variables or must I use a button? When using the link nothing shows in the url after the
?
.
To make the link you'd need to do something like
var link = "http://google.com/test.php?class=" + "class4";
To go there you would do something like
location.href = link;
And in the PHP code to get the value, you would do something like
$class = $_GET['class'];
Link should look like http://google.com/test.php?var=class4 (There is no need for quotes or +)
then you can do echo $_GET['var'];
hmm what dou you get out of this :
var url = 'http://google.com/test.php?var='+class4;
alert(url);
Assuming 'class4' is an variable in javascript you have created. otherwise
var url = 'http://google.com/test.php?var=class4';
alert(url);
Does this give you the url you are wanting to redirect to ?
if so try to copy paste the alert from the alert into the browsers adresbar and test if it works
in the php page just after
精彩评论