473,837 Members | 1,558 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need button to clear drop downs wo postback

Greeting

I built asp.net (V1.1) page.
I want to use this button to reset SelectedIndex=0 on several drop
down lists. However, I do not want to post back to server. The point
is to avoid the round trip.

It had an asp:button which would post back to the server when clicked
but changed it to an input button to avoid the postback. (If that is
not needed,let me know)

So, I now have
<input type=button value="clear" onclick="Clear_ ddls()">

in header of page I have script
function Clear_ddls()
{
want to set ddlLastName.sel ectedIndex = 0;
}

I know the script runs because I put an alert message in there.
I do not know how to reference the drop down lists contained on my
asp.net page from in the script.
I tried different forms of document.get... , or Form1.ddlLastNa me,
etc.. but can not get it to work.

My form contains
<ASP:dropdownli st id="ddlLastName "
runat="server" bla bla></asp:dropdownlis t>

This list (and others ) are populated on server side. That is ok for
me. I just want to be able to reset it on client side with script.

Can I do this?
thanks
Jeff

May 16 '06 #1
3 1483
you need to use the ClientId property of the controls to know the name. try:

function Clear_ddls()
{
document.getEle mentById('<%=dd lLastName.Clien tId%>').selecte dIndex =
0;
}
-- bruce (sqlwork.com)

"Jeff User" <je*******@hotm ail.com> wrote in message
news:n2******** *************** *********@4ax.c om...
Greeting

I built asp.net (V1.1) page.
I want to use this button to reset SelectedIndex=0 on several drop
down lists. However, I do not want to post back to server. The point
is to avoid the round trip.

It had an asp:button which would post back to the server when clicked
but changed it to an input button to avoid the postback. (If that is
not needed,let me know)

So, I now have
<input type=button value="clear" onclick="Clear_ ddls()">

in header of page I have script
function Clear_ddls()
{
want to set ddlLastName.sel ectedIndex = 0;
}

I know the script runs because I put an alert message in there.
I do not know how to reference the drop down lists contained on my
asp.net page from in the script.
I tried different forms of document.get... , or Form1.ddlLastNa me,
etc.. but can not get it to work.

My form contains
<ASP:dropdownli st id="ddlLastName "
runat="server" bla bla></asp:dropdownlis t>

This list (and others ) are populated on server side. That is ok for
me. I just want to be able to reset it on client side with script.

Can I do this?
thanks
Jeff

May 16 '06 #2
Bruce

I have the script running wo any errors, but the drop down list does
not change appearance on the screen. Does this mean it isn't working
or do I have to do something to get the drop down to re-display itself
with its new index (assuming it has been reset to 0)

Thanks
Jeff
On Tue, 16 May 2006 11:37:17 -0700, "bruce barker \(sqlwork.com\) "
<b_************ *************@s qlwork.com> wrote:
you need to use the ClientId property of the controls to know the name. try:

function Clear_ddls()
{
document.getEle mentById('<%=dd lLastName.Clien tId%>').selecte dIndex =
0;
}
-- bruce (sqlwork.com)

"Jeff User" <je*******@hotm ail.com> wrote in message
news:n2******* *************** **********@4ax. com...
Greeting

I built asp.net (V1.1) page.
I want to use this button to reset SelectedIndex=0 on several drop
down lists. However, I do not want to post back to server. The point
is to avoid the round trip.

It had an asp:button which would post back to the server when clicked
but changed it to an input button to avoid the postback. (If that is
not needed,let me know)

So, I now have
<input type=button value="clear" onclick="Clear_ ddls()">

in header of page I have script
function Clear_ddls()
{
want to set ddlLastName.sel ectedIndex = 0;
}

I know the script runs because I put an alert message in there.
I do not know how to reference the drop down lists contained on my
asp.net page from in the script.
I tried different forms of document.get... , or Form1.ddlLastNa me,
etc.. but can not get it to work.

My form contains
<ASP:dropdownli st id="ddlLastName "
runat="server" bla bla></asp:dropdownlis t>

This list (and others ) are populated on server side. That is ok for
me. I just want to be able to reset it on client side with script.

Can I do this?
thanks
Jeff


May 16 '06 #3
No other ideas?

Any body?

Jeff
On Tue, 16 May 2006 11:37:17 -0700, "bruce barker \(sqlwork.com\) "
<b_************ *************@s qlwork.com> wrote:
you need to use the ClientId property of the controls to know the name. try:

function Clear_ddls()
{
document.getEle mentById('<%=dd lLastName.Clien tId%>').selecte dIndex =
0;
}
-- bruce (sqlwork.com)

