Welcome to WebmasterWorld Guest from

Forum Moderators: incrediBILL

Message Too Old, No Replies

Java script variables

making an array a string



2:37 am on Jun 27, 2001 (gmt 0)

10+ Year Member

I have a form with a name "COLOR[1]" it works great to pass an array to my php script. Now I am tring to use a js onchange event with that form name and I can't get it to look at it as a string.

here is what I have
<select name="COLOR[1]" onchange="available(COLOR[1]) ">

this is the part of the function that breaks down..

function available(newLoc) {
newcolor = newLoc.selectedIndex

the function then goes on to update a div/layer based on the selection. It works great if I just name the form COLOR but that messes a major php script. I am stuck!

Can this be done ?
Any one have any Ideas ?



9:00 am on Jun 27, 2001 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member

I think this is what you are trying to do.

function available(newLoc) 
//or whatever i.e. newcolor = etc.. etc..

<form name="frm">
<select name="COLOR[1]" onChange="available('COLOR[1]')">
<OPTION value="0">0</OPTION>
<OPTION value="1">1</OPTION>
<OPTION value="2">2</OPTION>

When passing the name of the element in the available function it needs to be in ''; otherwise it thinks you are passing a variable (which hasn't been defined).

Personally I would pass the whole object using onChange="available(this)" and pull it out in JS with newLoc.selectedIndex

I have only tried this in IE5 and it may not be what you were talking about in the firstplace - hope it was ;)


2:00 pm on Jun 27, 2001 (gmt 0)

10+ Year Member

Thanks for the help, That works on all browsers. Now my problem is the rest of my function does not work on Netscape 6 or opera.
How would you write. to a div tag with an ID named fillit


2:03 pm on Jun 27, 2001 (gmt 0)

WebmasterWorld Administrator brett_tabke is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

I've heard that style applied to forms is not going to be supported by either Opera or Moz 1 or NN 6


2:25 pm on Jun 27, 2001 (gmt 0)

10+ Year Member

Thats to bad done right you can warm up some of the form elements and help pull the page design together. I like the things you can do with the submit button. Opera does accept the font:weight I was hoping the rest would come.
What I am tring to do is write to a absolute positioned div/layer.


3:12 pm on Jun 27, 2001 (gmt 0)

10+ Year Member

I got netscape 6 to work. I keep forgetting in many cases netscape 6 is not netscape. I tested for document.layers instead of "Netscape" and now the whole family works. I wonder why Opera doesn't like it.

Featured Threads

Hot Threads This Week

Hot Threads This Month