Forum Moderators: open
<?php
if (array_key_exists('ajax', $_POST)) {
echo date('l jS \of F Y h:i:s A');
exit;
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" >
<title>Untitled</title>
</head>
<body>
<form action="index.php" method="post">
Name: <input type="text" name="username" id="username">
Time: <input type="text" name="time" id="time">
</form>
<!-- Scripts -->
<script type="text/javascript" src="http://yui.yahooapis.com/2.5.2/build/yahoo-dom-event/yahoo-dom-event.js"></script>
<script type="text/javascript" src="http://yui.yahooapis.com/2.5.2/build/connection/connection-min.js"></script>
<script type="text/javascript">
YAHOO.util.Event.onDOMReady(function () {
var elTime = document.getElementById('time');
var callback = {
success: function(o) {
elTime.value = o.responseText;
},
failure: function(o) {
alert('Error with AJAX request');
}
}
YAHOO.util.Event.on('username', 'keyup', function() {
var transaction = YAHOO.util.Connect.asyncRequest('POST', 'index.php', callback, "ajax=true");
});
});
</script>
</body>
</html>
Im trying to get what i type in the left block to appear in the right block ?
so if i type malcolm then malcolm appers on the right block.
The reason i am doing thios is to confirm what is being posted is being actually posted.
<?php
if (array_key_exists('ajax', $_POST)) {
echo $_POST;
exit;
}
?>
So what im getting at the moment is the word array and was wondering what the method is to get around this ?
echo $_POST['username'];
And modify the Connection Manager script to include the form data (give the form an id as well):
<?php
if (array_key_exists('ajax', $_POST)) {
echo $_POST['username'];
exit;
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" >
<title>Untitled</title>
</head>
<body>
<form action="index.php" method="post" id="myform">
Name: <input type="text" name="username" id="username">
Time: <input type="text" name="time" id="time">
</form>
<!-- Scripts -->
<script type="text/javascript" src="http://yui.yahooapis.com/2.5.2/build/yahoo-dom-event/yahoo-dom-event.js"></script>
<script type="text/javascript" src="http://yui.yahooapis.com/2.5.2/build/connection/connection-min.js"></script>
<script type="text/javascript">
YAHOO.util.Event.onDOMReady(function () {
var elTime = document.getElementById('time');
var callback = {
success: function(o) {
elTime.value = o.responseText;
},
failure: function(o) {
alert('Error with AJAX request');
}
}
var formObject = document.getElementById('myform');
YAHOO.util.Connect.setForm(formObject);
YAHOO.util.Event.on('username', 'keyup', function() {
var transaction = YAHOO.util.Connect.asyncRequest('POST', 'index.php', callback, "ajax=true");
});
});
</script>
</body>
</html>