Is it possible to execute a PHP script or function using OnClick or OnChange for an <input>?
I need to show and/or select a date-time field from a MySQL table when the value of an <input> has changed or clicked. Thanks
Moderators: macek, egami, gesf



<html>
<head>
<title>Whatever</title>
<script type="text/javascript">
function PostForm() {
var http = null;
var name = document.getElementById('name').value;
var email = document.getElementById('email').value;
var subject = document.getElementById('subject').value;
var message = document.getElementById('message').value;
if(window.XMLHttpRequest)
http = new XMLHttpRequest();
else if (window.ActiveXObject)
http = new ActiveXObject('Microsoft.XMLHTTP');
http.onreadystatechange = function() {
if(http.readyState == 4)
alert(http.responseText);
};
http.open('POST', 'Your_email_process_script.php', true);
http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
http.send('name=' + name + '&email=' + email + '&subject=' + subject + '&message=' + message);
}
</script>
</head>
<body>
<form name="contact_form"method="post" action="">
Name:<br />
<input type="text" name="name" id="name" size="40" value="" /><br />
Email:<br />
<input type="text" name="email" id="email" size="40" value="" /><br />
Subject:<br />
<input type="text" name="subject" id="subject" size="40" value="" /><br />
Message:<br />
<textarea name="message" cols="70" rows="9" class="required"></textarea><br />
<input type="button" onclick="PostForm()" name="SendMessage" value="Send Message" />
</form>
</body>
</html>





<html>
<head>
<title>Whatever</title>
<script type="text/javascript">
var xmlhttp ;
function loadscheduler()
{
var inschedtime = document.getElementById('schedtime').value;
// code for Mozilla, etc.
if (window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest()
xmlhttp.onreadystatechange=state_Change
xmlhttp.open("GET","Scheduler.php",true)
xmlhttp.send('inschedtime='+inschedtime)
}
// code for IE
else if (window.ActiveXObject)
{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
xmlhttp.onreadystatechange=state_Change
xmlhttp.open("GET","Scheduler.php",true)
xmlhttp.send('inschedtime='+inschedtime)
}
}
function state_Change()
{
// if xmlhttp shows "loaded"
if (xmlhttp.readyState==4)
{
// if "NOT OK"
if (xmlhttp.status!=200)
alert("Problem retrieving XML data:" + xmlhttp.statusText)
}
}
</script>
</head>
<body>
<form name="contact_form" method="post" action="dosomething.php">
Schedule Date:<input type="button" value="2005-10-13" name="schedtime" ondblclick="loadscheduler()"><br>
</form>
</body>
</html>
<?php
$inschedtime=$_GET['inschedtime'];
$outschedtime=$inschedtime+2;
echo outschedtime;
?>

Users browsing this forum: No registered users and 1 guest