473,795 Members | 3,002 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Display the selected item

Ranjan kumar Barik
95 New Member
Hello !!!

I am Ranjan.

can the selected item of a combo box be displayed on the same page.
I mean when I just click the item of a combo box it will atonce displayed on the page.

Thanks !!!
Aug 28 '07 #1
16 2988
markrawlingson
346 Recognized Expert Contributor
This is easy to accomplish with javascript.

Place the following code within your < select > tag

onChange="javas cript:document. getElementById( 'myId').innerTe xt=this.options[this.selectedIn dex].value;"

Modify the Id of the object where you wish the content to be placed as necessary, of course.

For example...

<select name="whatever" id="whatever" onChange="javas cript:document. getElementById( 'myId').innerTe xt=this.options[this.selectedIn dex].value;">
<option value="whatever 1">Whatever1 </option>
<option value="whatever 1">Whatever1 </option>
<option value="whatever 1">Whatever1 </option>
<option value="whatever 1">Whatever1 </option>
<option value="whatever 1">Whatever1 </option>
</select>

and have a layer, like a div or span tag, present on the page
<div id="myId"></div>
Aug 28 '07 #2
Ranjan kumar Barik
95 New Member
This is easy to accomplish with javascript.

Place the following code within your < select > tag

onChange="javas cript:document. getElementById( 'myId').innerTe xt=this.options[this.selectedIn dex].value;"

Modify the Id of the object where you wish the content to be placed as necessary, of course.

For example...

<select name="whatever" id="whatever" onChange="javas cript:document. getElementById( 'myId').innerTe xt=this.options[this.selectedIn dex].value;">
<option value="whatever 1">Whatever1 </option>
<option value="whatever 1">Whatever1 </option>
<option value="whatever 1">Whatever1 </option>
<option value="whatever 1">Whatever1 </option>
<option value="whatever 1">Whatever1 </option>
</select>

and have a layer, like a div or span tag, present on the page
<div id="myId"></div>
Hello !!!
You have sended me a very good script.
But I am sorry to mention that I actually trying it in an "asp file" using "vbscript"
So I am sorry again.
Still I need your help.

Thankssssss !!!!
Aug 29 '07 #3
jhardman
3,406 Recognized Expert Specialist
Hello !!!
You have sended me a very good script.
But I am sorry to mention that I actually trying it in an "asp file" using "vbscript"
So I am sorry again.
Still I need your help.

Thanks!
Ranjan,

vbscript and javascript are not mutually exclusive. ASP scripts are run on the server so only function when the page is loading, and mark is suggesting you add client-side scripting. The most well-supported client-side script is javascript and his example would work well for your purpose.

Jared
Aug 29 '07 #4
Ranjan kumar Barik
95 New Member
Ranjan,

vbscript and javascript are not mutually exclusive. ASP scripts are run on the server so only function when the page is loading, and mark is suggesting you add client-side scripting. The most well-supported client-side script is javascript and his example would work well for your purpose.

Jared
Hello Jhardman !!!

I have used the script and it works well.
I just have done it like this ;


<%
dim str
str = "select india pakistan bangladesh usa uk china indonesia southAfrica"
dim country
country = split(str," ")
dim c
c=ubound(countr y)

response.write( "<form><sel ect name=cbo onchange=javasc ript:document.g etElementById(' myId').innerHTM L=this.value;>" )
for i=0 to c
response.write( "<option value="&country (i)&">"+Cstr(co untry(i)))
response.write( "</option>")
next
response.write( "</select></form>")
%>

But in this case one problem is that when I open view soure on the page I found that there is nothing inside the <div> section.I just want to make it visible.

ThankSSSSSSSS !!!!!!
Aug 30 '07 #5
markrawlingson
346 Recognized Expert Contributor
The div container holds dynamically generated content on the client side, but is initialized as empty when you write the script - so if you open the source you won't see anything in the div container. That's normal.
Aug 30 '07 #6
Ranjan kumar Barik
95 New Member
The div container holds dynamically generated content on the client side, but is initialized as empty when you write the script - so if you open the source you won't see anything in the div container. That's normal.
Its true that the container has dynamically generated content.
>>Is there any way to do it before the container is being inisialised.

>>>that is the asp file would generate an html file where I can see the combo box selected and the selected item is also displayed.I hope you understand.
Aug 31 '07 #7
jhardman
3,406 Recognized Expert Specialist
Its true that the container has dynamically generated content.
>>Is there any way to do it before the container is being inisialised.

>>>that is the asp file would generate an html file where I can see the combo box selected and the selected item is also displayed.I hope you understand.
If I understand you right, what you actually want to do is submit the form when an option from the select box is selected, then the form handler sends back to the browser an almost identical page, but with the div added on. This is doable, I have seen it done to good effect. just put an onChange attribute on the select control which submits the form, and resend the page with all of their inputs filled out. does this make sense?

Jared
Aug 31 '07 #8
Ranjan kumar Barik
95 New Member
If I understand you right, what you actually want to do is submit the form when an option from the select box is selected, then the form handler sends back to the browser an almost identical page, but with the div added on. This is doable, I have seen it done to good effect. just put an onChange attribute on the select control which submits the form, and resend the page with all of their inputs filled out. does this make sense?

Jared
I have submitted the form using onchange event.But I could not make out how to resend the page with filled out combobox and simultaneously the <div> will be displayed.
Sep 1 '07 #9
markrawlingson
346 Recognized Expert Contributor
It's different for each type of form element..

For texboxes - <input type="text" name="atextbox" value="<%=Reque st.Form("atextb ox")%>"> - basically you're grabbing the content from itself.

To fill the div...

Expand|Select|Wrap|Line Numbers
  1. <div id="whatever">
  2. <%=Request.Form("yourselectbox")%>
  3. </div>
  4.  
Select boxes, radio buttons, and check boxes are a little trickier because their default value is "CHECKED" (radio buttons) and "SELECTED" (Select boxes)

I usually create a function for writing out select boxes, because then it's very straight forward.. otherwise you have to write out :

Expand|Select|Wrap|Line Numbers
  1. <% if request.form("thisbox") = "this value" Then Response.write "SELECTED" end if %>
  2.  
For each and every option box. Same thing for radio button options.
Sep 1 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

3
10255
by: shreddie | last post by:
Could anyone assist with the following problem? I'm using JavaScript to hide/show table rows depending on the option selected in radio buttons. The script works fine in IE but in Firefox the hidden rows take up page space even though their content is not visible. I have extracted the necessary code as shown below: ************************************************************************
3
7811
by: Northern | last post by:
I need to write code clear the display box of my DropDownList (something like clear current selected item) while still keep the loaded item list in the DropDownList. I tried DropDownList's ClearSelecttion() method and set SelectedIndex to -1 but neither works. How should I do this? Thanks
10
10772
by: dhnriverside | last post by:
Hi guys Still having a problem with this dropdownlist. Basically, I've got 4. The first 2 work fine, then my code crashes on the 3rd. ddlEndTimeHour.Items.FindByValue(endTime).Selected = true; Where endTime is a string containing "15".
4
1992
by: cwoll | last post by:
I am runing this function to toggle buttens to display an "X" when they is selected, the butten is linked to a yes/no field. This function works good, the problem I am having is that when I make a new record the "X" from the last record I looked at are still there, but the bottens are not selected nether should they be. How do I clear every thing when creating a new record? Any help would be apprecated. Clarence Wollman Function...
3
1881
by: rukkie | last post by:
I've made a webform in which some selection boxes are incorporated. Once the form is submitted the user can display the form again and all the options selected are highlighted (via the "selected" keyword). The only thing what bothers me is that sometimes the selected option is not visible ; one has to scroll down the selection box to see the highlighted item. Is there anyone who has experienced the same and found a solution for this...
1
4955
by: Bob | last post by:
Hi, Hope you can help me with this one. I'm at my wits end. I'm trying to create an intelligent edit-box like the excellent "Customer" one at the URL: http://munich.schwarz-interactive.de/autocomplete.aspx
3
13301
by: =?Utf-8?B?TWFyayBCb2V0dGNoZXI=?= | last post by:
I am writing a Windows Form app in c# and I've populated a combobox with values. I click on the down arrow to display the list and the list of values displays correctly. Once I select a value, the list disappears and the selected value does NOT display as the selected item. If I click the down arrow again and re-select the value, this time it displays. What's wrong?
2
2139
vikas251074
by: vikas251074 | last post by:
I am creating an application for official use. This application will be used by employees to take items for official use. I have a list, presently this list contains three items - 1) Cartridges, 2) Floppy, 3) CD Note : If a user selects Cartridges then list of printer should display, And if floppy or CD is selected, then 'purpose' text item should display. And many many more,
2
3689
by: kurtzky | last post by:
i created a form that should function as follows: i will enter a number in a textbox..then it should query from the database all the records which has that number..these records will have a different item no in it..then, these records will be saved in a temporary datatable (which i made in a separate class, the name is WBASKET)...The item nos of these records will be displayed in a combobox, say item1, item2, etc.. then,i have a datagrid...
0
9672
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
10439
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...
0
10215
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10165
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
10001
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6783
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5437
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
4113
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
3
2920
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.