"Jeff User" <je*******@hotm ail.com> wrote in message
news:n2******* *************** **********@4ax. com...
Greeting

I built asp.net (V1.1) page.
I want to use this button to reset SelectedIndex=0 on several drop
down lists. However, I do not want to post back to server. The point
is to avoid the round trip.

It had an asp:button which would post back to the server when clicked
but changed it to an input button to avoid the postback. (If that is
not needed,let me know)

So, I now have
<input type=button value="clear" onclick="Clear_ ddls()">

in header of page I have script
function Clear_ddls()
{
want to set ddlLastName.sel ectedIndex = 0;
}

I know the script runs because I put an alert message in there.
I do not know how to reference the drop down lists contained on my
asp.net page from in the script.
I tried different forms of document.get... , or Form1.ddlLastNa me,
etc.. but can not get it to work.

My form contains
<ASP:dropdownli st id="ddlLastName "
runat="server" bla bla></asp:dropdownlis t>

This list (and others ) are populated on server side. That is ok for
me. I just want to be able to reset it on client side with script.

Can I do this?
thanks
Jeff


May 18 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1102
by: Jeff Uchtman | last post by:
Have a 5 page simple (?) form that the customer wants end users to be able to do next back at will while filling this out (not sure why). Had some problems with the back button and versions of IE so I started drawing from the session on back <?php echo $_SESSION?> which works out fine. I need some help on pre-filing via session the drop downs and radio buttons now. I an not a avid PHP coder and only know how to do this in ASP. Any help...
1
4691
by: Martial Spirit | last post by:
Hello- I was amazed at the suckerfish drop-downs from AListApart.com. They work great except for one thing, if I position the drop-downs over an iframe element, on mouseover the menus disappear. It works fine in IE, but not FireFox. I would like to implement these menus, but if I can't get this to work, I gotta look at something else. If anyone has some suggestions, I would appreciate it.
8
2039
by: Kim14 | last post by:
Help! I am trying to create a webpage and it would be obvious to anyone who reads my source code (it's a mess) that I created it using a template. I know almost nothing about webpages, but am happy with all but a few bugs in my page. I have read many posts about opening drop-downs in new windows, and have spent hours looking over my source code to see what I have done wrong.
4
1198
by: IGotYourDotNet | last post by:
I have 2 drop downs on my screen the second one is displayed and populated based on the selection of the first drop down. The problem i'm having is that when a user selects something it keeps going back to the first item in the list - in this case is Select Car. How can I keep the users selection displayed in the drop down?
1
14401
by: NancyASAP | last post by:
Thought I'd share this since it took me a long time to get it working. Thanks to a bunch of contributers in Google Groups who shared javascript, etc. The question was: How can I put a reset button on my ASP.NET web page, and have an HTML reset button click clear 1) all validator text display and 2) validation summary display. Problem was clearing them and yet still leaving them working and visible if the user immediately began...
1
2171
by: Joe Dunleavy | last post by:
Hi Guys, Hopefully some one will have come across this issue already. I have a DataGrid inside a Div where a scroll bar displays once a certain height is meet --> <div id="dvSales" style="height: 230px; overflow: auto; width: 100%" runat="server"> The Data Grid has AllowPaging is set to False and the HeaderStyle tag is set for the DataGrid so that the header remains fixed when we scroll using the
3
2522
by: Prabhupl | last post by:
Hi I have an problem in asp.net code behine vb.net. :confused: I need to clear the controls while postback the page. eg:- i am getting the input of an child information(name, age, qualification, address, and so on), when i click the (save)button the present information should save in database and clear the control to accept the information for the second child in a single page itself. My problem is after i click the save button, the data...
2
3638
by: John | last post by:
I have CSS drop down navigatoon bar and it works fine. However, when I have page where I have an <embed - needed to show a PDF file, such as: <embed src="Security.pdf" width="900" height="500"></embed> When the mouse passes over the navigation bar, the drop downs are hidden behind the PDF page.
6
3092
by: Rob Meade | last post by:
Hi all, Looking for a bit of help if possible. For about 2 weeks now I've been investigating the best way to populate related drop down menus, and have their values pre-populated again if the user clicks back with their selected options still selected - and I'm getting to the point where I might just popup a big window, perhaps with some flash in it and say "dont be lazy, select em again you great big freak of nature" because I am...
0
9844
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
9683
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10883
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
10578
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
7813
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
7006
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
5851
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4477
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
3126
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.