Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,149,729 members, 7,806,002 topics. Date: Tuesday, 23 April 2024 at 09:56 AM

Help: Onkeyup And Onclick In AJAX - Webmasters - Nairaland

Nairaland Forum / Science/Technology / Webmasters / Help: Onkeyup And Onclick In AJAX (1217 Views)

How Can I Create Onclick Navigation / Form Validation Tutorial Using Javascript, Php And Ajax! / Dynamic Web Design Tutorials Ft Javascript,Ajax,DOM,PHP,MySQL... (2) (3) (4)

(1) (Reply) (Go Down)

Help: Onkeyup And Onclick In AJAX by Nobody: 10:41am On Dec 11, 2013
Greetings to you all,

i have been working on ajax+php+mysql to make a data from table "NETWORK" be displayed using onkeyup(), which is working well.
diagram A
However, i also want the displayed data from the table "NETWORK" on the same form be submitted to another table "OUTWORK" in mysql using the onclick(). my problem is that it wont insert anything in the database nor display the result in the <div>result</div> as a confirmation or not.

Please kindly look at my codes in the picture and make valuable suggestion. thanks. Also please it should be strictly javascript+Ajax and not jquery because am yet to delve in but will later.

USAGE:
Dreamweaver CS5
Javascript + Ajax
Php
Mysql

codes

<script type='text/javascript' src='Finite.js'> </script>

<script language="JavaScript" type='text/javascript'>

var http = createXmlHttpRequestObject();

function createXmlHttpRequestObject() {
var http;

if (window.ActiveXobject){
try{
http = new ActiveXObject("Microsoft.XMLHTTP"wink;
}catch(e) {
http = false;
}
}else{

try{
http = new XMLHttpRequest();
}catch(e){
http = false;
}
}
if(!http)
alert("cant create that object hoss!"wink;
else
return http;
}

function ajax_post(){

//var http = new XMLHttpRequest();
var url = "procform7.php";
var Rn = document.getElementById("agid"wink.value
var Ln = document.getElementById("agtel"wink.value
var Mn = document.getElementById("agfn"wink.value
var Fn = document.getElementById("agsal"wink.value
//alert('good');
var vars = "registrationno="+Rn+"&lastname="+Ln+"&middlename="+Mn+"&firstname="+Rn;
//alert('good');

//alert('MOVE');
http.open("POST", url, true);
http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");

http.onreadystatechange = function() {
if(http.readyState == 4 && http.status == 200) {
var return_data = http.responseText;

document.getElementById("status"wink.innerHTML = return_data;

}

}
http.send(vars);
document.getElementById("status"wink.innerHTML = "processing...";
}

</script>

<link rel="stylesheet" type="text/css" href="Doubld.css" />
<div class='stutDiv'>

<form name="schform">
<table>
<tr>
<td>Contact ID:</td>
<td><input id="agid" type="text"
name="contactid" onKeyUp="getagentids();"></td>
</tr>
<tr>
<td>Tel Number:</td>
<td><input id="agtel" type="text"
name="contacttel"></td>
</tr>
<tr>
<td>Name:</td>
<td><input id="agfn" type="text"
name="contactfullname"></td>
</tr>
<tr>
<td>Salutation:</td>
<td><input id="agsal" type="text"
name="contactsalutation"></td>
</tr>
<tr>
<td><input type="reset" value="Clear"></td>
<td> <div align="center">

<input type="submit" name="submit" id="submit" value="Submit Data" onclick="javascript:ajax_post()"; />
</div></td>
</tr>
</table>
</form>

<br /> <br />

<div id="status"></div> //display report from the database
</div>

Re: Help: Onkeyup And Onclick In AJAX by Nobody: 10:50am On Dec 11, 2013
image

Re: Help: Onkeyup And Onclick In AJAX by DualCore1: 11:51am On Dec 11, 2013
Place your codes on pastebin.com and give us the URLs
The codes you have placed here are presently not very useful or runnable because of that smiley bug.
Re: Help: Onkeyup And Onclick In AJAX by Nobody: 6:03pm On Dec 11, 2013
Dual Core: Place your codes on pastebin.com and give us the URLs
The codes you have placed here are presently not very useful or runnable because of that smiley bug.
thanks dualcore, after using firebug, i discovered that i misspelt my variables. Its running perfectly thanks also for that site you posted, will check it out for future reference. Once again thank you for your willingness to assist.

(1) (Reply)

Live Lesson - Free Web Promotion & Digital Marketing Lesson For SMEs / How To Create An Auto-Pilot Video Download Site On , No Hosting Needed / Best Free Site To Boost Your Blog Traffic

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 18
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.