Hi,

For my website:
www.unlockSEonline.com in the search function i've been working on a javascript which check the form that is actually submitted (there are multiple forms on that page) and then checks some data then modifies some data from that form and submits it.
For visualisation just type in 'w' in the searchbox at the site.

The code:
Code:
function finaliseform2(formid) {
    var chosen = true;
     
    var cust = "cust" + formid;
    var custom = document.getElementById(cust).value; 			//ip address at first 
    var ip = custom;											//double click fix
	
    var phone = "phonemodel" + formid;
    var pmodel = document.getElementById(phone).value; 		//phone model
	var counter = 0;
    
    var lock1 = "locktype1" + formid;
    var lock2 = "locktype2" + formid;
    var lock3 = "locktype3" + formid;
    var lock4 = "locktype4" + formid;
    var lock5 = "locktype5" + formid; 
    
    //phonemodel
    if(pmodel == ""){
	   chosen = false;
    } else{
    	custom = custom + "-" + pmodel;   						//add phonemodel info
    }
    
	//add the lock values
	if(document.getElementById(lock1).checked){
		custom = custom + "-lock1";
	    counter++;
	}
	
	if(document.getElementById(lock2).checked){
		custom = custom + "-lock2";
	    counter++;
	}
	        
	if(document.getElementById(lock3).checked){
		custom = custom + "-lock3";
	    counter++;
	}           
	
	if(document.getElementById(lock4).checked){
		custom = custom + "-lock4";
	    counter++;
	}    
	    
	if(document.getElementById(lock5).checked){
		custom = custom + "-lock5";
	    counter++;
	}                    
	
    //for(var i=0; i < document.getElementById("custom").length; i++){
    //	document.getElementById("custom").value = custom;
	//} 
    //var test  = document.getElementById("custom").length;
    //alert("test: " + test);
    alert("test: " + cust); 
    document.forms[cust].custom.value = custom;
    alert("test: " + custom); 
    //document.getElementById("custom").value = custom;
    
    if(counter < 1 || counter == 5){                            
		chosen = false;
	}
	   
	if(chosen == false) {
    	document.getElementById("custom").value = ip;        
	    alert("You have not selected your lock type or selected all 5 which our solution can not solve.  Please select your lock type.");
	} 
       
	return chosen;
}
Now up to the checking of the checkbox all goes ok. But when I want to write back the 'custom' variable values to the 'custom' element of the form I run into trouble. The problem is that in every form the element is called 'custom' and I can't give it any other (unique) name. As you can see from the commented stuff I tried many different ways but it just does not work.

I can only write it back to the first form, using:
document.getElementById("custom").value = custom;
(in this case the first form works perfect, all other don't, they submit but not with correct data).

I though document.forms[cust].custom.value = custom; should have fixed the problem but it just does not work... (I'm testing in FF using Tamper data) and using this method the 'custom' field just does not have any value.

Who can help me with this? Been trying for more then 3 days now.
thank you very much.

Best regards,
Steven