[PHP] Conditional anchor href value
I'm working on a page which displays details for a given record, and allows the user to flip back and forth through a large set of records, much like a set of index cards. Previous and Next buttons reload the card with the new record id. It is important that the URLs for the cards be very simple and static (easily bookmarked), along the lines of: card.php?id=123. The complexity comes because there are a number of ways in which one would want to flip back and forth: by date, by creator, etc. We have a select menu on the card which provides these options. If the prev/next buttons and select menu are part of a form, one can check the menu upon the reload of the page and find the correct new id, but the page in this case will not have a useful, clean URL. Most likely it will reference the referring card. We don¹t want that. What we need is a way of saying if the menu says date, use this id, etc. It seemed to me that we might be looking at problem requiring a client-side solution, but my javascript experiments have been frustrating, and seem to be veering into browser-conditional waters - one of the great arguments for server-side scripting. Still the js approach has been closest to what we need: the php script puts all the possible links from that card into the page, and then the js function uses the correct one. Does anyone have any advice? Thanks -eric -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Conditional anchor href value
you might be able to put the id of the next/prev card as the value of the option and then use javascript to generate the url. the only reliance then would be that the browser as JS enabled, as the above should be possible with the most basic of JS HTH Martin -Original Message- From: Eric Blanpied [mailto:[EMAIL PROTECTED] Sent: Wednesday, 3 December 2003 2:05 PM To: php-general Subject: [PHP] Conditional anchor href value I'm working on a page which displays details for a given record, and allows the user to flip back and forth through a large set of records, much like a set of index cards. Previous and Next buttons reload the card with the new record id. It is important that the URLs for the cards be very simple and static (easily bookmarked), along the lines of: card.php?id=123. The complexity comes because there are a number of ways in which one would want to flip back and forth: by date, by creator, etc. We have a select menu on the card which provides these options. If the prev/next buttons and select menu are part of a form, one can check the menu upon the reload of the page and find the correct new id, but the page in this case will not have a useful, clean URL. Most likely it will reference the referring card. We don¹t want that. What we need is a way of saying if the menu says date, use this id, etc. It seemed to me that we might be looking at problem requiring a client-side solution, but my javascript experiments have been frustrating, and seem to be veering into browser-conditional waters - one of the great arguments for server-side scripting. Still the js approach has been closest to what we need: the php script puts all the possible links from that card into the page, and then the js function uses the correct one. Does anyone have any advice? Thanks -eric -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php __ Information from NOD32 1.568 (20031202) __ This message was checked by NOD32 for Exchange e-mail monitor. http://www.nod32.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Conditional anchor href value
--- Eric Blanpied [EMAIL PROTECTED] wrote: Still the js approach has been closest to what we need: the php script puts all the possible links from that card into the page, and then the js function uses the correct one. Does anyone have any advice? Let PHP choose the correct one? Maybe something like this will work: a href=foo.php?bar=? echo $bar; ?Click here/a Then, you can let PHP choose what the appropriate value of bar should be. Show us some code, and I'm sure we can give you more specific examples. Chris = Chris Shiflett - http://shiflett.org/ PHP Security Handbook Coming mid-2004 HTTP Developer's Handbook http://httphandbook.org/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Conditional anchor href value
Chris Shiflett wrote: --- Eric Blanpied [EMAIL PROTECTED] wrote: Still the js approach has been closest to what we need: the php script puts all the possible links from that card into the page, and then the js function uses the correct one. Does anyone have any advice? Let PHP choose the correct one? Maybe something like this will work: a href=foo.php?bar=? echo $bar; ?Click here/a Then, you can let PHP choose what the appropriate value of bar should be. The trouble is that the value of $bar is dependent on the value of a select list. And, as noted in my original post, the hrefs for the pages need to end up being nice, static URLs which cleanly point to the correct data. -e -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Conditional anchor href value
Martin Towell wrote: you might be able to put the id of the next/prev card as the value of the option and then use javascript to generate the url. the only reliance then would be that the browser as JS enabled, as the above should be possible with the most basic of JS That's not all that different from what I'm doing. The following gets called from the left arrow graphic: function getLinkLeft(form) { var prevDate= ?php echo \$prevDate\; ?; var prevSrce= ?php echo \$prevSrce\; ?; if (form.setarrows.value == date) { location=prevDate; } else { location=prevResults; } } ... a href=javascript:getLinkLeft(self)img src=arrow.gif/a I know next-to-no javascript, so this has all been cobbled together via an afternoon's research. It appears to be what _should_ work, but it only behaves in one browser out of six I've tried (Safari). I'd just as soon ditch the JS, since I don't want to rely on it being enabled for this site. I just can't think of a server-side approach. -e -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php