Jump to content

How to submit multiple forms onchange event


tyra

Recommended Posts

How to submit multiple forms with onchange event ?

the goal is  php to load them to various varibles.

here is javascript.js


var AJAXForms = false;
var LastField = null;
var isIE = false;
// on !IE we only have to initialize it once
if (window.XMLHttpRequest) {
AJAXForms = new XMLHttpRequest();
}

function CheckField(field) {

if (window.XMLHttpRequest) {
// branch for IE/Windows ActiveX version
} else if (window.ActiveXObject) {
	AJAXForms = new ActiveXObject("Microsoft.XMLHTTP");
}

  AJAXForms.onreadystatechange = processChange;
  AJAXForms.open("POST", "check.php?op="+field.value);
  LastField = field.name;
  AJAXForms.send(null);
}

function processChange() {
  if (AJAXForms.readyState == 4) { 
  
    var  res = document.getElementById(LastField);
    res.innerHTML = AJAXForms.responseText;
    res.style.visibility = "visible";
    
  }
}

 

 

html

<input type="text" name="t0" value="" size="20" OnChange="CheckField(this)" tabindex="1">
<input type="text" name="t1" value="" size="20" OnChange="CheckField(this)" tabindex="1">
<div id="t0" class="message"></div>
<div id="t1" class="message"></div>

 

 

php

var_dump ($_GET['op']) ;
var_dump ($_GET['t1']);
die();

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.