royalcyber
asked on
How can I change the value of a hidden variable if the user clicks on a specific button
Following is the code of my form and buttons. Based on the update variable I show differnt buttons
Now the problem is that if the update value = -1, the JSP shows 2 buttons SAVE and SAVE AS NEW.
When user clicks on SAVE it update the record based on the hidden id "ueid"
Now what I need is that when the user clicks on SAVE AS NEW it should change the ueid to "". If I can do that I can reuse the entire code
Any help will be greatly appreciated
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- -----
<form name="myform" enctype="multipart/form-da ta" action="chapter_admin?acti on=add_doc uments" method="post" onSubmit="return verify();">
<% String document_id = null;
document_id = new Integer(selected_document. getDocumen t_ID()).to String();
%>
<input type="hidden" name="ueid" value="<%= document_id %>">
.
.
.
<% if(update == "-1"){ %>
<td><input type="submit" class="button" value="Save" onClick="parent.location=' chapter_ad min?action =update_do cuments&ei d=<%= selected_document.getDocum ent_ID() %>'"></td>
<td><input type="button" class="button" value="New" onClick="parent.location=' chapter_ad min?action =show_docu ments'"></ td>
<% } else { %>
<td><input type="submit" class="button" value="Add Document"></td>
<% } %></tr>
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------
Now the problem is that if the update value = -1, the JSP shows 2 buttons SAVE and SAVE AS NEW.
When user clicks on SAVE it update the record based on the hidden id "ueid"
Now what I need is that when the user clicks on SAVE AS NEW it should change the ueid to "". If I can do that I can reuse the entire code
Any help will be greatly appreciated
--------------------------
<form name="myform" enctype="multipart/form-da
<% String document_id = null;
document_id = new Integer(selected_document.
%>
<input type="hidden" name="ueid" value="<%= document_id %>">
.
.
.
<% if(update == "-1"){ %>
<td><input type="submit" class="button" value="Save" onClick="parent.location='
<td><input type="button" class="button" value="New" onClick="parent.location='
<% } else { %>
<td><input type="submit" class="button" value="Add Document"></td>
<% } %></tr>
--------------------------
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
"wierd results"
what this mean?
what this mean?
ASKER
By "wierd result" I meant that when I run the application and click on the button to add the data to the database. It adds the data twice in the database, which I guess is beacuase of two submit buttons.
ASKER
--------------------------
<tr>
<% if(update == "-1"){ %>
<td><input type="submit" class="button" value="Save Event" onClick="parent.location='
<td><input type="submit" class="button" value="Save As New" onClick="parent.location=a
<% } else { %>
<td><input type="submit" class="button" value="Add Event"></td>
<% } %></tr>
--------------------------
Now if I use two buttons with type="submit" it gives me wierd results such that when i try to add an event it adds two events instead of one
Also if I try to use type="button" it doesn't submit all the values of the form to the servlet
Now what I need is that if there is a way I can submit all the form to the request parameter, so that I can retreive it in the servlet and also get the value parameter of the buton clicked
Thanks