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();

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.