JavaScript - Click disabled option to select other options?

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

JavaScript - Click disabled option to select other options?

Post by JAB Creations »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Here is a multiple choice select form field.  Let us say the user clicks on the state even though it's disabled.

It would make sense to have JavaScript highlight the associated regions of that state all at once when the user clicked on the state with say an onclick or onmousedown event trigger.

[syntax="html"] <select class="state" name="" multiple="multiple">
  <option class="state" disabled="disabled" value="state">State 1</option>
  <option class="region" value="#">Region</option>
  <option class="region" value="#">Region</option>
  <option class="region" selected="selected" value="#">Region</option>
  <option class="region" value="#">Region</option>
  <option class="region" value="#">Region</option>
  <option class="region" value="#">Region</option>

  <option class="state" disabled="disabled" value="state">State 2</option>
  <option class="region" value="#">Region</option>
  <option class="region" value="#">Region</option>
  <option class="region" selected="selected" value="#">Region</option>
  <option class="region" value="#">Region</option>
  <option class="region" value="#">Region</option>
  <option class="region" value="#">Region</option>
</select>
My wild guess at the event handler...

Code: Select all

  <option class="state" disabled="disabled" onmousedown="select(state1)" value="state">State 1</option>
With IDs needing to be unique I'm not sure how you would dynamically doing this without creating some sort of list for all the regions associated with each state. Kick ass idea though.


feyd | Please use[/syntax]

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
bravobritto
Forum Newbie
Posts: 2
Joined: Mon Jul 31, 2006 12:17 am

IE settings page

Post by bravobritto »

On the Tools menu, click Internet Options.
Select the Security tab, and click the icon for the zone containing Internet, then click Custom Level
Scroll down to Scripting and under Active Scripting, select Enable.
Click OK. Click Yes to any popup asking if you want to change the security settings, then click OK. Now retry.

Regards
Britto :x
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Re: IE settings page

Post by RobertGonzalez »

bravobritto wrote:On the Tools menu, click Internet Options.
Select the Security tab, and click the icon for the zone containing Internet, then click Custom Level
Scroll down to Scripting and under Active Scripting, select Enable.
Click OK. Click Yes to any popup asking if you want to change the security settings, then click OK. Now retry.

Regards
Britto :x
Does this have anything to do with highlighting a region based on a select list selection?
JAB Creations wrote:With IDs needing to be unique I'm not sure how you would dynamically doing this without creating some sort of list for all the regions associated with each state.
How would the regions get populated into the form? I am guessing through some sort of a loop, so you could use a counter and increment that as your ID.
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

Post by JAB Creations »

Everah, really I wouldn't mind creating unique ID's and manually setting them to be selected in some sort of loop. Unless someone could go the extra level to take that static idea and make it dynamic. I will have to use ID's, I know that for certain.
Post Reply