0
<html>
<head>
<style type="text/css">

#apDiv1 {
    position:absolute;
    width:595px;
    height:298px;
    z-index:1;
    left: 412px;
    top: 38px;
}
-->
</style>
</head>
<title>safarina JavaScript</title>
<body align="center">

<div id="apDiv1">


<script type="text/javascript">

function MM_validateForm() { 
  if (document.getElementById){
    var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
    for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]);
      if (val) { nm=val.name; if ((val=val.value)!="") {
        if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
          if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
        } else if (test!='R') { num = parseFloat(val);
          if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
          if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
            min=test.substring(8,p); max=test.substring(p+1);
            if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
      } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
    } if (errors) alert('The following error(s) occurred:\n'+errors);
    document.MM_returnValue = (errors == '');
} }
</script>



<style type="text/css">

#apDiv1 {
    position:absolute;
    width:444px;
    height:185px;
    z-index:1;
    left: 348px;
    top: 37px;
    visibility: visible;
}

</style>


 <fieldset style="border-color:#999999">
   <form name="checkbox" method="get" action="" onSubmit="return comparision()" enctype = text/plain>
     <table width="452" border="0" cellpadding="0" cellspacing="0">
       <tr>
         <td width="117" scope="col"><div align="left">Name:</div></td>
         <th width="335" scope="col"><label> </label>
             <div align="left">
               <input name="name" type="text" id="name" onBlur="MM_validateForm('name','','R');return document.MM_returnValue" />
           </div></th>
       </tr>
       <tr>
         <td scope="row"><div align="left">Email Address:</div></td>
         <td><label>
           <input name="email" type="text" id="email" onBlur="MM_validateForm('email','','RisEmail');return document.MM_returnValue" />
           </label>
             <label>
             <input name="Validate" type="submit" id="Validate" onClick="MM_validateForm('name','','R','email','','RisEmail');return document.MM_returnValue" value="Validate" />
           </label></td>
       </tr>
     </table>
     <br />
     How can we help you?<br />
     <table width="452">
       <tr>
         <td width="43" height="28"><label>
           <input name="checkbox0" type="checkbox" />
         </label></td>
         <td width="397" scope="col">I'm interested in your programmes offered.</td>
       </tr>
       <tr>
         <td width="43" height="28"><label>
           <input name="checkbox1" type="checkbox" />
         </label></td>
         <td width="397" scope="col">I'm interested in short courses.</td>
       </tr>
       <tr>
         <td width="43" height="28"><label>
           <input name="checkbox2" type="checkbox"/>
         </label></td>
         <td width="397" scope="col">I'm interested in visiting your campus.</td>
       </tr>
     </table>
     <p>
     <input name="Reset" type="reset" tabindex="8">

     <input name="Submit" type="submit" id="Submit" value="Process"/>
     </p>
   </form>

 </fieldset>
</div>
</body>
</html>

hi,
i need help from you ^^ i don't now how to add java script into this programmed. the result should be come out with "you are interested in: (either one or all check box they click)". i hope you guys can help me on this.
Thank you ^^

Edited by mike_2000_17: Fixed formatting

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by Pnorq
0

Is this what you had in mind?

<html>
<head>
<style type="text/css">

#apDiv1 {
position:absolute;
width:595px;
height:298px;
z-index:1;
left: 412px;
top: 38px;
}
-->
</style>
<title>safarina JavaScript</title>
</head>
<body align="center">

<div id="apDiv1">


<script type="text/javascript">

function MM_validateForm() { 
if (document.getElementById){
var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]);
if (val) { nm=val.name; if ((val=val.value)!="") {
if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
} else if (test!='R') { num = parseFloat(val);
if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
min=test.substring(8,p); max=test.substring(p+1);
if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
} } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
} if (errors) alert('The following error(s) occurred:\n'+errors);
document.MM_returnValue = (errors == '');
} }

function comparision() {
  var x = document.getElementsByTagName("input");
  var message = "";
  for (var i=0;i< x.length;i++)
    {
       if(x[i].type == "checkbox") {
          if (x[i].checked){ 
            message += x[i].value + "\n";
          }
       }  
    }
  alert(message);
}
</script>



<style type="text/css">

#apDiv1 {
position:absolute;
width:444px;
height:185px;
z-index:1;
left: 348px;
top: 37px;
visibility: visible;
}

</style>


<fieldset style="border-color:#999999">
<form name="checkboxform" id="frm1" method="get" action="" onSubmit="return comparision();" enctype = text/plain>
<table width="452" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="117" scope="col"><div align="left">Name:</div></td>
<th width="335" scope="col"><label> </label>
<div align="left">
<input name="name" type="text" id="name" onBlur="MM_validateForm('name','','R');return document.MM_returnValue" />
</div></th>
</tr>
<tr>
<td scope="row"><div align="left">Email Address:</div></td>
<td><label>
<input name="email" type="text" id="email" onBlur="MM_validateForm('email','','RisEmail');return document.MM_returnValue" />
</label>
<label>
<input name="Validate" type="submit" id="Validate" onClick="MM_validateForm('name','','R','email','','RisEmail');return document.MM_returnValue" value="Validate" />
</label></td>
</tr>
</table>
<br />
How can we help you?<br />
<table width="452">
<tr>
<td width="43" height="28"><label>
<input name="checkbox[]" type="checkbox" value="You're interested in our programmes offered." />
</label></td>
<td width="397" scope="col">I'm interested in your programmes offered.</td>
</tr>
<tr>
<td width="43" height="28"><label>
<input name="checkbox[]" type="checkbox" value="You're interested in our short courses." />
</label></td>
<td width="397" scope="col">I'm interested in short courses.</td>
</tr>
<tr>
<td width="43" height="28"><label>
<input name="checkbox[]" type="checkbox" value="You're interested in visiting our campus."/>
</label></td>
<td width="397" scope="col">I'm interested in visiting your campus.</td>
</tr>
</table>
<p>
<input name="Reset" type="reset" tabindex="8">

<input name="Submit" type="submit" id="Submit" value="Process"/>
</p>
</form>

</fieldset>
</div>
</body>
</html>

Edited by Pnorq: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.