Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problem with ajax form update

Status
Not open for further replies.

akaballa123

Technical User
Apr 29, 2008
46
US
Hi There, Im a noob with ajax but really like the conept behind it. Iwanted to implement it into my form submit process. Basically, I want to create a security id each time the form is opened. When the user clicks submit, the for runs a javascript validation to check the form fields. If evrtything is fine, the ajax kicks in and sends the security id to mysql db through calling another php file. And then the for values are submit. However, my problem is that after implementing the code and logic, the form keeps showing an:

Code:
Object does not support method or property method on line 192

error. Eventhough this line has nothing to do with the ajax code in the file, I know it has someting to do with my ajax implementation.

please help!

ajax implementation and checkform:

Code:
function secIns()
{
 
 <!-- 
//Browser Support Code

	var ajaxRequest;  // The variable that makes Ajax possible!
	var err = 0;
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser is not compatible!");
				return false;
				err = 1;
			
			}
		}
	}
	if(err == 0)
	{
	// Create a function that will receive data sent from the server
	    ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			document.sessionForm.submitted.value = ajaxRequest.responseText;
		}
	    }
     //	ajaxRequest.open("GET", "serverTime.php", true);
     //	ajaxRequest.send(null); 


        //-->
  

	    var secID = document.getElementById('secID').value;
     	var queryString = "?secID=" + secID;
	    ajaxRequest.open("GET", "securityIDupdate.php" + queryString, true);
	    ajaxRequest.send(null);
	
	    return true;
	}
}
/*-----------------------------------------------------------------------------------------------*/
function checkForm()
{

   var num=/(^\d+$)|(^\d+\.\d+$)/ ;
   var myForm = window.document.sessionForm;
   var cempName = myForm.empName;
   var cID = myForm.empID;
   var cTraining = myForm.training;
   var cTrainingDuration = myForm.trainingDuration;
   var cStartD = myForm.startDate;
   var cEndD = myForm.endDate;
   var cSubmit = myForm.submitted;
   
   if (cempName.value == '')
     {
       alert('Please enter your full name');
       cempName.focus();
       return false;
     }
   if (checkName(cempName.value) == false)
   {
       alert('Invalid characters used.  Please re-enter your full name.');
       cempName.focus();
       return false;
   }

   if(cID.value == '' )
    {
      alert('Please enter your Employee ID Number');
      cID.focus();
      return false;
    }
    if( checkString(cID.value) == false )
    {
        alert('Please enter a valid Employee ID Number');
        cID.focus();
        return false;
    }

    if(document.getElementById("training").value == "select")
    {
           alert('Please select a course');
           cTraining.focus();
           return false;
    }
    if(cStartD.value == '')
    {
        alert('Please enter a start date')
        cStartD.focus();
        return false;
    }

    if(cEndD.value == '')
    {
        alert('Please enter an end date')
        cEndD.focus();
        return false;
    }
    if(Date.parse(cStartD.value) > Date.parse(cEndD.value))
    {
       alert('ERROR: Start Date is greater than the end date. Please re-check your dates!');
       return false;
       cStartD.focus();
    }
    if(cTrainingDuration.value == '')
    {
       alert('Please enter the Training Duration')
       cTrainingDuration.focus();
       return false;
    }
    if( checkString(cTrainingDuration.value) == false )
    {
        alert('Please enter a valid Training Duration');
        cTrainingDuration.focus();
        return false;
    }
    if (checkSubmit(cSubmit.value) == false)
    {
        alert('Form is already processed');
        return false;
    }
    elseif(secIns() == true)
    {

      cempName.value    = cempName.value;
      cID.value   = cID.value;
      cStartD.value   = cStartD.value;
      cEndD.value   = cEndD.value;
      cTrainingDuration.value = cTrainingDuration.value;
      return true;
    }
}

this is my submit form button:

Code:
<input class="button" type="submit" value="Submit" onclick="return checkForm(); " />

any help would be wonderful!!
 
I had similar problems for ages
then I changed my sumbmits buttons ID to somfhing other than 'submit'

it seems to clash with the javascript somewhere
 
ye i got it to work now..i now call the ajax function through the onsubmit event in the form tag. seems to work fine now
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top