FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Associative Array
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Associative Array [message #176166 is a reply to message #176164] Mon, 28 November 2011 13:31 Go to previous messageGo to previous message
Jesolo Sun is currently offline  Jesolo Sun
Messages: 8
Registered: November 2011
Karma:
Junior Member
"Jerry Stuckle" ha scritto nel messaggio news:javunb$78b$1(at)dont-email(dot)me...

On 11/28/2011 5:33 AM, Jesolo Sun wrote:
> Hi
> is not possible because in the first page i use this values in
> Javascript functions for example : calculate(numero_99_300, 99, 300);
> this input
> <INPUT style="width: 130px;" id="99_300_numero0" onChange="if
> (this.value < min_numero_per_calcolare) { $(window).humanMsg('Minimal,
> total quantity of products has to be: ' + min_numero_per_calcolare + '
> pcs.'); this.value = ''; return false
> }change_colour('99','300','0',this);document.getElementById('99_300_il0').v alue
> = this.value;cambio_pagamento('99','300');calculate(numero_99_300, 99,
> 300);"
> class="formfield"
> name="product_data[99][300][numero0]" type="text">

I agree with Erwin that using hidden fields will solve your problem, and
I see no reason they should affect your javascript. It would require
the least modification to your page. Using PHP's array functions is
also a solution.

A good start would be to check out foreach(), i.e.

foreach($array = $key=>$value)

You could use this as

foreach ($_POST['product_data'] as $product_id=>$prod_data)
foreach ($prod_data as $product_variant=>$variant_data)

But I also think your approach can be confusing. Better I would think
would be to just use product_data[0], product_data[1], etc, with a
hidden field containing id, i.e.

<input type="hidden" name="product_data[0][id]" value="99"> (product id)
<input type="hidden" name="product_data[0][0]" value="300"> (variant)
<INPUT id="99_300_prezzo0" name="product_data[0][0][0]"
readOnly="readonly" type="text"> (value for prezzo0)
<INPUT id="99_300_prezzo1" name="product_data[0][0][1]"
readOnly="readonly" type="text"> (value for prezzo1)

And so on.



Ok i understand

i have used this example
http://us.php.net/manual/en/function.array-keys.php#73992:

the response of Array is this
Array
(
[0] => 0
[1] => product_data
[2] => 99
[3] => 300
[4] => prezzo0
[5] => prezzo1
[6] => prezzo2
[7] => prezzocal0
[8] => prezzocal1
[9] => prezzocal2
[10] => numero0
[11] => numero1
[12] => numero2
[13] => color
[14] => tipo_stampa
[15] => il_colore0
[16] => il_colore1
[17] => il_colore2
[18] => ad_adornment
[19] => 0
[20] => 1
[21] => 2
[22] => 3
[23] => pacchetto_id
[24] => colorepack
[25] => realization_period
[26] => submit
)

question:
Is it to get this values?

example
$val0 = [2] => 99
$val1 = [4] => 1,44
$val1 = [14] => 2_0
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Order/Timing of Execution of PHP
Next Topic: Browser doesn't support
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sun Nov 10 11:18:00 GMT 2024

Total time taken to generate the page: 0.07195 seconds