473,395 Members | 1,742 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.

how do I import from a PHP array in a Javascriptarray

Hi
I cannot figure out how to import an array from PHP into Javascript

MyPHPcode is like this

<?php
$i=0;
While ($i < $num) {
$PHPvar= (" $PHPvar \" $Mystring[$i] \" , ");
$i++;
}
?>

The ouput of $Mystring is: "string1","string2","etc"," " (the
last empty string is added later on in the function:
This is exactly what Javascript expects in an array, however I get no
output in Javascript this way.
transfering data:

<INPUT TYPE= "hidden" ID= "PHP2JS" VALUE="<?php echo( $c);?> ">

javascript:

<script type="text/javascript">

var text=PHP2JS.value;
document.write(text);

myarray = new Array(text);

for etc.
</script>

When I replace the \" with nothing (in the PHP part) it works in
the - document write(text) - and all data is loaded into
myarray(0) but I need the " " .

does someone have a better idea?

Thanks

Frits
Netherlands

Frits v/d Laan
Biologische tuinplanten kwekerij
http://fvanderlaan.nl
Feb 4 '06 #1
1 2464

<script type="text/javascript">
<?php
echo "var myjsArr=split(" . implode(",", $Mystring) . ")"; //
$Mystring being the php array object
?>

</script>
as for addressing an IDed object in js, you use
document.getElementById('WHATEVERIDHERE');
Danny
Feb 5 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Michel Feldheim | last post by:
Hi everybody, I have some big csv-like files with 15.000 and more artikles stored in it. They should be put into a mysql database. I thought about PHP processing but only the read and print...
4
by: orange | last post by:
I've got a database in .txt file similar to this: BookName;Author;Year;ReviewedBy;Rating;Pages Nemesis;Isaac Asimov;1989;13,31,24;good;110 Sense & Sensibility;Jane Austen;1970;45,32;great;120...
2
by: musicloverlch | last post by:
I need to import 60 text files all in one folder. Can I use VBA to cycle through all the files, without having to import them one by one? Does anyone have an example? Thanks in advance. Laura
3
by: Jason | last post by:
I have created a dll from a C++ class using .Net and have imported it into my C# applications (one webservice, one standalone app). It works fine for a while, but will eventually fail to produce...
0
by: maxim mat | last post by:
Hi I need to build client for web service. But when I'm using Visual Studio .NET to add Web Reference, I get error: "Custom tool error: Unable to import WebService/Schema. Unable to import...
6
by: jao.sanien | last post by:
Hi all I was wondering if it was possible to some how import .DAT files into access form? I have over 500 DAT files which contains infomation about various components and I wouldn't want to...
3
by: DONE1 | last post by:
Hello, I am trying to import 4 separate csv files from 4 different servers into an excel sheet.I want to write a macro which will automate this.Also, i want to append the name of the server for each...
6
by: Kanis | last post by:
Hi, I am a Python beginner and using PyCrust to process data for my research work. I found I not able to import a .py file directly. But I have to type in every lines every time. Or I can save...
6
by: Romulo NF | last post by:
Greetings again to everyone, Im back to show this grid componenet i´ve developed. With this grid you can show the data like a normal table, remove the rows that you need, add rows, import data,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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
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
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
jinu1996
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...
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
tracyyun
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...

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.