473,398 Members | 2,165 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Clearing text boxes

5
I have a "Cancel" button on a form that when clicked brings the user back to the previous page where he had entered data into two different text boxes and also had to click a radion button. I can get the user back but can not space out the two text boxes and unchecked the radio buttons.

Here is the button
[HTML]<input type="button" onClick="history.go(-1);clearForm();return true;" name="CancelButton" value="Cancel" class="button">
[/HTML]
And the function clearForm()

Expand|Select|Wrap|Line Numbers
  1. function clearForm() {
  2.  
  3.    document.all("myForm").value = ""
  4.    //document.myForm.thetext.value = '';
  5.    //document.myForm.searchParm.value = '';
  6.    //document.getElementById("myForm").reset();
  7.    //document.myForm.setthetext(" ");
  8.    //document.myForm.setCheckedValue("none");
  9.    //document.getElementById("myForm").reset();
  10.    //document.myForm.thetext.focus();
  11. }
  12.  
  13.  
Nothing works.
Aug 20 '07 #1
9 2452
gits
5,390 Expert Mod 4TB
heya,

Expand|Select|Wrap|Line Numbers
  1. document.getElementById("myForm").reset();
should do the trick. to get it to work you should have an id assigned to your form-element id = "myForm" ...

kind regards

ps: and please use the appropriate CODE tags when posting code ... that makes it easier for readers to read the code ... ;)
Aug 20 '07 #2
JShea
5
Thanks. I tried that and it did not work.
Aug 21 '07 #3
gits
5,390 Expert Mod 4TB
hi ...

the following works ... i tested it right now! have a close look at this example.

[HTML]
<html>
<head>
<script type="text/javascript">
function clear_form() {
var form = document.getElementById('my_form');
form.reset();
}
</script>
</head>
<body>
<form id="my_form">
<input type="text" name="test"/>
<input type="button" value="reset" onclick="clear_form();"/>
</form>
</body>
</html>
[/HTML]

kind regards
Aug 21 '07 #4
JShea
5
Thanks again, but I still can not achieve my task. Although your reply worked, it did not fit into what I have to do.

Here is the jsp file I am working on. I tried to skinny it down as best I could without eliminating anything that may be needed. I bolded and Italicized the "input" statement where I have to put the "Cancel" button, near the botton of the second jsp file.

There is actually two different screens involved in this form. The first is where you enter your search criteria. That is the first frame/part where I need to eventually bring the user back to and reset the form. You then hit the "Search" button that brings you to the second part of the form where the "Cancel" button needs to be installed. The button should bring the user back to the original part of the form and clear the text boxes and radio buttons there. I need to make it work just like a "Back" button then a "Reset" button combined into one.

Here is the two jsp files involved.

***************** First jsp file *******************************

[HTML]<HTML>
<HEAD>
<TITLE> AAAAA Resources </TITLE>
<link rel="stylesheet" type="text/css" href="/enroll/css/employer.css">

</HEAD>
<body>
<table CELLSPACING=0 CELLPADDING=0 WIDTH=100%>
<tr><td colspan=3>

<jsp:include page="admin_details_blank.jsp" flush="false">
</jsp:include>

</td></tr>
<tr>

<td colspan=3>

<jsp:include page="button_bar.jsp" flush="false">
</jsp:include>

</td></tr>
<tr>
<td valign=top width=150>

<jsp:include page="admin_details_custName.jsp"flush="false">
</jsp:include>
</td>

<td>&nbsp;&nbsp;&nbsp;</td>

<td valign=top>
<br/>

<jsp:include page="find_subscriber_customers.jsp"flush="false">
</jsp:include>

</td>
</tr>
</table>

[/HTML]*************** End of first jsp ***********************************


