• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Ok / Cancel window - link

 
Tom Dunne
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,
im having a problem linking to my class when the user clicks the ok button of a JavaScript Confirm window. Here is my problem.
<% out.println("<script language=\"JavaScript\">"); %>
function rusure() {
question = confirm("Are you sure you want to delete this document")
if(question !="0") {
location.href= "DocumentCommand.class?id=<%= primaryKey %>&command=DEL"
}
}
<% out.println("</script>");%>
Ok my problem is that the location.href does not allow the string to contain the %> after i display the value for the primary key therefore the &command=DEL never gets past to the url. It seems JavaScript doesnt like the JSP tags. Is there anyway i can get this to link using this JavaScript function ?? Please Help..... Thanks Tom.
 
Bosun Bello
Ranch Hand
Posts: 1510
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This may not be what you are trying to do. But I did something similar with...
<A HREF="/location/csd?widget=daddr&seqnbr=<%=patientAddress.getSequenceNbr()%>" onClick="return verifyDelete(); ">DELETE</A>

Bosun
 
Cameron Park
Ranch Hand
Posts: 371
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or you can split the first scriptlet into two smaller scriptlets.
<% out.println("<script language=\"JavaScript\">"); %>
function rusure() {
question = confirm("Are you sure you want to delete this document")
if(question !="0") {
location.href= "DocumentCommand.class?id=%>
<%= primaryKey %>
<%&command=DEL"
}
}%>
<% out.println("</script>");%>
But really, you don't need scriptlets at all. You can simply type your javascript code and add the expression to it.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic