Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript thread: netscape and onclick


Message #1 by "Alex Shiell, ITS, EB, SE" <alex.shiell@s...> on Mon, 3 Mar 2003 17:39:41 -0000
	It's not just Netscape want [ ] instead of ( ); it's in the standard
and definition in C-like languages (in opposite to Basic-like languages as
VBScript created by Microsoft) :
[ ] is for array while ( ) is for function.  If IE accepts ( ) as [ ], it's
its fault.

	On the other hand, as Imar pointed out, a form element already has a
predefined attribute called action, so it's not wise to call a field action
too.  But if you're afraid to break your page, you could use canonical
addressing:

document.forms[0].elements["action"].value = '.....'

which might resolve your problem.

> -----Original Message-----
> From: alex.shiell@s... [mailto:alex.shiell@s...] 
> Sent: mardi 4 mars 2003 12:41
> To: javascript
> Subject: [javascript] RE: netscape and onclick
> 
> 
> Yes, thats sorted it cheers.  And it still works in IE which is nice!
> 
> i'd like to change the field called action, but i'm working on a site 
> built by someone else and they've used it in so many places....
> 
> > Doesn't Netscape want [] instead of ()???
> 
> <input type="button" value="Generate One-off Code"
> onclick="document.forms[0].action.value='generatecode';document.forms
> [0].submit()">
> 
> I guess that Netscape will see forms(0) as a funtion called 
> forms on the
> object document and that you try to pass the parameter 0, 
> instead of an
> indexed collection. Using the square brackets should do the 
> trick......and
> is supposed to be cross browser.
> 
> It may also be not a good idea to name your textfield 
> "action" (if that IS
> a form field, that is). action is used to set the ..... 
> action of the form
> and it expects a URL instead of a text string. This is useful 
> if you want
> to change the action attribute of the form depending on some 
> logic. Change
> it to txtAction for example...
> 
> 
> Cheers,
> 
> Imar
> 
> 
> 
> > yes I realised that after changing it to that - i wouldn't 
> normally do it
> > that way ayway.
> >
> > my code is
> >
> > <input type="button" value="Generate One-off Code" 
> onclick="document.forms
> > (0).action.value='generatecode';document.forms(0).submit()">

  Return to Index