homepage Welcome to WebmasterWorld Guest from 54.167.75.155
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / HTML
Forum Library, Charter, Moderators: incrediBILL

HTML Forum

    
Java script variables
making an array a string
David




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

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 ?

Thanks
David

 

joshie76




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

I think this is what you are trying to do.

function available(newLoc)
{
alert(document.frm[newLoc].selectedIndex)
//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>
</SELECT>
</form>

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 ;)

David




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

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

Brett_Tabke




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

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

David




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

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.

David




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

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.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / HTML
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved