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 !!!
16 2963
This is easy to accomplish with javascript.
Place the following code within your < select > tag
onChange="javascript:document.getElementById('myId ').innerText=this.options[this.selectedIndex].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="javascript:document.getElementById('myId ').innerText=this.options[this.selectedIndex].value;">
<option value="whatever1">Whatever1</option>
<option value="whatever1">Whatever1</option>
<option value="whatever1">Whatever1</option>
<option value="whatever1">Whatever1</option>
<option value="whatever1">Whatever1</option>
</select>
and have a layer, like a div or span tag, present on the page
<div id="myId"></div>
This is easy to accomplish with javascript.
Place the following code within your < select > tag
onChange="javascript:document.getElementById('myId ').innerText=this.options[this.selectedIndex].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="javascript:document.getElementById('myId ').innerText=this.options[this.selectedIndex].value;">
<option value="whatever1">Whatever1</option>
<option value="whatever1">Whatever1</option>
<option value="whatever1">Whatever1</option>
<option value="whatever1">Whatever1</option>
<option value="whatever1">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 !!!!
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
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(country)
response.write("<form><select name=cbo onchange=javascript :document.getElementById('myId' ).innerHTML=this.value;>")
for i=0 to c
response.write("<option value="&country(i)&">"+Cstr(country(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 !!!!!!
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.
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.
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
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.
It's different for each type of form element..
For texboxes - <input type="text" name="atextbox" value="<%=Request.Form("atextbox")%>"> - basically you're grabbing the content from itself.
To fill the div... -
<div id="whatever">
-
<%=Request.Form("yourselectbox")%>
-
</div>
-
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 : -
<% if request.form("thisbox") = "this value" Then Response.write "SELECTED" end if %>
-
For each and every option box. Same thing for radio button options.
It's different for each type of form element..
For texboxes - <input type="text" name="atextbox" value="<%=Request.Form("atextbox")%>"> - basically you're grabbing the content from itself.
To fill the div... -
<div id="whatever">
-
<%=Request.Form("yourselectbox")%>
-
</div>
-
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 : -
<% if request.form("thisbox") = "this value" Then Response.write "SELECTED" end if %>
-
For each and every option box. Same thing for radio button options.
Hello mark!!!
I am writting the code i have used.Please tell me what more changes I need to make the combox box selected after submission.
------------CODE--------------
<html>
<head><title>dpd</title></head>
<body>
<%
dim str
str = "select india pakistan bangladesh usa uk china indonesia southAfrica"
dim country
country = split(str," ")
dim c
c=ubound(country)
response.write("<form id=frm action=dpd.asp method=post><select name=cbo onchange=frm.submit()>")
for i=0 to c
response.write("<option value="&country(i)&">"+Cstr(country(i)))
response.write("</option>")
next
response.write("</select></form>")
%>
<div id="mydiv">
<%=request.form("cbo")%>
</div>
</body>
</html>
------------END-------------------
Thnaks !!!!!!
Give this a shot, pretty self explanitory. -
<html>
-
<head><title>dpd</title></head>
-
<body>
-
-
<%
-
dim str
-
str = "select india pakistan bangladesh usa uk china indonesia southAfrica"
-
dim country
-
country = split(str," ")
-
dim c
-
c=ubound(country)
-
-
response.write("<form id=frm action=dpd.asp method=post><select name=cbo onchange=frm.submit()>")
-
for i=0 to c
-
If Request.Form("cbo") = country(i) Then
-
IsSelected = " SELECTED"
-
End If
-
response.write("<option value="&country(i)&IsSelected&">" & Cstr(country(i)))
-
response.write("</option>")
-
next
-
response.write("</select></form>")
-
%>
-
-
<div id="mydiv">
-
<%=request.form("cbo")%>
-
</div>
-
-
</body>
-
</html>
-
That should do the trick.
Give this a shot, pretty self explanitory. -
<html>
-
<head><title>dpd</title></head>
-
<body>
-
-
<%
-
dim str
-
str = "select india pakistan bangladesh usa uk china indonesia southAfrica"
-
dim country
-
country = split(str," ")
-
dim c
-
c=ubound(country)
-
-
response.write("<form id=frm action=dpd.asp method=post><select name=cbo onchange=frm.submit()>")
-
for i=0 to c
-
If Request.Form("cbo") = country(i) Then
-
IsSelected = " SELECTED"
-
End If
-
response.write("<option value="&country(i)&IsSelected&">" & Cstr(country(i)))
-
response.write("</option>")
-
next
-
response.write("</select></form>")
-
%>
-
-
<div id="mydiv">
-
<%=request.form("cbo")%>
-
</div>
-
-
</body>
-
</html>
-
That should do the trick.
Sorry mark
It just making the last item selected that is "southafrica" after submission.
Is that not the effect that you wanted? It will auto select whatever the user selects and re-post it back to itself.
If that was not the desired effect, please reply and be more clear and concise with what it is you want to do exactly.
Mark
Is that not the effect that you wanted? It will auto select whatever the user selects and re-post it back to itself.
If that was not the desired effect, please reply and be more clear and concise with what it is you want to do exactly.
Mark
I just want that when I select india the form will be submitted and the value india will remain selected and the division showing india also.
Same for all the other items.
Thanksssssss!!
Oh My bad.. I ran the code and see the mistake. -
<html>
-
<head><title>dpd</title></head>
-
<body>
-
-
<%
-
dim str
-
str = "select india pakistan bangladesh usa uk china indonesia southAfrica"
-
dim country
-
country = split(str," ")
-
dim c
-
c=ubound(country)
-
-
response.write("<form id=frm action=dpd.asp method=post><select name=cbo onchange=frm.submit()>")
-
for i=0 to c
-
If Request.Form("cbo") = country(i) Then
-
IsSelected = " SELECTED"
-
else
-
IsSelected = Empty
-
End If
-
response.write("<option value="&country(i)&IsSelected&">" & Cstr(country(i)))
-
response.write("</option>")
-
next
-
response.write("</select></form>")
-
%>
-
-
<div id="mydiv">
-
<%=request.form("cbo")%>
-
</div>
-
-
</body>
-
</html>
-
That should work now!
Oh My bad.. I ran the code and see the mistake. -
<html>
-
<head><title>dpd</title></head>
-
<body>
-
-
<%
-
dim str
-
str = "select india pakistan bangladesh usa uk china indonesia southAfrica"
-
dim country
-
country = split(str," ")
-
dim c
-
c=ubound(country)
-
-
response.write("<form id=frm action=dpd.asp method=post><select name=cbo onchange=frm.submit()>")
-
for i=0 to c
-
If Request.Form("cbo") = country(i) Then
-
IsSelected = " SELECTED"
-
else
-
IsSelected = Empty
-
End If
-
response.write("<option value="&country(i)&IsSelected&">" & Cstr(country(i)))
-
response.write("</option>")
-
next
-
response.write("</select></form>")
-
%>
-
-
<div id="mydiv">
-
<%=request.form("cbo")%>
-
</div>
-
-
</body>
-
</html>
-
That should work now!
Thanks a lot mark !!!!!!
You donot believe for consicutive 4 days I am working on this.
Thank you very much !
HaaaaaaVe a good day............
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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 =...
|
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...
|
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"...
|
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:
...
|
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,...
|
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, ...
|
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...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
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,...
|
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...
| |