Hi fellas, helping someone with a learning disability, and having trouble with this code (I was the only person available that had touched Javascript, so despite not knowing it that well, I can teach it if I have working code).
Heres what we have so far;
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Dans' magnificent forms page</TITLE>
<SCRIPT LANGUAGE="JAVASCRIPT" TYPE="TEXT/JAVASCRIPT">
//opens an alert window as soon as the page loads, or the form is cleared
window.open ("http://www.swin.edu.au" ,"SwinWin" , "width=400,height=400,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no")
//begin validation script
function validate(){
theForm=document.dansForm;
ok=true;
//Check for data entered in first name input box. If not, prompt the user.
if(theForm.fname.value==""){
ok=false;
alert("Please enter your first name");
theForm.fname.focus();
return false;
}
//Check for data entered in last name input box. If not, prompt the user.
if(theForm.lname.value==""){
ok=false;
alert("Please enter your last name");
theForm.lname.focus();
return false;
}
//Check for data entered in email input box. If not, prompt the user.
if(theForm.email.value==""){
ok=false;
alert("Please enter your email address");
theForm.email.focus();
return false;
}
//Check for data entered in address input box. If not, prompt the user.
if(theForm.address.value==""){
ok=false;
alert("Please enter your mailing address");
theForm.address.focus();
return false;
}
//If all fields are entered as required, run a script acknowledging this to the end user.
if(ok){
alert("Thankyou");
return true
}
}
</SCRIPT>
<style type="text/css">
div
{
background-color: white;
border: 1px solid black;
height:600px;
width:390px;
padding:2em;
font-size: 10px;
font-family: Helvetica,Arial,sans-serif ;
}
h2
{
font-size: 12px;
color:red;
}
body
{
background-image: url(gradient.jpg);
background-repeat: repeat-y
}
marquee
{
font-size: 9px;
}
</style>
</HEAD>
<BODY bgcolor=#666666>
<DIV>
<img src="banner.gif">
<FORM name=dansForm onsubmit="return validate()">
<H2>Contact Details</H2>
Title: <INPUT TYPE="RADIO" VALUE="Mr" NAME="Mr">Mr
<INPUT TYPE="RADIO" VALUE="Mrs" NAME="Mrs">Mrs
<br><br>
First Name:  <INPUT name=fname> <BR>
Last Name:  <INPUT name=lname> <BR>
Email:         <INPUT name=email> <br><br>
Address: <BR>
<TEXTAREA name=address></TEXTAREA> <br><br>
Region<br>
<select>
<option>Please select a Region</option>
<option>Australasia</option>
<option>Europe</option>
<option>South America</option>
<option>USA</option>
<option>Antarctica</option>
</select>
<H2>Courses</H2>
<INPUT type=checkbox value=Psychology name="">Psychology
<INPUT type=checkbox value=Business Management name="">Business Mgmt
<INPUT type=checkbox value=E-Commerce name="">E-Commerce
<INPUT type=checkbox value=Multimedia Design name="">Multimedia Des.<br><br>
<INPUT type=checkbox value=International BUsiness name="">International Business
<INPUT type=checkbox value=Biology name="">Biology
<INPUT type=checkbox value=Sport Management name="">Sports Mgmnt
<INPUT type=checkbox value=Economics name="">Economics<br><br>
<H2>How did you hear about us</H2>
<INPUT type=checkbox value=Newspaper name=""> Newspaper<BR>
<INPUT type=checkbox value=Television name=""> Television<BR>
<INPUT type=checkbox CHECKED value=Magazine name=""> Magazine<BR>
<INPUT type=checkbox value=Mail name=""> Mail<BR><br>
<INPUT type=submit value=Process>
<INPUT type=reset value=Clear>
<BR><br>
</FORM>
<marquee WIDTH="110%">The University also offers a wide range of postgraduate courses ranging from graduate certificates through to PhDs.</marquee>
</DIV>
</BODY>
</HTML>
We need the results to display in their own page, though from what I gather this cant be done using strictly client-side coding. Any other viable alternatives, if not? How would we code a simple text reaults field on the same page?
You will notice the checkboxes with course names. I also somehow need to give them all a value of $100, and make it that if 4-6 are checked, the resulting total multiplied price reflects a 10% discount; if more than 6, then %25% off the total (which is displayed). Anyone have an idea how to orchestrate this?
So yeah, I really have no idea how to validate the select field (so that if a region isnt selected, the user is alerted).
This would be a massive help, if someone can take a look for me.
cheers!