*** Second jsp file, find_subscriber_customers.jsp ***************

Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  2. <HTML>
  3. <HEAD>
  4. <%@ page language="java" 
  5.     import="com.aaaaa.util.*,java.util.*,java.lang.*,java.net.*,com.aaaaa.health.custsetup.database.*,com.aaaaa.health.enroll.memberenroll.business.ProductGridConstants"%>
  6.  
  7. <jsp:useBean id="EzEnroll_EzUser" beanName="com.aaaaa.health.enroll.EzUser"
  8.  type="com.aaaaa.health.enroll.EzUser" scope="session">
  9. </jsp:useBean> 
  10.  
  11. <jsp:useBean id="CUSTOMER_CONTAINER" beanName="com.aaaaa.health.enroll.ui.EzCustomer"
  12. type="com.aaaaa.health.enroll.ui.EzCustomer" scope="session">
  13. </jsp:useBean> 
  14.  
  15. <jsp:useBean id="customerData" beanName="com.aaaaa.health.enroll.ui.EzCustomerData"
  16. type="com.aaaaa.health.enroll.ui.EzCustomerData" scope="session">
  17. </jsp:useBean>     
  18.  
  19. <jsp:useBean id="PLAN_CONTAINER" beanName="com.aaaaa.health.enroll.ui.plan.EzPlanContainer"
  20.      type="com.aaaaa.health.enroll.ui.plan.EzPlanContainer" scope="session">
  21. </jsp:useBean>
  22.  
  23. <jsp:useBean id="applySuccessful" beanName="java.lang.String" type="java.lang.String" scope="session">
  24. </jsp:useBean>
  25.  
  26. <jsp:useBean id="applyMessage" beanName="java.lang.String" type="java.lang.String" scope="session">
  27. </jsp:useBean>
  28.  
  29. <jsp:useBean id="view" beanName="java.lang.String" type="java.lang.String" scope="session">
  30. </jsp:useBean>
  31.  
  32. <jsp:useBean id="ezPortalEntry" beanName="java.lang.String" type="java.lang.String" scope="session">
  33. </jsp:useBean>
  34.  
  35. <jsp:useBean id="customerdata" beanName="java.lang.String" type="java.lang.String" scope="session">
  36. </jsp:useBean>
  37.  
  38. <TITLE>Get Subscriber and Customers</TITLE>
  39. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  40.  
  41. <META name="GENERATOR" content="IBM WebSphere Studio">
  42. <link rel="stylesheet" type="text/css" href="/enroll/css/employer.css">
  43. <script language="JavaScript" type="text/javascript" src="/enroll/script/global.js"></script>
  44.  
  45. <script type="text/javascript">
  46.     function clear_form() {
  47.         var form = document.getElementById('ssnForm');
  48.         form.reset();
  49.     }
  50. </script>
  51.  
  52. </HEAD>
  53. <BODY>
  54.  
  55. <FORM NAME="ssnForm" ID="ssnForm" METHOD="POST" TARGET="_top" ACTION="/enroll/EzGetMember">
  56.  
  57. <!-- START error TABLE -->
  58.  
  59.  <%  if (PLAN_CONTAINER.getErrorTable().size() > 0)
  60.    //if (errorMessages.size() > 0)
  61.     {%>
  62.  
  63.     <table cellspacing="0" cellpadding="1" border="0" width="100%" align="center">
  64.     <tr>
  65.         <td>
  66.         <table cellspacing="0" cellpadding="0" border="0" width="100%" >
  67.         <tr>
  68.             <td height="1" nowrap></td>
  69.         </tr>    
  70.         <tr>
  71.             <td>
  72.             <table cellspacing="0" cellpadding="0" border="0" width="100%" >
  73.             <tr>
  74.             <td>
  75.             <table cellspacing="0" cellpadding="5" border="0" width="100%">
  76.             <tr>
  77.                 <td align="left" class="Error" height="20px">
  78.                  Error</td>        
  79.             </tr>
  80.             </table>
  81.             </td>
  82.         </tr>    
  83.         <tr>
  84.             <td>
  85.             <table cellspacing="0" cellpadding="7" border="0" width="100%">
  86.             <tr>
  87.                 <td class=body>
  88.                 <%   //System.out.println("FS JSP:: The error messages hashtable has elements");           Enumeration enum =  PLAN_CONTAINER.getErrorTable().elements();
  89.               //Enumeration enum = errorMessages.elements();
  90.               while (enum.hasMoreElements())
  91.               {
  92.               out.println("<font color=red>" + enum.nextElement()+ "</font>");
  93.                       }%>            
  94.                 </td>
  95.                 </tr></table></td>
  96.                 </tr></table></td></tr></table>
  97.                 </td></tr></table>
  98.                 <br>
  99.                    <%}else{
  100.               // System.out.println("FS JSP::  NO errors in errorMessages hashtable");
  101.             }%>                
  102.  
