469,902 Members | 1,815 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,902 developers. It's quick & easy.

selecting a default option in a drop down list

hi all,

i am still a learner in javascript

i have a select tag with options as follows:

<select>
<option py:for="mb in range(32,100)">${mb}</option>
</select>

which dynamically generates numbers ranging from 32 to 100

and if i want the list to show the value "50" when the page is loaded
what should be done

thanks in advance,
vimal
Binary Karma Enterprise

Oct 4 '07 #1
3 7016
On Oct 4, 9:53 pm, vimal <cool.vimalsm...@gmail.comwrote:
hi all,

i am still a learner in javascript

i have a select tag with options as follows:

<select>
<option py:for="mb in range(32,100)">${mb}</option>
</select>

which dynamically generates numbers ranging from 32 to 100

and if i want the list to show the value "50" when the page is loaded
what should be done
Set the appropriate option element's selected property to true.
--
Rob

Oct 4 '07 #2
On Oct 4, 5:31 pm, RobG <rg...@iinet.net.auwrote:
On Oct 4, 9:53 pm, vimal <cool.vimalsm...@gmail.comwrote:
hi all,
i am still a learner in javascript
i have a select tag with options as follows:
<select>
<option py:for="mb in range(32,100)">${mb}</option>
</select>
which dynamically generates numbers ranging from 32 to 100
and if i want the list to show the value "50" when the page is loaded
what should be done

Set the appropriate option element's selected property to true.

--
Rob
no if we r having a manual entry.....
like
<selector (.selected="true")-->in javascript
<option>vimal</option>
<option>sanjay</option>
<option selected="selected">ajay</option>
<option>someone</option>
</select>
in this case we know the options
but i want to select the cases i which the options are unknown
that is they r generated dynamically

Oct 4 '07 #3
vimal wrote:
On Oct 4, 5:31 pm, RobG <rg...@iinet.net.auwrote:
>On Oct 4, 9:53 pm, vimal <cool.vimalsm...@gmail.comwrote:
>>hi all,
i am still a learner in javascript
i have a select tag with options as follows:
<select>
<option py:for="mb in range(32,100)">${mb}</option>
</select>
which dynamically generates numbers ranging from 32 to 100
and if i want the list to show the value "50" when the page is loaded
what should be done
Set the appropriate option element's selected property to true.

--
Rob
Please don't quote signatures, trim quotes to what you are replying too.
>
no if we r having a manual entry.....
This is not SMS. Please use reasonable grammar, spelling and punctuation.

like
<selector (.selected="true")-->in javascript
<option>vimal</option>
<option>sanjay</option>
<option selected="selected">ajay</option>
<option>someone</option>
</select>
in this case we know the options
but i want to select the cases i which the options are unknown
that is they r generated dynamically
If you don't know what option you want to select, it doesn't matter how
you go about doing it, you don't know which one to select.

I guess you need to loop through the existing options and whichever ones
have their selected property set to true, set them to false. Or remove
them.

Then use whatever logic appeals to you to set the selected property of
one or more to true.

--
Rob
"We shall not cease from exploration, and the end of all our
exploring will be to arrive where we started and know the
place for the first time." -- T. S. Eliot
Oct 4 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by sara | last post: by
2 posts views Thread by Yoshitha | last post: by
3 posts views Thread by KatMagic | last post: by
1 post views Thread by Waqarahmed | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.