473,324 Members | 1,678 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

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.selectedIndex = 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.ddlLastName,
etc.. but can not get it to work.

My form contains
<ASP:dropdownlist id="ddlLastName"
runat="server" bla bla></asp:dropdownlist>

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 1463
you need to use the ClientId property of the controls to know the name. try:

function Clear_ddls()
{
document.getElementById('<%=ddlLastName.ClientId%> ').selectedIndex =
0;
}
-- bruce (sqlwork.com)

"Jeff User" <je*******@hotmail.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.selectedIndex = 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.ddlLastName,
etc.. but can not get it to work.

My form contains
<ASP:dropdownlist id="ddlLastName"
runat="server" bla bla></asp:dropdownlist>

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_*************************@sqlwork.com> wrote:
you need to use the ClientId property of the controls to know the name. try:

function Clear_ddls()
{
document.getElementById('<%=ddlLastName.ClientId%> ').selectedIndex =
0;
}
-- bruce (sqlwork.com)

"Jeff User" <je*******@hotmail.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.selectedIndex = 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.ddlLastName,
etc.. but can not get it to work.

My form contains
<ASP:dropdownlist id="ddlLastName"
runat="server" bla bla></asp:dropdownlist>

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_*************************@sqlwork.com> wrote:
you need to use the ClientId property of the controls to know the name. try:

function Clear_ddls()
{
document.getElementById('<%=ddlLastName.ClientId%> ').selectedIndex =
0;
}
-- bruce (sqlwork.com)

"Jeff User" <je*******@hotmail.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.selectedIndex = 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.ddlLastName,
etc.. but can not get it to work.

My form contains
<ASP:dropdownlist id="ddlLastName"
runat="server" bla bla></asp:dropdownlist>

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
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...
1
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....
8
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...
4
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...
1
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...
1
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"...
3
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,...
2
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"...
6
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...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.