473,468 Members | 1,328 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

hidden and more values

if inner a form I have :
foreach ($arrayquery as $a)
{ echo <input type="hidden" name="x1" value=" $a->type" >;
echo <input type="hidden" name="x2" value=" $a->color" >;
echo <input type="hidden" name="x3" value=" $a->pos" >;
}

and in:
<script type=text/javascript>
var test1=document.form.x1;
var test2=document.form.x2;
var test3=document.form.x3;
....code
</script>

now I want to use only a field hidden for all value;
I thinked some similar:
$arr=[[$a->type]=>[$a->color,$a->pos]];
<input type="hidden" name="x1[]" value="$arr" >;
the problem is here (to put array) and after
in the script javascript
is there some example online or your solution ?
Aug 30 '06 #1
3 1133
artev said the following on 8/30/2006 2:06 AM:
if inner a form I have :
foreach ($arrayquery as $a)
{ echo <input type="hidden" name="x1" value=" $a->type" >;
echo <input type="hidden" name="x2" value=" $a->color" >;
echo <input type="hidden" name="x3" value=" $a->pos" >;
}
If you view the source of that output, you will find that you have
multiple inputs with the same name attribute. You can't do that and
expect any reasonable response from scripting or even on the server.
and in:
<script type=text/javascript>
var test1=document.form.x1;
var test2=document.form.x2;
var test3=document.form.x3;
....code
</script>

now I want to use only a field hidden for all value;
I thinked some similar:
$arr=[[$a->type]=>[$a->color,$a->pos]];
<input type="hidden" name="x1[]" value="$arr" >;
If your PHP code is concatenating the array contents then the value of
the field will be all the values of all the inputs, is that what you wanted?
the problem is here (to put array) and after
in the script javascript
Huh? Just read it's value:

theValue = document.formID.elements['x1[]'].value;

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Aug 30 '06 #2
Il Wed, 30 Aug 2006 02:50:08 -0400, Randy Webb ha scritto:
theValue = document.formID.elements['x1[]'].value;
this work I see 10000
code php
$fruits=10000;
echo <input type="hidden" name="x1[]" id="x1[]" value="$fruits" >;

code javascript
var test3 = document.formID.elements['x1[]'];
alert(test3[0].value);
---------------------------------------------------

that bottom, not work; I see in the alert the word: array
I want to use the array of array in the javascript's code
using the hidden's variable

code php
foreach ($arrayquery as $a)
{
$fruits = array($a['type'] =array(1 ='color', 2 ='pos'));
echo <input type="hidden" name="x1[]" id="x1[]" value="$fruits" >;
}

code javascript
var test3 = document.formID.elements['x1[]'];
alert(test3[0].value);
Aug 30 '06 #3
artev said the following on 8/30/2006 6:01 AM:
Il Wed, 30 Aug 2006 02:50:08 -0400, Randy Webb ha scritto:
>theValue = document.formID.elements['x1[]'].value;

this work I see 10000
code php
$fruits=10000;
echo <input type="hidden" name="x1[]" id="x1[]" value="$fruits" >;

code javascript
var test3 = document.formID.elements['x1[]'];
alert(test3[0].value);
---------------------------------------------------

that bottom, not work;
Thats because test3 is not an array. Also, is the ID of your form
element "formID" ?

Either way, you *should* be getting an error on the alert line.
I see in the alert the word: array
I want to use the array of array in the javascript's code
using the hidden's variable
If you want JS code, why not just produce JS code instead of trying to
put it into a hidden input and then reading it via JS? What you want to
ultimately do with that JS code will dictate how you want it created.
--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Aug 30 '06 #4

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

Similar topics

10
by: Randell D. | last post by:
Folks, Perhaps someone can figure this out - this is 'the process of my script' I have a form whereby I can add multiple contacts to a single address. There is only one...
2
by: JimS | last post by:
Hello I seem to be having a problem with saving hidden values. I am trying to use the hidden values to post infomation back to the same page and also to a different second page. I would like to...
6
by: GoCMS | last post by:
Hi, guys: I am trying debug other people(who has left company)'s ASP code, and had difficulty understanding the use of a hidden asp page. The application has an index page, like MyIndex.asp...
3
by: Itai | last post by:
I have an aspx file named index.aspx which contains two ‘form' sections, one that has the runat=server attribute (e.g From1) and one which is a regular HTML form (e.g SignInForm). I am trying...
9
by: Randell D. | last post by:
Folks, I have a large amount of values to store (we're talking tens, if not hundreds of bytes). I need this for a client side application - ignore the security consequences for the moment -...
3
by: Jeremy Ames | last post by:
I have a form that contains two hidden values, among other controls. I was wondering, if I change these values in server script and immediately do a server.transfer, do these values get updated...
351
by: CBFalconer | last post by:
We often find hidden, and totally unnecessary, assumptions being made in code. The following leans heavily on one particular example, which happens to be in C. However similar things can (and...
2
by: Jeff | last post by:
....still new to .net 2005 using VB. Do I understand correctly that the value of a session variable is actually stored in the server's ram, but relies on the asp.net session ID cookie that...
3
by: simora | last post by:
Hi: Need some working sample code to post hidden form data from a php page to a new popup window. 540 x 500 centered. The popup that I'm calling already is formatted and has a TITLE:web-2007.php...
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
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
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...
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,...
1
isladogs
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...

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.