You are here: passing javascript variable to php ? « PHP Programming Language « IT news, forums, messages
passing javascript variable to php ?

Posted by Geoff Cox on 03/07/07 15:06

Hello,

The code below is aimed at passing the date in the yyyyMMdd format
from the javascript calendar in an html file to the php in a another
file which then searches a MySQL database.

For some reason the sendPhp is not working.

I need to send

target=frameright (as the results of the next.php search appear in the
right hand frame), and

submit=1

Any ideas please?!

Cheers

Geoff

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Sounds</title>
<link rel="STYLESHEET" type="text/css"
href="../assets/style/sounds.css">

<script type="text/javascript" src="fcp_calendar.js"></script>
<script type="text/javascript">

window.onload = function() {
cal = new _
fcp.Calendar(document.getElementById("cal_placeholder"));
cal.onselect = function(date) {;

function dateToISO(date) {
var year = date.getFullYear();
var month = date.getMonth() + 1;
var day = date.getDate();
if (month < 10) month = "0" + month;
if (day < 10) day = "0" + day;
return year + month + day;

};

newdate = dateToISO(date);

// the 2 functions below are used to pass the javascript variable
//to the php file, next.php

function xmlreq(){
if(window.XMLHttpRequest){
req = new XMLHttpRequest();
}else if(window.ActiveXObject){
req = new ActiveXObject("Microsoft.XMLHTTP");
}

return(req);

};

function sendPhp(url){
var req = xmlreq();

req.onreadystatechange = stateHandler;
req.open("GET", url, true);
sreq.send(null);
};


sendPhp("next-right.php?searchfield=date&term=newdate&target=frameright'&submit=1");

}

}



</script>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация