Code Bank
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingCode Bank

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old August 25th, 2004, 01:07 PM
mwoolgar's Avatar
mwoolgar mwoolgar is offline
e-Marketing By Design
ASP Free Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Location: London, UK
Posts: 141 mwoolgar User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 12 h 6 m 8 sec
Reputation Power: 5
complex form validation - radio buttons

Hi

I have an asp form which needs validating.
In section 4 of the form there is a question which asks:

* Do you own the machine(s) that will be used to run Trader Desk?

If the person says No to this question then another hidden question appears:

* If NO, have you been given the authority to put other software on the machine?

What I would like is that if they say no to this second question then they cannot proceed/enter the form.

I have enclosed the actual form but here is a summary of it.

MANY THANKS ;-)


<script language="JavaScript">
<!--
function hideAll()
{
changeDiv("Ownership_Authority_Quest","none");
changeDiv("dog_questions","none");
}
function getStyleObject(objectId) {
if (document.getElementById && document.getElementById(objectId)) {
return document.getElementById(objectId).style;
} else if (document.all && document.all(objectId)) {
return document.all(objectId).style;
} else {
return false;
}
}
//-->
</script>

<form action="<%=MM_editAction%>" method="POST" name="form1" onSubmit="YY_checkform('form1','EnqFormPref[0]','#q','2','Enquiry form preference: Please select either fax or email','PC_Proc[0]','#q','2','Please tell us if you have a 300 MHz Processor','PC_RAM[0]','#q','2','Please tell us if you have 64 MB RAM','PC_DiskSpace[0]','#q','2','Please tell us if you have 500 MB free disk space','PC_Resolution[0]','#q','2','Please tell us if you have 800 x600 bit Colour Monitor','PC_CD[0]','#q','2','Please tell us if you have a 16 speed CD ROM Drive','PC_Modem[0]','#q','2','Please tell us if you have a 56K modem','Internet_HaveCon[0]','#q','2','Please tell us if you have an Internet connection','Internet_UserPass[0]','#q','2','Please tell us if you know the username and password','Internet_Modem[0]','#q','2','Please tell us if you have an Internet_Modem','Internet_Network[0]','#q','2','Please let us know if your connection is via a network','Internet_AOL[0]','#q','2','Please tell us if you use AOL or CompuServe as your ISP.','NetInt_Proxy[0]','#q','2','Please tell us if your connection is via a Proxy Server','NetInt_Ports[0]','#q','2','Field \'NetInt_Ports[0]\' is not valid.','Ownership_Own[0]','#q','2','Please tell us if you own the machine','Ownership_Authority[0]','#q','2','Do you have authority to put software on the PC? Please select Yes or no.','Windows_Admin[0]','MM_insert','2','have you given the user\(s\) of Trader Desk admin rights for their local machine\(s\)? Please select Yes or No','DealershipName','#q','0','Please enter a delearship name','SalesContact','#q','0','Please give us your sales contact name','Address','#q','0','please enter your address','Town','#q','0','please enter your town','County','#q','0','please enter your County','PostCode','#q','0','please enter your PostCode\'','PhoneNumber','#q','0','Please enter your phone number','SignedBy','#q','0','Please sign this form by entering your name');return document.MM_returnValue">


<table width="40%" border="0" align="center" cellpadding="0" cellspacing="5">
<tr>
<td colspan="4"><strong>4. Machine Ownership</strong></td>
</tr>
<tr>
<td align="right">&nbsp;</td>
<td>Yes</td>
<td>No</td>
<td>&nbsp;</td>
</tr>
<tr>
<td><strong><font color="#FF0000">* </font></strong>Do you own the machine(s)
that will be used to run Trader Desk?</td>
<td><input type="radio" name="Ownership_Own" value="1"></td>
<td><input type="radio" name="Ownership_Own" value="0" onClick="hideAll(); changeDiv('Ownership_Authority_Quest','block');"></td>
<td align="center">&nbsp;</td>
</tr>
<tr>
<td colspan="3"><div id="Ownership_Authority_Quest" style="display:none" align="left"><strong><font color="#FF0000">*
</font></strong>If NO, have you been given the authority to put other
software on the machine?
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
Yes
<input type="radio" name="Ownership_Authority" value="1">
No
<input type="radio" name="Ownership_Authority" value="0" onClick="return confirm('If you do not have permission you will not be able to submit this form.')">
</div></td>
</tr>
<tr>
<td colspan="4"><hr></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1">
</form>