Expand|Select|Wrap|Line Numbers
  1. <!-- start search CRITERIA table-->
  2.  
  3.     <% if (view.equals ("c") && !EzEnroll_EzUser.hasRestrictedCustomerAccess()) 
  4.     {%>        
  5.     <table cellspacing="0" cellpadding="1" border="0" width="100%" align="center">
  6.         <tr>
  7.         <td>
  8.         <table cellspacing="0" cellpadding="0" border="0" width="100%" >
  9.         <tr>
  10.         <td height="1" nowrap></td>
  11.         </tr>    
  12.         <tr>
  13.         <td>
  14.         <table cellspacing="0" cellpadding="0" border="0" width="100%" >
  15.         <tr>
  16.             <td>
  17.             <table cellspacing="0" cellpadding="5" border="0" width="100%">
  18.             <tr>
  19.             <td align="left" class="Bodybold">Search Criteria</td>
  20.             </tr>
  21.             </table>
  22.             </td>
  23.         </tr>    
  24.         <tr><td></td></tr>    
  25.         <tr>
  26.         <td>
  27.         <table cellspacing="0" cellpadding="7" border="0" width="100%">
  28.         <tr>
  29.  
  30.             <td><span class="bodyBold">Search Type: <% if (!customerData.getSearchType().equals ("customer_name")) out.println(customerData.getSearchType()); else out.println("Plan Sponsor Name");%> &nbsp;&nbsp;
  31.             <B>Search by:</B>  <%=customerData.getSearchParm()%></span>
  32.             </td>
  33.             </tr></table></td>
  34.             </tr></table></td>
  35.             </tr></table></td>
  36.             </tr></table><br>
  37.  
  38.     <%}%>    
  39. <!-- END Search Criteria Table-->        
  40.  
  41. <table cellspacing="0" cellpadding="1" border="0" width="100%" align="center">
  42.  
  43. <tr>
  44. <td valign="top" class="headlineEmployer" align="center">Find/Enroll Subscriber</td>   
  45. </tr>
  46.  
  47. <tr><td valign="top">
  48.  
  49. <table width="100%" border="0" cellspacing="0" cellpadding="0">
  50. <tr>
  51.  
  52. <BR/><BR/>
  53.  
  54. <table cellspacing="0" cellpadding="0" border="0" width="100%" align="center"> 
  55. <tr><td valign="top">    
  56.  
  57. <td class="bodyBold" valign="top" align="left" nowrap width=50%>*Please Enter Subscriber Social Security Number:</td>        
  58. <td class="body" align="left" width=50%>
  59. <% if (ezPortalEntry.equals("true")) 
  60. { %>
  61.     <input type="text" maxlength="9" size="12" name="ssn" value="<%= customerData.getSSN() %>" />
  62. <%}else{ %>
  63.  
  64.     <input type="text" maxlength="9" size="12" name="ssn" value="<%=customerData.getSSN()%>" />
  65.     <%} %>
  66. </td>
  67. </tr>
  68. </table>
  69.  
[HTML]<!--START SEARCH OPTIONS (if multi customer access)-->
<% String tempName = " ";
// if ( (!EzEnroll_EzUser.hasRestrictedCustomerAccess() && customerData.getViewInd().equals ("search") || customerData.getViewInd() == null ) )
if( (!EzEnroll_EzUser.hasRestrictedCustomerAccess() && customerData.getCustomerNames() == null) ||
(!EzEnroll_EzUser.hasRestrictedCustomerAccess() && view.equals ("s") || view.equals (" ") ) )

{
//System.out.println("the customer does not have single customer access ");
//System.out.println("the customerNames array = " + customerData.getCustomerNames() );
//System.out.println("the view = " + view);
//System.out.println("the viewInd = " + customerData.getViewInd());

%>
<table cellspacing="0" cellpadding="0" border="0" width="100%">
<tr><td valign="top">

<table cellspacing="0" cellpadding="0" border="0" width="100%">
<tr><td class="bodyBold" valign="top" align="left">*Please Select a Search Option:</td></tr>

<tr><td class="body" align="left">

<!-- SELECT SEARCH BY-->

<input type=radio name="searchBy" value="control" <%= customerData.getSelectedValueControl()? "checked" : "" %>><span class="bold">Control # </span><br>
<input type=radio name="searchBy" value="group" <%= customerData.getSelectedValueGroup()?"checked" : "" %>><span class="bold">Group #</span><br>
<input type=radio name="searchBy" value="name" <%= customerData.getSelectedValueName()?"checked" : "" %>><span class="bold">Plan Sponsor Name</span>

<br><br>

<span class="bold">&nbsp;Search by:</span>&nbsp;
<input type="text" name="searchParm" size=6 maxlength=50 value="<%=customerData.getSearchParm()%>">
<BR>
</td></tr></table>
</td></tr></table>

<BR>

<!-- END SEARCH OPTIONS-->
<div align="left"><input type="submit" name="search" value="Search" class="button"/></div>

</table>
</td></tr></table>

<!--Main grid ends -->

<%}else if (customerData.getCustomerNames() != null && customerData.getViewInd().equals("choose") )
{
//System.out.println("JSP:: The customerData object has customerNames");
// System.out.println("JSP:: The customerData object has " + customerData.getCustomerNames());
}%>

