This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Servlets and the fly likes Ok / Cancel window - link Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Ok / Cancel window - link" Watch "Ok / Cancel window - link" New topic
Author

Ok / Cancel window - link

Tom Dunne
Greenhorn

Joined: Aug 02, 2001
Posts: 1
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

Joined: Nov 06, 2000
Posts: 1510
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


Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
Cameron Park
Ranch Hand

Joined: Apr 06, 2001
Posts: 371
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Ok / Cancel window - link
 
Similar Threads
javascript confirm() function issue in IE 9
Servlet and Frame Problem
Javascript Guru Needed
catching page change or browser close
manipulating frames