Reply With Quote
  #2  
Old September 7th, 2004, 02:07 PM
mwoolgar's Avatar
mwoolgar mwoolgar is offline
e-Marketing By Design
ASP Free Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Location: London, UK
Posts: 141 mwoolgar User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 12 h 6 m 8 sec
Reputation Power: 5
I eventually found my own solution:


Here are the radio boxes.

<table width="40%" border="0" align="center" cellpadding="0" cellspacing="5">
<tr>
<td colspan="4"><strong>5. Machine Ownership</strong></td>
</tr>
<tr>
<td align="right">&nbsp;</td>
<td>Yes</td>
<td>No</td>
<td>&nbsp;</td>
</tr>
<tr>
<td><strong><font color="#FF0000">* </font></strong>Do you own this machine,
or do you have permission to put software on it?</td>
<td><input type=radio value=1 name=Ownership_Authority onclick="enableElems(this.checked,gr1);enableElems(document .form1.agree[0].checked,gr2)">yes</td>
<td><input type=radio value=0 name=Ownership_Authority onclick="enableElems(!this.checked,gr1)">no</td>
<td align="center">&nbsp;</td>
</tr>


<tr>
<td><strong><font color="#FF0000">* </font></strong>Have you read the terms of this agreement</td>
<td><input type=radio value=1 name=agree onclick="enableElems(this.checked,gr2)">yes</td>
<td><input type=radio value=0 name=agree onclick="enableElems(!this.checked,gr2)">no<BR></td>
<td align="center">&nbsp;</td>
</tr>


<tr>
<td colspan="3">&nbsp;</td>
</tr>
<tr>
<td height="71" colspan="4">
<hr><br>
<%
Dim SignedDate
SignedDate = date()
'SignedDate = Now()
%>
<input type="hidden" name="SignedDate" value="<% =SignedDate %>">
<%
'dim todays
'todays = FormatDateTime(date(), 1)
%>


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

The idea was that you can not proceed to the next radio button until you say yes to the first, plus everything on the form gets greyed out. If you say no to the second then the submit button gets greyed out.
Here the clever stuff in the header:

<script language="JavaScript">
<!--
// BEGIN RADIO BUTTONS

//initial configuration (Ownership_Authority is always enabled)
var grInit = new Object();
grInit.stay=new Object();
grInit.stay["Ownership_Authority"]=true;
//first configuration (Ownership_Authority is always enabled, and agree is enabled depending the)
var gr1 = new Object();
gr1.stay=new Object();
gr1.stay["Ownership_Authority"]=true;
gr1["agree"]=true;
//gr1["all_elements"]=true;
//...
var gr2 = new Object();
gr2.stay=new Object();
gr2.stay["Ownership_Authority"]=true;
gr2.stay["agree"]=true;
gr2["agree"]=true;
gr2["all_elements"]=true;

function enableElems(isSelected, config){
//alert(isSelected);
for(var i=0;i<document.form1.elements.length;i++){
var elem = document.form1.elements[i];
if (elem.name==null || elem.name=="") continue;
// alert(elem.name);
elem.disabled = !((isSelected && (config[elem.name] || config["all_elements"]))|| config.stay[elem.name]);
}
}
<!-- END RADIO BUTTONS -->
//-->
</script>


ENJOY!!

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingCode Bank > complex form validation - radio buttons


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway