Re: A two flavored post
| From: | Dan | Date: | Sat, 13 Oct 2007 00:20:11 +0000 |
| Subject: | Re: A two flavored post | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-263170@lists.php.net to get a copy of this message | ||
In addition to what everyone else has suggested you probably also want to have your page work for people without javascript enabled, or the handicapped. One way you could do this is have a div and the PHP generates the div where you would put the link, with code for the link inside with the PHP variable so you have
----------------------
| abc.com/?a=value |
----------------------
the div wouldn't really have a border, it's just there so you can see it.
Anyway, for those lucky people who have JavaScript enabled you could simply use JS to change the innerhtml of the div to have the new JS generated link.
- Dan
Nathan Nobbe"" <quickshiftin@gmail.com> wrote in message news:7dd2dc0b0710042018p1bd43182x89f0b361c5946404@mail.gmail.com...
On 10/4/07, tedd <tedd@sperling.com> wrote:Hi gang: I asked this question on the javascript list, but for some reason it's taking forever to post there. So, I figured that I would ask here as well. I'm currently sending data (the value of s) to another script via the html statement: <a href="img.php?s=<?php echo($value);?>">Click here</a> However, I need to add another variable, namely a javascript variable, to the GET string. How can I send both a php and a javascript variable together at the same time?the question is when is the variable you want to append available to the javascript. as soon as you get the variable in the javascript the next thing you can do is append it to the value of the href attribute of the <a> tag. <html> <head><script type="text/javascript"> window.onload = function() { var someLinkHref = document.getElementById('someLink').href; someLinkHref += "&anotherVar=8"; alert(someLinkHref); } </script></head> <body><a id="someLink" href="http://somesite.com?a=5"> click here </a></body> </html> if you want to use the onclick event handler as rob suggested, you could stash the variable in the Window global object, then reference it in the implementation of the onclick function (though i still have mixed feelings about that approach [the Window object part that is]). -nathan -nathan