Simple Javascript Funtion - 2 Choices, each going to a different URL
<p>I'm trying to figure out how to have a Confirm/Decline box pop up when someone clicks a link. When they click "Ok" it takes them to one place, when they click "Cancel" it takes them to another place. Most of my experience is with php but usually I can take other javascript functions and make them work.. can't seem to figure this one out though.</p>

<p>Here's my script:</p>

<pre><code>function confirmChoice(name, newid){
    answer = confirm("Transfer Ownership of this task to " + name + 
                     "? Press Cancel to decline.")
    if (answer == 1) {
        location = "transfer.php?task=&lt;? echo $taskid; ?&gt;&amp;from=&lt;? echo ownerid; ?&gt;&amp;to=" + newid;
    } elseif (answer==0) {
        location = "decline.php?task=&lt;? echo $taskid; ?&gt;";
    }   
}
</code></pre>

<p>Any help would be greatly appreciated!</p>

<p>EDIT: Okay, changed the code as suggested. Now it is:</p>

<pre><code>function confirmChoice(name, newid){
var answer = confirm("Transfer Ownership of this task to " + name + "? Press Cancel to decline.")
if (answer){
location = "transfer.php?task=&lt;? echo $thistaskid; ?&gt;&amp;from=&lt;? echo $ownerid; ?&gt;&amp;to=" + newid;
}else{
location="decline.php?task=&lt;? echo $thistaskid; ?&gt;";
}   
}
</code></pre>

<p>And the link used is: </p>

<pre><code>&lt;a href="#" onclick="confirmChoice(&lt;? echo $requestorname; ?&gt;, &lt;? echo $newid; ?&gt;); return false;"&gt;&lt;? echo $requestorname; ?&gt; Requested Ownership&lt;/a&gt;
</code></pre>

<p>I still don't get a confirm box.. thanks so much for the help!</p>
