Re: [PHP] A two flavored post
i was just working on some stuff and remembered how ive handled a problem like this in the past. the issue you have to wrestle w/ is the anchor tag will perform its normal behavior after the onclick handler has finished executing. basically, onclick is just part of the process for the anchor tag. well, what ive done in the past is determined, its only a link if you think its a link :) so i just toss some css on a span tag to make it look like a link, then you get full control over the onclick behavior. heres some sample css: /* anchor imitator */ span.anchorImitator { font-size: 11px; font-family: Verdana,Arial,Helvetica,san-serif; font-weight: 400; color: #1505A5; text-decoration: none; } span.anchorImitator:hover { cursor:pointer; font-size: 11px; font-family: Verdana,Arial,Helvetica,san-serif; font-weight: 400; color: #AEF3F9; text-decoration: underline; } of course it wont do much w/o javascript enabled. -nathan
Re: [PHP] A two flavored post
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 [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] On 10/4/07, tedd [EMAIL PROTECTED] 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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] A two flavored post
ALSO: a href=img.php?i=?php echo($value);? onclick=window.location = this.getAttribute( 'href' ) + 's=' + s; return false; can be altered to be: a href=img.php?i=?php echo($value);? onclick=this.setAttribute(this.getAttribute( 'href') + 's=' + s); What exactly do you need to do, anyways? Maybe there'll be some better way to do this. I'm sure there is a better way. I was just trying to get a user's selection (in an CMS I'm developing) without a refresh. Something like this: http://www.webbytedd.com/c/js-maintain-state/ But ultimately, I was faced with a trade-off. 1) I could use javascript with no refresh, but lose hover; 2) Or, I could use php and maintain hover, but be forced to accept refresh. So, I went back to php and accomplished what I wanted with a *lot* less code. My thinking, the user shouldn't object to a refresh while editing. Thanks for everyone's help. Cheers, tedd Rob -- it now works with js turned off. :-) -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] A two flavored post
At 12:58 PM -0400 10/5/07, Daniel Brown wrote: ? $s = $_GET['s']; ? script language=JavaScript function writeHREF(value,title) { var url = http://www.crusar.org/test.php;; var currentTime = new Date(); var month = currentTime.getMonth(); var day = currentTime.getDate(); var year = currentTime.getFullYear(); var jsvalue = month + '/' + day + '/' + year; document.write('a href=' + url + '?s=' + value + 'jsvalue=' + jsvalue + '' + title + '/a'); } /script This is where your JS link will appear, Tedd: script language=JavaScript writeHREF('?=$s;?','Test Link'); /script Daniel That's slick. I solved the problem by using: a href=img.php?i=?php echo($value);? onclick=window.location = this.getAttribute( 'href' ) + 's=' + s; return false; But, I am sure I will be using your's sometime soon. Thanks, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] A two flavored post
At 1:26 PM -0400 10/5/07, Nathan Nobbe wrote: strange; i missed that when i put it together; my bad, it was late. here is a revision that works. html head script type=text/javascript window.onload = function() { var someLink = document.getElementById('someLink'); someLink.href += anotherVar=8; alert(document.getElementById('someLink').href); } /script /head body a id=someLink href= http://somesite.com?a=5; click here /a /body /html the problem was the local variable was being assigned the value of the attribute, not the reference to the tag in the dom. i have now set it to be a reference to the variable in the dom. -nathan: Not that I provided information otherwise, but document.getElementById won't work in this case because there are several links involved. As such, I have to use document.getElementByClass and that has problems. Unfortunately, my solution isn't unobtrusive. a href=img.php?i=?php echo($value);? onclick=window.location = this.getAttribute( 'href' ) + 's=' + s; return false; However, I couldn't see a way to make it so. Many thanks for your time and effort. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] A two flavored post
On Sat, 2007-10-06 at 13:41 -0400, tedd wrote: At 1:26 PM -0400 10/5/07, Nathan Nobbe wrote: strange; i missed that when i put it together; my bad, it was late. here is a revision that works. html head script type=text/javascript window.onload = function() { var someLink = document.getElementById('someLink'); someLink.href += anotherVar=8; alert(document.getElementById('someLink').href); } /script /head body a id=someLink href= http://somesite.com?a=5; click here /a /body /html the problem was the local variable was being assigned the value of the attribute, not the reference to the tag in the dom. i have now set it to be a reference to the variable in the dom. -nathan: Not that I provided information otherwise, but document.getElementById won't work in this case because there are several links involved. As such, I have to use document.getElementByClass and that has problems. Unfortunately, my solution isn't unobtrusive. a href=img.php?i=?php echo($value);? onclick=window.location = this.getAttribute( 'href' ) + 's=' + s; return false; However, I couldn't see a way to make it so. Why not? I'm guessing because you need to the link to have the JavaScript variable in it. If this is the case then the href target should link to a page informing the user that they need to have JavaScript installed. By doing so you inform them of why clicking on the link is not having the desired outcome :) Cheers, Rob. -- ... SwarmBuy.com - http://www.swarmbuy.com Leveraging the buying power of the masses! ... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] A two flavored post
At 1:49 PM -0400 10/6/07, Robert Cummings wrote: On Sat, 2007-10-06 at 13:41 -0400, tedd wrote: Unfortunately, my solution isn't unobtrusive. a href=img.php?i=?php echo($value);? onclick=window.location = this.getAttribute( 'href' ) + 's=' + s; return false; However, I couldn't see a way to make it so. Why not? I'm guessing because you need to the link to have the JavaScript variable in it. If this is the case then the href target should link to a page informing the user that they need to have JavaScript installed. By doing so you inform them of why clicking on the link is not having the desired outcome :) Cheers, Rob. Rob: I would agree with you IF I was creating a web page for the general public. However, what I am creating in my laboratory is a monster of my own making that will be used only by my clients AND those clients will be required to have javascript turned on. Sometimes, programming for the lowest common denominator limits possibilities. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] A two flavored post
ALSO: a href=img.php?i=?php echo($value);? onclick=window.location = this.getAttribute( 'href' ) + 's=' + s; return false; can be altered to be: a href=img.php?i=?php echo($value);? onclick=this.setAttribute(this.getAttribute( 'href') + 's=' + s); What exactly do you need to do, anyways? Maybe there'll be some better way to do this. On 10/6/07, tedd [EMAIL PROTECTED] wrote: At 1:49 PM -0400 10/6/07, Robert Cummings wrote: On Sat, 2007-10-06 at 13:41 -0400, tedd wrote: Unfortunately, my solution isn't unobtrusive. a href=img.php?i=?php echo($value);? onclick=window.location = this.getAttribute( 'href' ) + 's=' + s; return false; However, I couldn't see a way to make it so. Why not? I'm guessing because you need to the link to have the JavaScript variable in it. If this is the case then the href target should link to a page informing the user that they need to have JavaScript installed. By doing so you inform them of why clicking on the link is not having the desired outcome :) Cheers, Rob. Rob: I would agree with you IF I was creating a web page for the general public. However, what I am creating in my laboratory is a monster of my own making that will be used only by my clients AND those clients will be required to have javascript turned on. Sometimes, programming for the lowest common denominator limits possibilities. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] A two flavored post
At 11:18 PM -0400 10/4/07, Nathan Nobbe wrote: On 10/4/07, tedd mailto:[EMAIL PROTECTED][EMAIL PROTECTED] 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=5http://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: Your example worked very well to provide an alert showing exactly what I needed to be in the href string. However, it didn't work to actually alter the actual link href string -- even when I commented out the alert. IOW, it remained: http://somesite.com?a=5http://somesite.com?a=5 instead of: http://somesite.com?a=5http://somesite.com?a=5anotherVar=8 I like the idea of keeping the code unobtrusive and working as it did -- I just need it to work as a link. Any ideas? This is so close. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] A two flavored post
On 10/5/07, tedd [EMAIL PROTECTED] wrote: At 11:18 PM -0400 10/4/07, Nathan Nobbe wrote: On 10/4/07, tedd mailto:[EMAIL PROTECTED][EMAIL PROTECTED] 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=5http://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: Your example worked very well to provide an alert showing exactly what I needed to be in the href string. However, it didn't work to actually alter the actual link href string -- even when I commented out the alert. IOW, it remained: http://somesite.com?a=5http://somesite.com?a=5 instead of: http://somesite.com?a=5http://somesite.com?a=5anotherVar=8 I like the idea of keeping the code unobtrusive and working as it did -- I just need it to work as a link. Any ideas? This is so close. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Tedd, try this (it's also live and working at http://www.crusar.org/test.php): ? $s = $_GET['s']; ? script language=JavaScript function writeHREF(value,title) { var url = http://www.crusar.org/test.php;; var currentTime = new Date(); var month = currentTime.getMonth(); var day = currentTime.getDate(); var year = currentTime.getFullYear(); var jsvalue = month + '/' + day + '/' + year; document.write('a href=' + url + '?s=' + value + 'jsvalue=' + jsvalue + '' + title + '/a'); } /script This is where your JS link will appear, Tedd: script language=JavaScript writeHREF('?=$s;?','Test Link'); /script -- Daniel P. Brown [office] (570-) 587-7080 Ext. 272 [mobile] (570-) 766-8107 Give a man a fish, he'll eat for a day. Then you'll find out he was allergic and is hospitalized. See? No good deed goes unpunished -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] A two flavored post
This might be a way to do it: *Example 1* script function appendMeBaby(aVar){ self.location.href = 'img.php?s=' + aVar + 'someOtherVar=itIsMeTheValue'; } /script a href=javascript:appendMeBaby(?php echo($value);?);Click here/a *Example 2* script function appendMeBaby(aVar, bVar){ self.location.href = 'img.php?s=' + aVar + 'someOtherVar=' + bVar; } /script a href=javascript:appendMeBaby(?php echo($value);?, 'itIsMeTheOtherValue');Click here/a Hope this helps Aleksandar Daniel Brown wrote: On 10/5/07, tedd [EMAIL PROTECTED] wrote: At 11:18 PM -0400 10/4/07, Nathan Nobbe wrote: On 10/4/07, tedd mailto:[EMAIL PROTECTED][EMAIL PROTECTED] 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=5http://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: Your example worked very well to provide an alert showing exactly what I needed to be in the href string. However, it didn't work to actually alter the actual link href string -- even when I commented out the alert. IOW, it remained: http://somesite.com?a=5http://somesite.com?a=5 instead of: http://somesite.com?a=5http://somesite.com?a=5anotherVar=8 I like the idea of keeping the code unobtrusive and working as it did -- I just need it to work as a link. Any ideas? This is so close. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Tedd, try this (it's also live and working at http://www.crusar.org/test.php): ? $s = $_GET['s']; ? script language=JavaScript function writeHREF(value,title) { var url = http://www.crusar.org/test.php;; var currentTime = new Date(); var month = currentTime.getMonth(); var day = currentTime.getDate(); var year = currentTime.getFullYear(); var jsvalue = month + '/' + day + '/' + year; document.write('a href=' + url + '?s=' + value + 'jsvalue=' + jsvalue + '' + title + '/a'); } /script This is where your JS link will appear, Tedd: script language=JavaScript writeHREF('?=$s;?','Test Link'); /script -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] A two flavored post
strange; i missed that when i put it together; my bad, it was late. here is a revision that works. html head script type=text/javascript window.onload = function() { var someLink = document.getElementById('someLink'); someLink.href += anotherVar=8; alert(document.getElementById('someLink').href); } /script /head body a id=someLink href= http://somesite.com?a=5; click here /a /body /html the problem was the local variable was being assigned the value of the attribute, not the reference to the tag in the dom. i have now set it to be a reference to the variable in the dom. -nathan On 10/5/07, tedd [EMAIL PROTECTED] wrote: At 11:18 PM -0400 10/4/07, Nathan Nobbe wrote: On 10/4/07, tedd mailto:[EMAIL PROTECTED][EMAIL PROTECTED] 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=5http://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: Your example worked very well to provide an alert showing exactly what I needed to be in the href string. However, it didn't work to actually alter the actual link href string -- even when I commented out the alert. IOW, it remained: http://somesite.com?a=5http://somesite.com?a=5 instead of: http://somesite.com?a=5http://somesite.com?a=5anotherVar=8 I like the idea of keeping the code unobtrusive and working as it did -- I just need it to work as a link. Any ideas? This is so close. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] A two flavored post
On Fri, 2007-10-05 at 19:19 +0200, Aleksandar Vojnovic wrote: This might be a way to do it: *Example 1* script function appendMeBaby(aVar){ self.location.href = 'img.php?s=' + aVar + 'someOtherVar=itIsMeTheValue'; } /script a href=javascript:appendMeBaby(?php echo($value);?);Click here/a *Example 2* script function appendMeBaby(aVar, bVar){ self.location.href = 'img.php?s=' + aVar + 'someOtherVar=' + bVar; } /script a href=javascript:appendMeBaby(?php echo($value);?, 'itIsMeTheOtherValue');Click here/a I don't believe that is standards-compliant use of the href attribute. Also it doesn't degrade gracefully for people who have JavaScript disabled. Cheers, Rob. -- ... SwarmBuy.com - http://www.swarmbuy.com Leveraging the buying power of the masses! ... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] A two flavored post
On Thu, 2007-10-04 at 22:33 -0400, tedd 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? Use an onclick= event handler. Cheers, Rob. -- ... SwarmBuy.com - http://www.swarmbuy.com Leveraging the buying power of the masses! ... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] A two flavored post
On 10/4/07, tedd [EMAIL PROTECTED] 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
Re: [PHP] A two flavored post
A simple example would be a href=img.php?s=?php echo($value);? onclick=this.href += 'othervalue=x';Click here/a On 10/4/07, Robert Cummings [EMAIL PROTECTED] wrote: On Thu, 2007-10-04 at 22:33 -0400, tedd 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? Use an onclick= event handler. Cheers, Rob. -- ... SwarmBuy.com - http://www.swarmbuy.com Leveraging the buying power of the masses! ... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php