473,395 Members | 2,783 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 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 5866
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Jonas Daunoravicius | last post by:
The subject pretty much sums up what I need to do. Here is what I have so far, but still can't figure out how to get it working: <script language="javascript" type="text/javascript"> function...
1
by: Patrice | last post by:
Hi, I'm trying to use a javascript function passing a vb variable. I don't understand why it doesn't work. Can someone help me? Thanks in advance. Here is my javascript function used to...
3
by: domeceo | last post by:
can anyone tell me why I cannot pass values in a setTimeout function whenever I use this function it says "menu is undefined" after th alert. function imgOff(menu, num) { if (document.images) {...
2
by: RootShell | last post by:
Hello First of all i know that PHP is a server side, and JavaScript is a Client side programming language, but i need to know if there is any way i can add the variable "countDownInterval" from...
1
by: cirillo_curiosone | last post by:
Hi, i'm new to javascript. I started studing it on the web few weeks ago, but still haven't been able to solve one big problem: HOT TO PASS VALUES FROM A SCRIPT VARIABLE TO A CHILD HTML...
2
by: brianwmunz | last post by:
Hi, I'm having a problem passing a variable through a URL because the variable is supposed to hold a URL that has a variable of its own. Here is an idea of what I'm trying to do: href="javascript:...
6
by: ged | last post by:
Hi, i am a oo (c#) programmer, and have not used javascript for a while and i cant work out how javascript manages its references. Object References work for simple stuff, but once i have an...
5
by: sfeher | last post by:
Hi All, I need to call a function(loaded with appendChild) for which I have the name as a string. .... var fnName = 'fn1'; var call = fnName + '('+ param +' )'; eval(call);
2
satterfieldben
by: satterfieldben | last post by:
I have a newbie question about passing variables between functions. I am wanting to use a drop down box to select a value. Then base on which was selected, it would create a variable and I would...
5
by: aelred | last post by:
I have a web page where a member can open up a chat window (child window) with another member. - From there the member can also navigate to other web pages. - From other pages in the site, they...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.