Jump to content

JS not working in php file


Alicia

Recommended Posts

Hi guys,

 

I tried to use this code in html file and it is working fine but when i use the same code in php file (with get method/value after the file name . eg : file.php?id=1) the JS doesnt work anymore.. it still will direct to the next page eventhough the user click cancel.

 

My code for ur reference :


function confirmation() 
{
var answer = confirm("Lets confirm!")
if (answer==true)
{
alert("Proceed"); // code will be inserted to redirect user to next page
}
else
{
	alert("I am not done");
}
}
</script>


<input type="image" onclick="confirmation()" value="Lets confirm" src="images/myimage.gif" alt="<? echo $useme ?>" name="personal" />

 

Can somebody please let me know what I have done wrong and why the cancel button doesnt return back to the original page my php file? All I want is after the user click cancel, it will remove the alert box and display back to current page without directing the user to other page.

 

Please assist. Thank you.

 

 

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.