473,507 Members | 8,054 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Simple JavaScript question

Hi....I realize this is a really basic question....

I have a webform (in VS.NET 2005). It has (among other things) a
combobox and a command button. At the beginning, the command button
is disabled....on the selectedindexchanged event of the combobox, I
want to enable the command button

Only way I know to do it is in the code-behind .CS file with a
postback, but I'd rather do it with Javascript....except I really
don't know the syntax very well.

Assuming my two controls were cboItem and btnSave, what would the
syntax be (in the HTML) to enable btnSave when cboItem changes?

Thanks a lot in advance,
Kevin
Mar 12 '06 #1
2 1057
The way I would do it so as not to get the post back would be to make the
dropdown a html control then
the javascript would look like this

document.body.all.item("btnSave").disabled = false;
"Kevin S. Goff" <kgoff@commongroundsolutions> wrote in message
news:1s********************************@4ax.com...
Hi....I realize this is a really basic question....

I have a webform (in VS.NET 2005). It has (among other things) a
combobox and a command button. At the beginning, the command button
is disabled....on the selectedindexchanged event of the combobox, I
want to enable the command button

Only way I know to do it is in the code-behind .CS file with a
postback, but I'd rather do it with Javascript....except I really
don't know the syntax very well.

Assuming my two controls were cboItem and btnSave, what would the
syntax be (in the HTML) to enable btnSave when cboItem changes?

Thanks a lot in advance,
Kevin

Mar 12 '06 #2
Hi,

barry wrote:
The way I would do it so as not to get the post back would be to make the
dropdown a html control then
the javascript would look like this

document.body.all.item("btnSave").disabled = false;


Why not rather use the standard way to do this? The "all" property
exists only in IE and is a fossile from the past.

The DOM Level 2 way is:

<select onchange="document.getElementById('btnSave').disab led=false;">
....

Also, the combo doesn't have to be a HTML control. You can use an
ASP.NET listbox, with AutPostback = false, and use SetAttribute to set
the javascript code.

HTH,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
Private/Malaysia: http://mypage.bluewin.ch/lbugnion
Support children in Calcutta: http://www.calcutta-espoir.ch
Mar 12 '06 #3

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

Similar topics

2
1441
by: not | last post by:
Hello All, I am trying to develop a relatively simple self-quiz form in javascript, but I'm having no luck getting it to work. What I am looking for is a script that allow the user to select...
2
8374
by: Hazzard | last post by:
I just realized that the code I inherited is using all asp.net server controls (ie. webform controls) and when I try to update textboxes on the client side, I lose the new value of the textbox when...
0
1871
by: 42 | last post by:
I implemented a simple class inherited from Page to create a page template. It simply wraps some trivial html around the inherited page, and puts the inherited page into a form. The problem I...
1
1443
by: number1.email | last post by:
Hello, I have a simple Web Page Questionairre in which questions are read from a database, and the user can indicate the correct answer via either a radio input control or a dropdown list. The...
3
359
by: Shelly | last post by:
Hi, I really don't know javascript, though I can understand existing code. I know java, php, etc. Here is my question, and I assume it is simple. I have a page. On this page I have element_1...
6
2095
by: alex.kemsley | last post by:
Hi guys, I am trying to write a simple script in vain. I need it to first check to see if the cookie exists then if not write one with two variable var ref = document.referrer var page =...
4
1529
by: Brian Piotrowski | last post by:
Hi All, After many years of ASP 3.0, I am finally taking the plunge and moving to ASP.NET. I'm going through a few tutorials, and I'm wondering if someone can answer me a question on adding a...
13
2011
by: aum | last post by:
Hi, I'm a Python programmer, just starting to get into javascript. On reading some of the js guides, and not liking any of the OO usage patterns I saw, I've cooked up something which python...
7
1937
by: James Harris | last post by:
My Googling has let me down here - maybe because when it comes to Java I don't really know which type I need! If someone could point me in the right direction I'd appreciate it. My requirement...
5
1598
by: fussfart | last post by:
I'm trying to do something that should be very simple but isn't working! (I also want to do something somewhat more complicated, but that has to wait until I figure out the simple stuff.) First, I...
0
7223
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,...
0
7314
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,...
0
7372
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...
1
7030
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...
0
5623
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4702
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...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
758
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
411
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...

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.