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 9013 Dormilich 8,658
Recognized Expert Moderator Expert
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??
Dormilich 8,658
Recognized Expert Moderator Expert
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??
Dormilich 8,658
Recognized Expert Moderator Expert @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)
acoder 16,027
Recognized Expert Moderator MVP
Instead of trying to pass an array, pass something that the server-side script will recognise, e.g. "val=1&val=2&va l=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...
Dormilich 8,658
Recognized Expert Moderator Expert @sarega
that's just a matter of correctly setting the text boxes' default 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 stuck:
I have page of results obtained from a MySQL query presented as a table (the
first column having checkboxes for each of the rows in the table, and all
having the name "seqs"). I have set up a javascript (connected to a "toggle
all" checkbox)...
|
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 (count = 0; count <= 1; count++) {
if (eval(f.RadioButtons.checked)) {
btnChosen = true;
}
|
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 dynamically creating an
array in the jsp page and want to pass this array (by reference) to
the javascript function.
All I want to do in the javascript function is to check whether the
input value matches with any of the array elements. However, i have...
|
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++) {
items = "item" + (i + 1);
| |
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 questions:
1) is this technology made for passing a lot of variables or in fact only
for one?
2) does it exist a esier way to pass the values and to recover them in
javascript?
|
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, which will
handle the audio somehow.
The JavaScript callback is a simple function, which I pass to the C#
object during its initialization; I then invoke the JavaScript
callback using
theCB.GetType().InvokeMember("", BindingFlags.InvokeMethod,...
|
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 "selectedValues"
from next page for php variable
this is my javascript code saved on "sendValue.js" file,
<script>
function updateRecordEntry(requestValue){
|
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 Array("./images/under1.png","./images/anemon.png","./images/arrow.png", "./images/babymoray.png","./images/grouper.png","./images/meridian.png", "./images/grouper1.png","./images/moray.png", "./images/morayeel.png", "./images/toitle.png", "./images/triggerfish.png",...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |