469,319 Members | 2,415 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,319 developers. It's quick & easy.

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 1711
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

Post your reply

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

Similar topics

3 posts views Thread by prodizy | last post: by
Frinavale
13 posts views Thread by Frinavale | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by Gurmeet2796 | last post: by
reply views Thread by mdpf | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.