<table>
<tr><td>Name</td><td>:</td><td><input type="text" id="name"/></td></tr>
<tr><td>City</td><td>:</td><td><input type="text" id="city"/></td></tr>
<tr><td>Age</td><td>:</td><td><select id="age">
<?php
$output = '';
for($i=21; $i<61; $i++){
$output .= '<option value="'.$i.'">'.$i.'</option>';
}
echo $output;
?>
</select></td></tr>
<tr><td> </td><td> </td><td><input type="button" onclick="Send()" value="Send"/></td></tr>
</table>
<script>
var lucia = lucia || {};
lucia.getById = function(id){
return document.getElementById(id);
}
function Send(){
var name = lucia.getById('name');
var city = lucia.getById('city');
var age = lucia.getById('age');
var data = {
'name': name.value,
'city' : city.value,
'age' : age.value
};
var json_data = JSON.stringify(data);
var ajax = new XMLHttpRequest();
ajax.open('POST','hello.php', false);
ajax.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
ajax.send('data='+json_data);
var response = eval('('+ajax.responseText+')');
}
</script>
<tr><td>Name</td><td>:</td><td><input type="text" id="name"/></td></tr>
<tr><td>City</td><td>:</td><td><input type="text" id="city"/></td></tr>
<tr><td>Age</td><td>:</td><td><select id="age">
<?php
$output = '';
for($i=21; $i<61; $i++){
$output .= '<option value="'.$i.'">'.$i.'</option>';
}
echo $output;
?>
</select></td></tr>
<tr><td> </td><td> </td><td><input type="button" onclick="Send()" value="Send"/></td></tr>
</table>
<script>
var lucia = lucia || {};
lucia.getById = function(id){
return document.getElementById(id);
}
function Send(){
var name = lucia.getById('name');
var city = lucia.getById('city');
var age = lucia.getById('age');
var data = {
'name': name.value,
'city' : city.value,
'age' : age.value
};
var json_data = JSON.stringify(data);
var ajax = new XMLHttpRequest();
ajax.open('POST','hello.php', false);
ajax.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
ajax.send('data='+json_data);
var response = eval('('+ajax.responseText+')');
}
</script>
great post as usual!
ReplyDeletearoma essential oils
What the best programming tutorial other than w3schools.com? I need to know because I plan to launch the one.
ReplyDelete