Hi, -
<?
-
#cd.php
-
echo "<input type='text' name='text1' id='text1' onchange=\"return_value()"\ /><br></br>";
-
?>
-
Javascript file - var xmlHttp;
-
function return_value() {
-
var x=document.getElementById('text1').value;
-
xmlHttp = GetXmlHttpObject();
-
if(xmlHttp == null) {
-
alert("Your browser does not support ajax");
-
return;
-
}
-
var url="ab.php";
-
url=url+"?x="+x;
-
xmlHttp.open("GET",url,true);
-
xmlHttp.send(null);
-
xmlHttp.onreadystatechange = StateChanged;
-
function StateChanged() {
-
if(xmlHttp.readyState == 4) {
-
var y=new Array();
-
y= xmlHttp.responseText;
-
}
-
}
the file ab.php returns an array to the javascript file, how can i pass this array 'y' to the php cd.php file
12 8970
I guess you have to use a serializer for that. JSON and WDDX are the ones I've heard of (both work in Javascript and PHP)
in the javascript code line 16 is unnecessary, your array (y) will be replaced by the return string (responseText).
ok...can you just give an example of how to serialize it??
so far I've only done WDDX. JSON might be more suitable for you. explanations and example you can find here:
ok will try that now...thank you
for serializing at the javascript and deserializing at the php side, can both the javascript n php be in different files??
@sarega
yes...???
PHP is run on the server, JS in the browser, that's two different locations. so why would you have them in the same file? (besides the fact that serialization originates from transfering complex data between system)
Instead of trying to pass an array, pass something that the server-side script will recognise, e.g. "val=1&val=2&val=3" (rather like how checked checkbox values are passed).
I cannot reload the page, if I did then the values that are entered in the text boxes will be lost...
@sarega
that's just a matter of correctly setting the text boxes' default values.
But the value in the text box will not be the same every time the form is submitted for the user
I don't see the problem there.
Yes, no problem there. Either use Ajax, or use the new submitted values to set the text box values.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Nath |
last post by:
Please help!?
I am new to writing html, javascript, pretty new to MySQL but quite
proficient at writing Perl and i'm a quick learner.
I am building a database driven website and i am a little...
|
by: Seeker |
last post by:
Newbie question here...
I have a form with some radio buttons. To verify that at least one of the
buttons was chosen I use the following code ("f" is my form object) :
var btnChosen;
for...
|
by: Sunny |
last post by:
Hi,
I am at present working on a jsp page which has a single text field.
Upon entering a value in the field, i am trigerring an onChangeEvent()
which calls a method of javascript. I am also...
|
by: Augusto Cesar |
last post by:
Hello people.
How can I Pass ASP Array variable to Javascript;
I´m to trying this:
<script language="JavaScript">
var x = new Array(10);
|
by: Sean Dockery |
last post by:
I have the following HTML file that I've been using for testing...
<html>
<head>
<script type="text/javascript">
<!--
function handleWindowLoad() {
var items = ;
for (var i = 0; i < 11; i++)...
|
by: André |
last post by:
Hi,
I have to pass a lot of variables from vb.net to javascript using client
callback. the problem is that there are single variables, but also arrays
with differents indexes.
I have two...
|
by: thomas_okken |
last post by:
I'm working on a little C# DLL that will let me capture audio from
within Internet Explorer. The idea is that the C# object, once it is
recording, will periodically invoke a JavaScript callback,...
|
by: IRC |
last post by:
hey, i am pretty new on javascript as well as PHP,
Hey, anyone can you help me, how to pass the javascript array value to
php page.........
i want to retrieve the values which are arrayed on...
|
by: helraizer1 |
last post by:
Hi all,
I have a photography page on my website, I have pictures on the page (obviously) but the file names are stored and loaded in Javascript, in an array.
var pic = new...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
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...
|
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...
|
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,...
|
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...
|
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,...
| |