Online form - multiple checkbox help

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Mary arilene
    New Member
    • Jan 2011
    • 1

    Online form - multiple checkbox help

    Hi,

    I currenlt building a form and would like some help validating multiple checkboxes and receiving values.

    I'm using two two pages there asp pages.

    HTML code(with the body tag)
    Code:
            <tr bgcolor="#FFFFFF">
                          <td valign="top"><strong> How did you find out about us? </strong></td>
                          <td align="left">
                          
                              <input name="find" type="checkbox" value="googlesearch"> 
                             Google Search<br />   
                              <input name="find" type="checkbox" value="friends"> 
                             Friends or family memberse<br />
                                                                                                                  
    </td>     </tr>
    *************************
    this is called in the head section using javascript
    
    function validate(frm) { //v1.0
    
    	if (frm.pc.value.length == 0){alert("Please answer Question-3.");return false};
    	if (frm.Features.value.length == 0){alert("Please answer Question-12.");return false};
    	if (frm.Easybanking.value.length == 0){alert("Please answer Question-13.");return false};
    	if (frm.comments.value.length == 0){alert("Please answer Question-14.");return false};
    	 var val1 = 0;
    	for( i = 0; i < frm.gender.length; i++ )
    	{
    		if( frm.gender[i].checked == true)
    			{val1 = frm.gender[i].value;break;}
    	}
    	var val2 = 0;
    	for( i = 0; i < frm.age.length; i++ )
    	{
    		if( frm.age[i].checked == true)
    			{val2 = frm.age[i].value;break;}
    	}
    		var val3 = 0;
    	for( i = 0; i < frm.visit.length; i++ )
    	{
    		if( frm.visit[i].checked == true)
    			{val3 = frm.visit[i].value;break;}
    	}
    		var val4 = 0;
    	for( i = 0; i < frm.medium.length; i++ )
    	{
    		if( frm.medium[i].checked == true)
    			{val4 = frm.medium[i].value;break;}
    	}
    		var val5 = 0;
    	for( i = 0; i < frm.purchases.length; i++ )
    	{
    		if( frm.purchases[i].checked == true)
    			{val5 = frm.purchases[i].value;break;}
    	}
    		var val6 = 0;
    	for( i = 0; i < frm.navigation.length; i++ )
    	{
    		if( frm.navigation[i].checked == true)
    			{val6 = frm.navigation[i].value;break;}
    	}
    	var val7 = 0;
    	for( i = 0; i < frm.Internetbanking.length; i++ )
    	{
    		if( frm.Internetbanking[i].checked == true)
    			{val7 = frm.Internetbanking[i].value;break;}
    	}
    	
    	var chks = document.getElementsByName('find');
    	var checkCount = 0;
    	for (var i = 0; i < chks.length; i++)
    	{
    	if (chks[i].checked)
    	{
    	checkCount++;
    	}
    	}
    	if (checkCount < 1)
    	{
    	alert("Please select at least one.");
    	return false;
    	}
    			
       	var val = 0;for( i = 0; i < frm.member.length; i++ ){if( frm.member[i].checked == true){val = frm.member[i].value;break;}}
        if ((val == "yes")&&(frm.memberno.value.length ==0)) {alert("SGE member number is mandatory.");return false};
        
    
    //and this is code is obtained and gotoURL (other parts of code is not pasted as they all work please help for the multiple checkbox part)
    
    MM_goToURL('parent','survey_ack.asp?p='+frm.pc.value+'&f='+frm.Features.value+'&es='+frm.Easybanking.value+'&c='+frm.comments.value+'&g='+val1+'&a='+val2+'&v='+val3+'&d='+val4+'&ps='+val5+'&n='+val6+'&e='+val7+'&fd1='+chks+'&m='+val+'&sm='+frm.memberno.value);
    }
    *************** ******
    when the values ae collected it is being passes as a query string...
    bdy = bdy + "How did you find about us : " + request.queryst ring("fd1") +vbNewLine

    when i received my email
    im geting an error as [object HTMLCollection] against the multiple checkbox.

    output
    ****
    Age : 0-18
    Gender : male
    Postcode : fgtf
    Internet Banking : Yes
    How did you find about us: [object HTMLCollection]
    How often do you visit : never
    Which medium do you prefer : online
    Navigation : ve
    Online : ve
    Features : rgdstg
    EasyBanking : rgdstg
    Comments : none
    Member : no
    *************** *************** ************

    Please help.....i was unable to paste the whole file so i have only pasted the parts where i need someones assistance. Thanks in advance.
    Last edited by debasisdas; Jan 14 '11, 07:29 AM. Reason: Formatted using code tags.
Working...