<!--Start CUSTOMER LIST section for multi customer user -->

<% //if ezCustData is not null then print results in drop down list box
String [] customerNames = customerData.getCustomerNames();
if ((customerNames != null && customerData.getViewInd().equals("choose")) ||
(customerNames != null && view.equals ("c") ) )
{
//System.out.println("JSP:: creating the drop down list box of customers");
//this is needed to enclose the value chosen in quotes
//so the whole string will be sent to the DB in the query
//String tempName = " "; %>

<!-- PLAN SPONSOR NAME INSTR-->
<table cellspacing="0" cellpadding="1" border="0" width="100%" align="center">
<tr><td valign="top">

<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr><td valign="top" class="bodybold" align="left" width=50%>
*Please Select the Name for this subscriber:</td>

<td class="body" align="left" width=50%>

<!-- NAME TAB-->

<% //System.out.println("JSP::The customerNames array from EzCustomerdata is not null");
customerNames = customerData.getCustomerNames();
%>

<SELECT name="customerChoice" size=5>
<!--<FONT FACE=Arial SIZE=2 COLOR="black">-->
<% if(customerNames.length > 1)
{%>
<OPTION value=""selected>
--- Select one ---
</OPTION>
<%}else{%>

<%}%>
<% int count = customerNames.length;
//System.out.println(" JSP:: (multi-customer) the length of customer names = " + count);
%>

<!-- tsx:repeat index="i" -->
<% for (int ii = 0; ii < count; ii++)
{ %>
<% tempName = customerNames[ii];%>

<% if (!(ii < count))
throw new ArrayIndexOutOfBoundsException();%>
<OPTION VALUE="<%=tempName%>"<%if(customerNames.length == 1){%>selected<%}%>> <%=customerNames[ii] %>
</OPTION>
<% } %>
<!-- /tsx:repeat -->

</SELECT>

<BR><BR>

</TD>
</TR>
</TABLE>
</td></tr></table>

<!--END CUSTOMER LIST for multi_customer user -->

[B]<div align="center">
<input type="submit" name="back" value="Back" class="button">&nbsp;&nbsp;
<input type="submit" name="continue" value="Continue" class="button">&nbsp;&nbsp;
<input type="button" name="ssn" value="Cancel" onclick="history.go(1);clear_form();"/>
</div>
[/b]
<td></tr></table></td></tr></table>
<!-- end of plan sponor list for multi-customer user-->

<%}
//if EzUser has customer names and the user is a single customer user print the drop down list box
else if (EzEnroll_EzUser.getCustomerNames() != null && EzEnroll_EzUser.hasRestrictedCustomerAccess())
{

customerNames = EzEnroll_EzUser.getCustomerNames();
//System.out.println("JSP::The customerNames array is not null");
customerNames = EzEnroll_EzUser.getCustomerNames();
%>

<!-- START CUSTOMER LIST for restricted user -->

<table cellspacing="0" cellpadding="1" border="0" width="100%" align="center">
<tr><td valign="top">

<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr><td valign="top" class="bodybold" align="left" width=50%>
*Please Select the Name for this subscriber:</td>

<td class="body" align="left" width=50%>

<SELECT name="customerChoice" size=2>
<!--BR><BR>-->
<% int count = customerNames.length;%>

<!-- tsx:repeat index="j" -->
<% for (int jj = 0; jj < count; jj++)
{ %>
<% tempName = customerNames[jj];%>
<% if (!(jj < count))
throw new ArrayIndexOutOfBoundsException();%>
<OPTION VALUE="<%=tempName%>"selected> <%= customerNames[jj] %></OPTION>
<% } %>
<!-- /tsx:repeat -->
</SELECT>

<BR><BR>
</div>

</TD></TR></TABLE>
</td></tr></table>

<div align="center">
<input type="submit" name="back" value="Back" class="button"/>&nbsp;&nbsp;
<input type="submit" name="continue" value="Continue" class="button"/>

<BR><BR>
</div>
</td>
<td width="15" class=body align=left>
<img alt="" border=0 height=1 width=15 src="/enroll/images/img_clear.gif"></td>

</tr></table></td></tr></table>
<!-- end of list for resricted user-->

<%}%>
<!-- Main Grid Ends -->

