0

That's what I have:

<a href="<?=$arItem["LINK"]?>#nav-link">LinkName</a>

Here <?=$arItem["LINK"]?> I'm getting some link, and I want to add to the end of this link some extra hashtag parameter #nav-link.

But the main problem is that PHP is executing on the server side, so, when I click the link, I get only link from the <?=$arItem["LINK"]?> (blabla.com). After second click, I have necessary code blabla.com/#nav-link.

So, is it possible to get blabla.com/#nav-link after first click?

asked Oct 1, 2014 at 19:50
3
  • use anything but the # if you want it to be sent to the server and not just the browser Commented Oct 1, 2014 at 19:52
  • You could set a var in jquery and have PHP populate that variable with what you want and then use that var in your code further down the line. Commented Oct 1, 2014 at 19:53
  • If you want to change the link after the page loads - why don't you just use jQuery to append the link instead of relying on PHP? Commented Oct 2, 2014 at 8:44

1 Answer 1

1

Try something to the tune of this:

<script>
 var data = <?php echo $arItem["LINK"]; ?>
 var yourLink = "blabla.com/"+data;
 //more of your code etc....
 $('#yourDiv_where_you_want_the_link').html(yourLink);
 </script>
answered Oct 1, 2014 at 20:02
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.