This is a discussion on Re: [PHP] A two flavored post within the PHP General forums, part of the PHP Programming Forums category; ALSO: <a href="img.php?i=<?php echo($value);?>" onclick="window.location = this.getAttribute( '...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
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 <tedd@sperling.com> 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 > > |
|
|||
|
>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 |
|
|||
|
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 > |
|
|||
|
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 |
![]() |
| Thread Tools | |
| Display Modes | |
|
|