Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #3960

Re: Associative Array

From Jerry Stuckle <jstucklex@attglobal.net>
Newsgroups comp.lang.php
Subject Re: Associative Array
Date 2011-11-28 07:27 -0500
Organization A noiseless patient Spider
Message-ID <javunb$78b$1@dont-email.me> (permalink)
References (2 earlier) <4ed09cbf$0$1384$4fafbaef@reader1.news.tin.it> <jar0ic$8mq$1@dont-email.me> <4ed35749$0$1374$4fafbaef@reader1.news.tin.it> <4ed35e4b$0$6887$e4fe514c@news2.news.xs4all.nl> <4ed3638d$0$1387$4fafbaef@reader1.news.tin.it>

Show all headers | View raw


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').value
> = 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.

-- 
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Associative Array "Jesolo Sun" <gala@tiscali.it> - 2011-11-26 01:37 +0100
  Re: Associative Array Jerry Stuckle <jstucklex@attglobal.net> - 2011-11-25 19:55 -0500
    Re: Associative Array "Jesolo Sun" <gala@tiscali.it> - 2011-11-26 09:01 +0100
      Re: Associative Array Jerry Stuckle <jstucklex@attglobal.net> - 2011-11-26 05:01 -0500
      Re: Associative Array Norman Peelman <npeelmandog@cfl.rr.com> - 2011-11-26 07:55 -0500
        Re: Associative Array "Jesolo Sun" <gala@tiscali.it> - 2011-11-28 10:42 +0100
      Re: Associative Array Jerry Stuckle <jstucklex@attglobal.net> - 2011-11-26 10:28 -0500
        Re: Associative Array "Jesolo Sun" <gala@tiscali.it> - 2011-11-28 10:41 +0100
          Re: Associative Array Erwin Moller <Since_humans_read_this_I_am_spammed_too_much@spamyourself.com> - 2011-11-28 11:11 +0100
            Re: Associative Array "Jesolo Sun" <gala@tiscali.it> - 2011-11-28 11:33 +0100
              Re: Associative Array Erwin Moller <Since_humans_read_this_I_am_spammed_too_much@spamyourself.com> - 2011-11-28 12:08 +0100
              Re: Associative Array Jerry Stuckle <jstucklex@attglobal.net> - 2011-11-28 07:27 -0500
                Re: Associative Array Cristiano Larghi <c.larghi@criosoftware.it> - 2011-11-28 12:41 +0000
                Re: Associative Array "Jesolo Sun" <gala@tiscali.it> - 2011-11-28 14:48 +0100
                Re: Associative Array Jerry Stuckle <jstucklex@attglobal.net> - 2011-11-28 13:57 -0500
                Re: Associative Array Doug Miller <doug_at_milmacdotcom@example.com> - 2011-11-28 15:42 -0500
                Re: Associative Array Jerry Stuckle <jstucklex@attglobal.net> - 2011-11-28 16:00 -0500
                Re: Associative Array Doug Miller <doug_at_milmacdotcom@example.com> - 2011-11-28 18:26 -0500
                Re: Associative Array Jerry Stuckle <jstucklex@attglobal.net> - 2011-11-28 21:03 -0500
                Re: Associative Array "Jesolo Sun" <gala@tiscali.it> - 2011-11-28 14:31 +0100
                Re: Associative Array "Jesolo Sun" <gala@tiscali.it> - 2011-11-28 15:59 +0100
                Re: Associative Array Erwin Moller <Since_humans_read_this_I_am_spammed_too_much@spamyourself.com> - 2011-11-28 16:39 +0100

csiph-web