PDA

View Full Version : changing a select box value with js


Carnage
04-03-2005, 10:52 AM
ok what i've got is a page with an image on it, it has an impage map and clickable areas on it, what i'm wanting is for whenever an area is clicked it to change the value of a select box to something else.

i tried: onmousedown='document.forms[6].selectbox.value=newvalue

it came up with the error: forms[6] has no properties

i also tried using the forms name in place of forms[6] same error... any ideas as to what this error means and how to fix it?

Colin F
04-03-2005, 11:18 AM
Selectbox isn't clear to me. Do you mean a dropdown box?

Or a radio button?

Or checkboxes?

if you have a checkbox, then make it selectbox.checked = newvalue; and not value.


If you happen to know german, Selfhtml has a good reference for javascript (http://de.selfhtml.org/javascript/objekte/elements.htm)

Carnage
04-03-2005, 11:43 AM
drop down box. ie <select><option> etc

Guy G
04-03-2005, 12:59 PM
Shouldnt be approachable with the name of the form and check box?

Dean C
04-03-2005, 01:13 PM
AFAIK you can't have trigger events on <option> tags, you need to apply the javascript event to the select :)

Carnage
04-03-2005, 02:58 PM
i know that, i'm trying to attatch it to the image map, to change the option selected in the select box; which should be possible by changing its value...