473,804 Members | 3,425 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 7163
On Oct 4, 9:53 pm, vimal <cool.vimalsm.. .@gmail.comwrot e:
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.ne t.auwrote:
On Oct 4, 9:53 pm, vimal <cool.vimalsm.. .@gmail.comwrot e:
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="tru e")-->in javascript
<option>vimal </option>
<option>sanja y</option>
<option selected="selec ted">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.ne t.auwrote:
>On Oct 4, 9:53 pm, vimal <cool.vimalsm.. .@gmail.comwrot e:
>>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="tru e")-->in javascript
<option>vimal </option>
<option>sanja y</option>
<option selected="selec ted">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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
6601
by: deko | last post by:
I populate a drop-down list like this: echo "<select>"; foreach ( $ip_list as $var ) { echo "<option>"; echo $var; echo "</option>"; } echo "</select>";
2
2468
by: Serge Myrand | last post by:
Hi, I cannot get the selected option to be POSTed (it does not appear in the QueryString when using GET neither) I construct the drop down list from an array, I select an element in the list, I POST using a submit button. When I use Request.Form("NAME") it's always empty. Is the selected item is Posted? How to retreive it?
2
336
by: sara | last post by:
Hi to all i have two drop down list when i select a certain item in the first one i load items to second one but when i select first item in first list no action is make why ?? any ideas??
2
12625
by: Yoshitha | last post by:
hi I have 2 drop down lists in my application.1st list ontains itmes like java,jsp,swings,vb.net etc.2nd list contains percentage i.e it conatains the items like 50,60,70,80,90,100. i will select any skill in 1st drop down list then i'll select % of this skill in the 2nd list box , based on the percentage i've selected in the 2nd list box it has to display 2 sets of drop down list boxes at run time one for selecting skill and
3
1810
by: KatMagic | last post by:
How do you force a drop down list to default to a particular item based on its value? I have a drop down list with options Yes, No, Maybe, All, and I would like it to default to "All" This is my code, what am I doing wrong? ddlBilling.SelectedIndex = ddlBilling.Items.IndexOf(ddlBilling.Items.FindByValue("All"))
2
3207
by: leeperman | last post by:
In Dreaweaver I cannot filter my database results to display only specific data that is retrieved from mulptile drop down list on my search page. The drop down list selections are posted to my display page by GET. How do i write my sql code so to only display info where TOWN = "Town selected from list" AND BEDS ="No of Beds selected from list My search page form is below <form action="tsearchresults.asp" method="get" name="townSearchForm"...
2
2120
by: chandm | last post by:
i have one registration form in that registration state and city dropdownlists are there. when select Andhrapredesh in state(dropdownlist) then the related cities will be displayed in city(dropdownlist) how can we done this through javascript. please give me urgent
2
2961
by: indhuma | last post by:
Hi, I'm using the following code to show the category = thoughts. I have three categories, when i select thoughts only it has to show the thoughts category. If i select other category it has to show that particular category details. I don't know how i have to mention the particular category. Please help me. <?php if(isset($_POST) && ($_POST=="GO")) { $sqlquery2="select * from news where category like '%thoughts%'"; $queryresult2...
4
3063
by: hdhouse3rd | last post by:
Greetings: A newbie question. I have a form that is completed and every time we save the form the value of the drop down list is reset to default. I presume you need to do a query of the database and challenge with drop down list to make that the primary field. Here is the code I have so far: <td colspan="2" id="c180">Water Source: <select name="water_source" size="1" id="water_source" style="height:15px width:67px"...
0
9704
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10561
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10302
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9132
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7608
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5505
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4277
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3803
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2976
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.