Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript_howto thread: Re: Using Javascript arrays for datacapture


Message #1 by "J House" <house@p...> on Sat, 1 Sep 2001 19:21:46
ok,
Let's say you have 10 rows and the fields are
CargoNo_0, StartDt_0, Day1_0, Day2_0, Vol_0
CargoNo_1, StartDt_1, Day1_1, Day2_1, Vol_1
CargoNo_2, StartDt_2, Day1_2, Day2_2, Vol_2
CargoNo_3, StartDt_3, Day1_3, Day2_3, Vol_3
etc ...


Then for validation:

<script language="JavaScript">
function Checking()
{
	var oForm;
	var blnBlank;
	var sTemp = new String;
	
	// form object
	oForm = Builder; // Builder is the name of the form
	
	
	blnBlank = false;
        // loop through the form elements
	for (i=0; i < oForm.length; i++)
	{
		sTemp = oForm.elements[i].name;

		// validate CargoNo
		if ((sTemp.substr(0, 7) != 'CargoNo'))
		{
			// check for blank
			// or valide type of data for CargoNo
                        oForm.elements[i].value
		}
		// validate  StartDt
		if ((sTemp.substr(0, 7) != 'StartDt'))
		{
			// check for blank
			// or valide type of data for  StartDt
                        oForm.elements[i].value
		}
		// validate Day1
		if ((sTemp.substr(0, 4) != 'Day1'))
		{
			// check for blank
			// or valide type of data for Day1
                        oForm.elements[i].value
		}
		// validate Day2
		if ((sTemp.substr(0, 4) != 'Day2'))
		{
			// check for blank
			// or valide type of data for Day2
                        oForm.elements[i].value
		}
		// validate Vol
		if ((sTemp.substr(0, 3) != 'Vol'))
		{
			// check for blank
			// or valide type of data for Vol
                        oForm.elements[i].value
		}
	}

	// if ok submit the form
	// using - document.form[0].submit();
        // or  call your UpdateRecords1 UpdateRecords2
	// else throw error
}

I am using the onClick method on the submit button, not an onChange
And not a true submit button, but a button 
i.e. <input type="button" value="update" onClick="Checking();">
Hope this helps

> Fields on the form are  (for each record)
> CargoNo / StartDt / Day1 / Day2 / Vol
> if Request("btnAddOperator")="Upd" then....
> call 
> UpdateRecords1
> UpdateRecords2

  Return to Index