Forum Moderators: open

Message Too Old, No Replies

javascript:ajaxpage

         

dredwiser

5:49 pm on Dec 21, 2010 (gmt 0)

10+ Year Member



I have a link that targets a div tag
<a href="#" onclick="javascript:ajaxpage('mypage.php?cid=<?PHP echo $variable1; ?>', 'contentarea');" style="cursor:hand" title="<?PHP echo $variable2; ?>"><?PHP echo $variable3; ?>

The link works great and does what it is supposed to do, however i need $variable1 to go to the url bar so i can use it in a diffrent query. If I use href="#?cid=$varibale1" before the on click event, it does go to the URL but then the onclick event doesn't work. I hope this makes sense, can anyone help me out with this? Is there a way to pass the onclick event variables to the url without having to use the href="#?cid=$varibale1"?

Thanks
in advance

Fotiman

6:12 pm on Dec 21, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Welcome to WebmasterWorld!

It depends on what you're trying to do. It looks to me as though you're trying to make an AJAX call and avoid a page refresh. If that's the case, then no, you can't modify the URL in the address bar without causing a page load.

When you say "so I can use it in a different query", is that "different query" also an AJAX request? That is, does it operate client side without a page refresh? If so, then you could simply store the value in a JavaScript variable. As it is now, your link is not going to work for people that have JavaScript disabled.

Could you provide a little bit more detail about what you're trying to accomplish?

dredwiser

6:19 pm on Dec 21, 2010 (gmt 0)

10+ Year Member



I have a category menu in a div tag that is populated by a PHP query, I use the link
<a href="#" onclick="javascript:ajaxpage('mypage.php?cid=<?PHP echo $variable1; ?>', 'contentarea');" style="cursor:hand" title="<?PHP echo $variable2; ?>"><?PHP echo $variable3; ?>
to display those results into another div tag with the id="contentarea" how ever I need the cid variable to be available in the main page so i can make a query to display title and meta information.