NYCPHP Meetup

[nycphp-talk] HTML Javascript Php Arrays

Michele Waldman mmwaldman at nyc.rr.com
Wed Aug 19 07:58:47 EDT 2009


Yeah, there's no document.getElementById("city0").length.  I'm not even
using that particular statement.

 

I was just trying to iterate that document.getElementById("city0") was
definited.

 

Specifically that the id is being used to identify the element but name is
not.

 

Michele

  _____  

From: talk-bounces at lists.nyphp.org [mailto:talk-bounces at lists.nyphp.org] On
Behalf Of Cristian Baltatescu
Sent: Wednesday, August 19, 2009 2:29 AM
To: NYPHP Talk
Subject: Re: [nycphp-talk] HTML Javascript Php Arrays

 

 

On Wed, Aug 19, 2009 at 5:58 AM, Michele Waldman <mmwaldman at nyc.rr.com>
wrote:

I'm trying to dynamically create an array in javascript to pass to php.

 

This works in FF, but not IE 7.  Does anyone know how to make this work in
IE?

 

            var inp = document.createElement("input");

            inp.type = "text";

            inp.name = "city[]";

            inp.id = "city0";

            inp.value = "Houston";

            document.getElementById('theDiv').appendChild(inp);

 

document.getElementById("city0").length -> 1

document.getElementsByName("lcity[]").length -> 0

 

Michele

 


_______________________________________________
New York PHP User Group Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk

http://www.nyphp.org/show_participation.php


Shouldn't document.getElementById("city0").length be
document.getElementById("city0").value.length ?
Also, you should look into creating a json string, send it to php and use
json_decode on the php side. If what you're looking for is sending arrays to
php. But I'm not sure you're thinking of the same thing looking at your
example.

-- 
Numai bine,
Cristian

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20090819/2e53d907/attachment.html>


More information about the talk mailing list