Hey Rob,

The jQuery library has a good function to run script after the DOM  
loads:

http://www.learningjquery.com/2006/09/introducing-document-ready

And it doesn't matter where you place the script on the page.

On your ther problem, I haven't tried this, but you could probably use  
the attribute selector to take care of the options you want to hide:

http://docs.jquery.com/Selectors/attributeEquals#attributevalue

Something like:

$("option[value='33'],option[value='35']").hide();

Hope this helps,
Mike

On Dec 11, 2008, at 2:44 PM, Paul wrote:

>
> Rob,
>
> You should be able to put some JavaScript after the code you want to
> manipulate. Best option IMHO is somewhere close to the end of the
> file. If not in the footer than as far down in the code as you can.
> The 3rd example I provided does remove the item from the dropdown
> display.
>
>       // Disables the 'Chinese (Simplified)' via the options value
>       if (lang_options[i].value == '21')
>               lang_options.remove(i);
>
>
>
>
>
> On Dec 11, 2008, at 2:39 PM, Rob Scott wrote:
>
>>
>> Paul - you are the man! This is exactly what I'm looking to do.  
>> Thanks
>> for the example.
>>
>> However, I have another problem: I'm trying to do this in a
>> third-party app and I don't have access to the HEAD section or the
>> BODY tags, so I can't put the js in the HEAD and I can't attach an
>> onLoad to the BODY tag. :(  I really only have the ability to put the
>> js into markup right after the BODY tag. Does that make it impossible
>> to do?
>>
>> Also, is there a way to remove the "unwanted" menu options from the
>> menu altogether (i.e set the display to "none")?
>>
>> Thanks for your responses Chris & Paul!
>>
>> -- Rob
>>
>> On Thu, Dec 11, 2008 at 2:05 PM, Paul <[email protected]> wrote:
>>>
>>> Rob,
>>>
>>> This is very easy to do with just some straight old fashioned
>>> JavaScript. Check out this test file: 
>>> http://www.codehooligans.com/tmp_open/test_drop.html
>>>
>>> I setup an onLoad event just to kick things off. You can obviously
>>> change this to trigger however you want. Here is the core
>>> functionality. I've provided three options for manipulating the
>>> select
>>> options. The first 2 disable the option (either by text or by value.
>>> The third removes it from the list all together.
>>>
>>> Also, I'm not performing any checks to make sure there are more than
>>> zero options in the select, etc. You can add that on your own.
>>>
>>>              function check_select()
>>>              {
>>>                      var lang_options        =
>>> document.getElementById("LanguageLocaleKey");
>>>
>>>                      for (var i = 0; i < lang_options.length; i++)
>>>                      {
>>>                              // Disable the 'French' via the
>>> options text
>>>                              if (lang_options[i].text == 'French')
>>>
>>> lang_options[i].setAttribute("disabled","disabled");
>>>
>>>                              // Disables the 'Swedish' via the
>>> options value
>>>                              if (lang_options[i].value == '58')
>>>
>>> lang_options[i].setAttribute("disabled","disabled");
>>>
>>>                              // Disables the 'Chinese
>>> (Simplified)' via the options value
>>>                              if (lang_options[i].value == '21')
>>>                                      lang_options.remove(i);
>>>
>>>
>>>                      }
>>>              }
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> On Dec 11, 2008, at 1:25 PM, Rob Scott wrote:
>>>
>>>>
>>>> Hey Refreshers,
>>>>
>>>> I have a form on a webpage and I have no control over the way it's
>>>> marked up. The form has a SELECT box for "Language" with multiple
>>>> options. We do not want users to be able to select some of the
>>>> languages in the SELECT box, but have no way to remove the options
>>>> from the form. I'm curious is there is a way using JavaScript to
>>>> hide
>>>> some of the options by specifying their values. For example, on  
>>>> this
>>>> form:
>>>>
>>>> <form>
>>>> <select  id="LanguageLocaleKey" name="LanguageLocaleKey">
>>>> <option value="1" selected="selected">English</option>
>>>> <option value="33">German</option>
>>>> <option value="41">Spanish</option>
>>>> <option value="48">French</option>
>>>> <option value="50">Italian</option>
>>>> <option value="52">Japanese</option>
>>>> <option value="58">Swedish</option>
>>>> <option value="53">Korean</option>
>>>> <option value="27">Chinese (Traditional)</option>
>>>> <option value="21">Chinese (Simplified)</option>
>>>> <option value="64">Portuguese (Brazilian)</option>
>>>> <option value="23">Dutch</option>
>>>> <option value="70">Danish</option>
>>>> <option value="59">Thai</option>
>>>> <option value="66">Finnish</option>
>>>> <option value="57">Russian</option>
>>>> </select>
>>>> </form>
>>>>
>>>> I only want to show a few of these options in the pull-down menu,
>>>> but
>>>> cannot hide the unwanted options using CSS (as far as I know) since
>>>> there are no ids/classes to add style to. Is there a way to do this
>>>> with JavaScript (using the option "values")?
>>>>
>>>> Thanks in advance for any help you can offer.
>>>>
>>>> -- Rob Scott
>>>>
>>>>>
>>>
>>>
>>>>
>>>
>>
>>>
>
>
> >


--~--~---------~--~----~------------~-------~--~----~
Our Web site: http://www.RefreshAustin.org/

You received this message because you are subscribed to the Google Groups 
"Refresh Austin" group.

[ Posting ]
To post to this group, send email to [email protected]
Job-related postings should follow 
http://groups.google.com/group/Refresh-Austin/web/refresh-austins-job-posting-guidelines.
We do not accept job posts from recruiters.

[ Unsubscribe ]
To unsubscribe from this group, send email to 
[email protected]

[ More Info ]
For more options, visit this group at 
http://groups.google.com/group/Refresh-Austin
-~----------~----~----~----~------~----~------~--~---

Reply via email to