</form>
</body>
</html>
[/HTML]
Thanks again for any help you provide.
Aug 24 '07 #5
acoder
16,027 Expert Mod 8TB
Please use code tags when posting code.

You're going forward with history.go(1) and then trying to clear the form. Clear the form first then leave the page.
Aug 24 '07 #6
JShea
5
Tried that and it did not work.

[HTML]<input type="button" name="CancelButton" value="Cancel" onclick="clear_form();history.go(-1);clear_form();"/>[/HTML]
Aug 27 '07 #7
gits
5,390 Expert Mod 4TB
hi ...

you have to clear the form of the page you are going to ... clearForm of your cancel-button only clears the form in the actual page (where the button is implemented) ... so you have to redesign your steps. the simplest way would be to call the clearForm-function from onload of the 'search'-page ... so you would always have a clean form when loading it ... another ... and probably more intuitive way would be to avoid frames and using hidden/visible divs that contain all formelements depending on the users actions. but first try the onload-solution :)

kind regards
Aug 27 '07 #8
JShea
5
Thanks again. It worked. But there is one minor problem I can not solve. When a user hits the "Back" button and returns to the "Search" page and then hits the "Search" button again to bring him to the page where he hit the "Back" button, and then hits the "Cancel" button, he is returned back to the "Search" page but this time the data in the text boxes is not cleared and the radio buttons are not unchecked like they were when you hit the "Cancel" without first hitting the "Back" button.

I was wondering if there is a way to bring the user back to the "Search" part of the form without using the
Expand|Select|Wrap|Line Numbers
  1. history.go(-1)
Aug 29 '07 #9
gits
5,390 Expert Mod 4TB
hi ...

i think the best way would be to consider a redesign and put all form-elements into one single page and then switching the visibility of the sections accordding to your needs ... the history isn't your friend ... did you try the browsers back-button too? i think there are more problems with relying on the history object then creating a selfcontained reliable interface ...

kind regards
Aug 30 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Savvas | last post by:
Hi everybody, I have a lot of textboxes on my form and a "Clear" button. Is there a way with a for loop or something to clear the textboxes, instead of writing textboxName.clear? Thanks a lot
3
by: Alex Wisnoski | last post by:
I have an edit record form with several text boxes, combo boxes, and check boxes. All of them are bound except for one combo box (cboPositionData), which I use to search for a specific record. I...
3
by: Dan | last post by:
I have a C# form with an OleDBconnection, adaptor and dataset along with a several text boxes linked to the Dataset and 2 buttons. I am assigning the dataset to a DataGrid. My problem: I enter...
5
by: Drew Leon | last post by:
I have a Form with a Tab Control on it. Each of the Tabs have two List Boxes on them. When you Select an Item from the List Box, the Text Box at the bottom of the Form gets populated. I would like...
8
by: jamesburkett | last post by:
I'm trying to clear text from a MaskEditBox control. I thought the format to delete it was: 'clear the mask mskName.Mask = "" 'clear the text mskName.Text = "" 'reassign the mask...
7
by: ljungers | last post by:
Have Form-1 with 3 text boxes and 1 command button. With any of the 3 boxes filled out and button is clicked, a Macro is performed that Opens a Query that has a WHERE clause that uses the 3 test...
12
by: ljungers | last post by:
I'm on the home streach of my project and found that my "Reset for New Search" command button not working as desired. What should happen is that when the button is clicked a Event Procedure is run....
1
by: Denis | last post by:
I want to have a prompt a text box on a form so that clears once you click on it to enter information. eg Ownername field to display "Enter Surname then First Name" until you click on it. Thanks...
4
by: fosterb | last post by:
I am a c# developer struggling with an ASP.NET problem and I have no web development experience at all, so I suspect that my question will be an easy one to the right person. I am trying to fix a...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.