hi, I am a beginner with AJAX, i have an assignment where I have to pass a number to my php script and have it sent back converted into CELCIUS OR FARENHEIHT(spel led wrong). The problem is I dont know how to pass multiple arguments to my php script...
Here is my stuff below if you can look at it and someone could help me i would appreciate it...
HTML
[HTML]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Ajax C-F conversion</title>
<style>
.NoNum {color:red; font-weight:bold;}
</style>
<script>[/html]
[code=javascript]var http = createRequestOb ject();
function createRequestOb ject() {
var ro;
var browser = navigator.appNa me;
if(browser == "Microsoft Internet Explorer"){
ro = new ActiveXObject(" Microsoft.XMLHT TP");
}else{
ro = new XMLHttpRequest( );
}
return ro;
}
function convertTemp(arg Temp) {
http.open('get' , 'convert.php?te mp='+argTemp);
http.onreadysta techange = handleResponse;
http.send(null) ;
}
function handleResponse( ) {
if(http.readySt ate == 4){
document.getEle mentById("resul ts").innerHTM L = http.responseTe xt;
}
}[/code]
[html]</script>
</head>
<body>
<div>
<form name="myForm" action="#">
<h1>Enter Degrees Here:</h1>
<input type="text" name="temp">
<select name="type" id="type">
<option value="CF">Cent igrade to Farenheit</option>
<option value="FC">Fare nheit to Centigrade</option>
</select>
<input type="button" value="Submit" name="btnSubmit " onclick="conver tTemp(this.valu e);"/>
</form>
</div>
<h1>Degrees Fahrenheit</h1>
<div id="results">
</div>
</body>
</html>[/html]
PHP SCRIPT
[PHP]<?php
$type=$_GET["type"];
$temp=$_GET["temp"];
if ($type=="CF"){
$convert=($temp *9/5)+32;
print ($convert);
}
if ($type=="FC"){
$convert=($temp-32)*(5/9);
print ($convert);
}
?>[/PHP]
Here is my stuff below if you can look at it and someone could help me i would appreciate it...
HTML
[HTML]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Ajax C-F conversion</title>
<style>
.NoNum {color:red; font-weight:bold;}
</style>
<script>[/html]
[code=javascript]var http = createRequestOb ject();
function createRequestOb ject() {
var ro;
var browser = navigator.appNa me;
if(browser == "Microsoft Internet Explorer"){
ro = new ActiveXObject(" Microsoft.XMLHT TP");
}else{
ro = new XMLHttpRequest( );
}
return ro;
}
function convertTemp(arg Temp) {
http.open('get' , 'convert.php?te mp='+argTemp);
http.onreadysta techange = handleResponse;
http.send(null) ;
}
function handleResponse( ) {
if(http.readySt ate == 4){
document.getEle mentById("resul ts").innerHTM L = http.responseTe xt;
}
}[/code]
[html]</script>
</head>
<body>
<div>
<form name="myForm" action="#">
<h1>Enter Degrees Here:</h1>
<input type="text" name="temp">
<select name="type" id="type">
<option value="CF">Cent igrade to Farenheit</option>
<option value="FC">Fare nheit to Centigrade</option>
</select>
<input type="button" value="Submit" name="btnSubmit " onclick="conver tTemp(this.valu e);"/>
</form>
</div>
<h1>Degrees Fahrenheit</h1>
<div id="results">
</div>
</body>
</html>[/html]
PHP SCRIPT
[PHP]<?php
$type=$_GET["type"];
$temp=$_GET["temp"];
if ($type=="CF"){
$convert=($temp *9/5)+32;
print ($convert);
}
if ($type=="FC"){
$convert=($temp-32)*(5/9);
print ($convert);
}
?>[/PHP]
Comment