472,119 Members | 1,792 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,119 software developers and data experts.

passing javascript variable to php ?

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_placehol der"));
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=fra meright'&submit=1");

}

}

</script>
Mar 7 '07 #1
2 5779
Geoff Cox wrote:
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_placehol der"));
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=fra meright'&submit=1");
Hi,

A very quick look tells me you have a ' after the frameright.
You cannot pass ' like that in a URL, you should URL-encode it
encode() in JS if memory serves me well.

And this is actually a JS question, not PHP related at all. :-)
Try comp.lang.javascript for such questions, they have a few gurus that can
help you a lot better.

Regards,
Erwin Moller
>
}

}

</script>
Mar 7 '07 #2
On Wed, 07 Mar 2007 16:39:31 +0100, Erwin Moller
<si******************************************@spam yourself.comwrote:
>Geoff Cox wrote:
>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_placeho lder"));
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=fra meright'&submit=1");
Hi,

A very quick look tells me you have a ' after the frameright.
You cannot pass ' like that in a URL, you should URL-encode it
encode() in JS if memory serves me well.
Erwin,

sorry - a typo - the ' should not be there.

Cheers

Geoff
>
And this is actually a JS question, not PHP related at all. :-)
Try comp.lang.javascript for such questions, they have a few gurus that can
help you a lot better.

Regards,
Erwin Moller
>>
}

}

</script>
Mar 7 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by domeceo | last post: by
2 posts views Thread by RootShell | last post: by
1 post views Thread by cirillo_curiosone | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.