alohatofu Posted April 22, 2007 Share Posted April 22, 2007 Hello, I have a link say <a href="javascript:freak_new()">click link </a> If i have varaibles that I want to carry with that link how would I do it? I can't use <a href="javascript:freak_new()?var=2783"> can't I? Thanks Quote Link to comment Share on other sites More sharing options...
AndyB Posted April 22, 2007 Share Posted April 22, 2007 <a href="javascript:freak_new(2783)"> might work if the js function can use 2783 Quote Link to comment Share on other sites More sharing options...
alohatofu Posted April 22, 2007 Author Share Posted April 22, 2007 so can i use <a href="javascript:freak_new(<?php $number ?>)"> ? Quote Link to comment Share on other sites More sharing options...
dwees Posted April 22, 2007 Share Posted April 22, 2007 Avoid use of the word JavaScript in your href's. Instead, use an href like #, and put your code for the function in the onclick attribute of your link. To answer your question, what you are suggesting will work, except you need to use <a href="#" onclick="return freak_new(<?php echo $number ?>)">Click me</a> If you use something like this format, you can return false, and cancel the link (if you need to). If you return true, the link goes through. Dave Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.