[dx] Posted June 7, 2009 Report Share Posted June 7, 2009 (edited) What's wrong with this, and can it be done at this way? <a href='java script: function_name($some_var);'>Something</a><script type="javascript"> function function_name($some_var) { var r = confirm('Some Question?'); if (r == true) { some command; }}</script> This won't work for me in any case.RegardsNote: javascript word in a href tag is one word for me, this is some bug with forum Edited June 7, 2009 by Haris S Link to comment Share on other sites More sharing options...
clonetrooper9494 Posted June 7, 2009 Report Share Posted June 7, 2009 (edited) Replace 'some command' with some actual code, the script crashes because it doesn't know what some command means. Also, why do you have parameters in your function? Also, don't use dollar signs($) for variables in your parameters... just say some_var. Also, when calling function_name in that link, some_var would have to be declared out side of the function or be a string.The forum just feels like splitting the phrase "javascript" up for some reason. No one is really sure why it does that. Edited June 7, 2009 by CloneTrooper9494 Link to comment Share on other sites More sharing options...
[dx] Posted June 8, 2009 Author Report Share Posted June 8, 2009 <a class='admin' href='java script: reset_stats($profil)'>Reset</a> function reset_stats(profil) { var r = confirm('Zelite li resetovat statistike za korisnika $profil?'); if (r == true) { header("location: index.php?admin=reset&op=$profil"); }} Link to comment Share on other sites More sharing options...
Ingolme Posted June 8, 2009 Report Share Posted June 8, 2009 You're confusing Javascript with PHP, they are two separate languages. There is no header() function in Javascript. Link to comment Share on other sites More sharing options...
[dx] Posted June 9, 2009 Author Report Share Posted June 9, 2009 Is there command in javascript that can replace PHP's header() function? Link to comment Share on other sites More sharing options...
justsomeguy Posted June 9, 2009 Report Share Posted June 9, 2009 You can't send headers with Javascript, it doesn't make sense to do that. If you want to redirect, you can set window.location.href to whatever URL you want. Link to comment Share on other sites More sharing options...
[dx] Posted June 9, 2009 Author Report Share Posted June 9, 2009 OK, that will be helpful :)Regards Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now