473,412 Members | 2,293 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,412 software developers and data experts.

How to maintain unhidden fields after a form submit event

tsubasa
64
I have an ASP checkout page where a customer can select from 2 choices of a credit card. One card only requires the card number, while the other selection will unhide a Div to reveal 2 dropdown list for month and year. The problem I have is that if there as an error the page will reload and the hidden fields will be hidden again. Does anyone know how to keep the fields from being hidden after a form submit?

Below is the Javascript that controls the hidden fields.

Expand|Select|Wrap|Line Numbers
  1.  
  2. function turnOff(id){
  3.   var checkboxgsa
  4.   if(form.checkboxgsa.checked==true)
  5.   var gsaAnswer=window.confirm('Credit GSA Credit Card?');
  6.  
  7.   if(gsaAnswer===true)
  8.   {
  9.   form.checkboxgsa.checked=true;
  10.   form.checkboxgcpc.checked=false;
  11.   }
  12.   var state = document.getElementById(id).style.display;
  13.   if (state == 'block') {
  14.   document.getElementById(id).style.display = 'none';
  15.    }
  16. }
  17.  
  18. function toggle(id) {
  19.   var checkboxgcpc
  20.   if(form.checkboxgcpc.checked==true)
  21.   var gcpcAnswer=window.confirm('Credit GCPC Credit Card?');
  22.  
  23.   if(gcpcAnswer===true)
  24.   {
  25.   form.checkboxgcpc.checked=true;
  26.   form.checkboxgsa.checked=false;
  27.   }
  28.   var state = document.getElementById(id).style.display;
  29.   if (state == 'none') {
  30.   document.getElementById(id).style.display = 'block';
  31.  
  32.        }
  33. }  
  34. <html>
  35. <form method="POST" action="<%=checkouturl%>" name="form" id="form">
  36.  
  37.  <tr>
  38.               <td width="10%">&nbsp;</td>
  39.               <td width="40%">
  40.                 <INPUT TYPE="radio" NAME="checkboxgsa" onclick="turnOff('hidden')"<%if checkboxgsa=1 then response.write(" checked")%>  VALUE="1" >GSA Card
  41.                 <INPUT TYPE="radio" NAME="checkboxgcpc" onClick="toggle('hidden')"<%if checkboxgcpc=1 then response.write(" checked")%> VALUE="1" >GCPC Credit Card
  42.               </td>
  43.               <td width="40%">&nbsp;</td>
  44.               <td width="10%">&nbsp;</td>
  45.             </tr>
  46.             <% if authcccode="ON" or cvven="ON" then %>
  47.             <% end if %>
  48.             <tr>
  49.               <td width="10%" height="21">&nbsp;</td>
  50.               <td width="40%" height="21">
  51.               <div id="hidden" style="display:none;">
  52.                 <table border="0" cellpadding="0" cellspacing="0">
  53.                   <tr>
  54.                     <td class="formheadings"><%=getsystext("sys51")%></td>
  55.                     <td width="10"></td>
  56.                     <td class="formheadings"><%=getsystext("sys52")%></td>
  57.                   </tr>
  58.                   <tr>
  59.                     <td><select class="formdrop" size="1" name="expmonth">
  60.                     <option>01</option>
  61.                     <option>02</option>
  62.                     <option>03</option>
  63.                     <option>04</option>
  64.                     <option>05</option>
  65.                     <option>06</option>
  66.                     <option>07</option>
  67.                     <option>08</option>
  68.                     <option>09</option>
  69.                     <option>10</option>
  70.                     <option>11</option>
  71.                     <option>12</option>
  72.                     <option selected value="<%=expmonth%>"><%=expmonth%>
  73.                     </option>
  74.                     </select> </td>
  75.                     <td width="10"></td>
  76.                     <td><select class="formdrop" size="1" name="expyear">
  77.                     <option>2005</option>
  78.                     <option>2006</option>
  79.                     <option>2007</option>
  80.                     <option>2008</option>
  81.                     <option>2009</option>
  82.                     <option>2010</option>
  83.                     <option>2011</option>
  84.                     <option>2012</option>
  85.                     <option>2013</option>
  86.                     <option>2014</option>
  87.                     <option>2015</option>
  88.                     <option>2016</option>
  89.                     <option>2017</option>
  90.                     <option>2018</option>
  91.                     <option>2019</option>                   
  92.                     <option selected value="<%=expyear%>"><%=expyear%></option>
  93.                     </select></td>
  94.                   </tr>
  95.                 </table>
  96.               </div>
  97.               </td>
  98.  
  99.  </form>
  100. </table>
  101. </html>
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
Oct 3 '11 #1
2 1823
johny10151981
1,059 1GB
follow the algorithm,
Expand|Select|Wrap|Line Numbers
  1. if(Selection Exists) than
  2.   show the selected item
  3. else
  4.   show default item.
  5.  
  6.  
Oct 3 '11 #2
tsubasa
64
Hello Johny,

Thank you for replying, but this is to maintain a selection on a dropdown list. In my form I have a hidden division, when I select the radio button for checkboxgcpc, the hidden division will display and the dropdown list for month and year will display. The problem that I am having is that when submitting the form, if a user forgets to enter a date or a credit card number, the form will display an error as programmed, but it will return the displaying division back to hidden. I want to keep the division unhidden, unless the user changes cards or properly submits the information which will allow him to complete the checkout process.
Oct 3 '11 #3

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

Similar topics

2
by: Billy | last post by:
Hi. I'm new to asp.net and I'm trying to create a confirm dialog box using the confirm() javascript function that will pup once the submit button is pressed. My problem is when I call...
2
by: The Crow | last post by:
i have to catch submit event of the form contained in the asp.net webform. when a button on the page clicked, it works ok, but when i call form.submit() or linkbutton vs. calls __doPostBack() ,...
4
by: John Boy | last post by:
Hi, Can anyone help. This is really doing my nut in. 3 years ASP exp. and now doing .DOT which is a step in the wrong direction. Basically I am left with the code of a guy who has left. When I...
2
by: alan_atwood | last post by:
Hello all. I am having a problem with the submit() method that is driving me nuts. I'm using document.form.submit() with large text fields (approx. 2000 characters) and am getting a "Invalid...
4
by: jwlum | last post by:
I have the following problem under Internet Explorer only: 1. User fills out form data (myform.php) and clicks a button that fires myFunction() 2. myFunction() spawns a "hello, world" popup page...
3
by: prodizy | last post by:
Hi, In Firefox, what's the best way of tracking the form submit? The following are two ways I tried, but they won't work if the form is submitted through JavaScript. Method 1: using the...
1
by: gbezas | last post by:
Hi All, I have added an event handler to redirect form.submit() to a newSubmit() method that I have defined (which does some additional processing before submitting the form). Additionally I...
4
by: szimek | last post by:
Hi, I've already posted an email with this problem, but this time I think I got a bit more info. The app I'm currently working on works like this: when user clicks on a clickable element, it...
14
by: white lightning | last post by:
How to have <select onchange="this.form.submit()"and also a Submit button on one form? I have something like this: <form action="<?php $_SERVER; ?>" method="post"...
13
Frinavale
by: Frinavale | last post by:
I've been trying all morning to cancel a form submit to the server. I have a JavaScript Object that determines whether or not the page should be submitted to the server depending on whether the...
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
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:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.