473,782 Members | 2,699 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 1481
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
1101
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
4685
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
2037
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
1197
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
14372
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
2168
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
2519
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
3628
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
3087
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
9639
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
9474
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
10143
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...
0
9939
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...
1
7486
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
6729
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
5507
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4040
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
2870
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.