Beginners Question (javascript)...

They have: 330 posts

Joined: Apr 2000

I know something is wrong with this code but I don't know how to fix it. I want to use the number associated with the onClick event to substitute for "the_Entry".

<?php
&lt;script language=\"javascript\"&gt;
function verifyDelete(the_Entry){
    varDelete = confirm('Are you sure you want to delete this?');
   
    if(varDelete == true)
        {
        window.location=\"DeleteEntry.asp?Entry=the_Entry\";
        }
}
&lt;/script&gt;
?>

Thanks for your help.

Suzanne's picture

She has: 5,507 posts

Joined: Feb 2000

how odd, why are you using { instead of {?

Anyway,

you need to replace language="javascript" with type="text/javascript", probably escape it out for older browsers unless it's a called function from another page.

What error are you getting? I'm a little rusty on JavaScript today (ha ha), but you might want to make varDelete var Delete.

I'm not sure, though,

Suzanne

They have: 330 posts

Joined: Apr 2000

It just redirects me to the URL:
DeleteEntry.asp?Entry=the_Entry

this BB changed it from a { to {.

Suzanne's picture

She has: 5,507 posts

Joined: Feb 2000

k, then you have to make the_Entry or whatever a variable.

var the_Entry = document.forms[0].field.value;

My guess is that you need to initialize the variable.

My syntax is wildly incorrect, but hopefully that will get you started on the right solution, or maybe Vinny will show up and help!

Smiling Suzanne

javascriptworld.com -- try here, and try Dori's book for help too.

They have: 330 posts

Joined: Apr 2000

Thank you.

While playing with it I realized I had it still in the quotes. I removed it from the quotes and it worked.

<?php
&lt;script language=\"javascript\"&gt;
function verifyDelete(the_Entry, Date){
    varDelete = confirm('Are you sure you want to delete this?' + the_Entry);
   
    if(varDelete == true)
        {
        window.location=\"DeleteEntry.asp?Entry=\" + the_Entry + \"&Date=\" + Date;
        }
}
&lt;/script&gt;
?>

Thank you again for your help. You got me looking in the right direction.

Suzanne's picture

She has: 5,507 posts

Joined: Feb 2000

Darn quotes! Smiling

I actually got stuck for two days because of a precadence problem.

Glad you found it, even with my crappy advice, lol...

Smiling S

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.