Re: changing css bu javascript for all input boxes with the same name



amykimber@xxxxxxxxx said the following on 5/8/2006 4:12 AM:
Hi guys,

Thanks for all the advice - especially TheBagbournes for reminding me
the .style bit was wrong.

BTW you also said... "Avoid multiple calls to functions just for
efficiency." - groovy, how would you go about this mission - i.e.
changing the style of all input boxes called 'ship_owner[]'?

Richard Cornford said that calling the function from the href wasn't
really the thing to do, so I've gone back to the classic <a href="#"
onClick="change_class('block')" >Block mode</a> - is this still
considered ok?

After you click the link, watch the location bar. It will append # to the URL. You can prevent that by returning false from the onclick event handler:

onclick="change_class('block');return false"

Or better:

onclick="return change_class('block')"

And have the function return true or false.

If the only purpose of the element is to invoke a JS function, use a button instead:

<button onclick="change_class('block')">Block Mode</button>

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
.


Loading