473,748 Members | 11,134 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to disable a multiple selection control using javascript

I have a script like below:

------------------------------------------------------------------------------------------------------------------------

<html>
<head>
<title>TEST</title>
<script language="javas cript>
<!--
function masking () {
var aForm = window.document .aForm;
if (aForm.build_ty pe.value == "A")
aForm.selected_ ae.disabled = true;
else
aForm.selected_ ae.disabled = false;
}
// -->
</script>
</head>
<body>
<form method="post" name="aForm">
<select name="build_typ e" size=1 onchange="maski ng()">
<option value="A">STD</option>
<option value="B">NON-STD</option>
</select>
<select name="selected_ ae[]" size="3" multiple>
<option value="james">J ames</option>
<option value="john">Jo hn</option>
<option value="jimmy">J immy</option>
<option value="jason">J ason</option>
</select>
</form>
</body>
</html>

------------------------------------------------------------------------------------------------------------------------

I tried to disable a multiple selection control using Javascript but it
did not work. Can anyone please help me? Thanks in advance for your
help.

Feb 27 '06 #1
2 4535
gg****@gmail.co m wrote:
I tried to disable a multiple selection control using Javascript but
it did not work. Can anyone please help me? Thanks in advance for your
help.
Several things need fixed:
<script language="javas cript>
<script type="text/javascript">
<!--
Don't use this
function masking () {
var aForm = window.document .aForm;
if (aForm.build_ty pe.value == "A")
aForm.selected_ ae.disabled = true;
else
aForm.selected_ ae.disabled = false;
}
function masking(o) {
var isA = (o.options[o.selectedIndex].value=="A");
o.form.elements['selected_ae[]'].disabled = isA;
}
// -->
Don't use this
<select name="build_typ e" size=1 onchange="maski ng()">


<select name="build_typ e" size="1" onchange="maski ng(this)">

Make the above changes and your code will both work and be better written.
Hope that helps.

--
Matt Kruse
http://www.JavascriptToolbox.com
http://www.AjaxToolbox.com
Feb 27 '06 #2
Thanks a lot for your help, Matt.
It really works!!!

Feb 28 '06 #3

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

Similar topics

0
3027
by: Joe Helmick | last post by:
This one has me really stumped, so I thought I'd ask publicly. I was trying to take my ASP.NET web page "template" -- banner graphic, small navigation bar, and user feedback message area -- and make it into a user control. I wanted to stretch one of the graphics so it always went all the way across the browser window. So far, so good... And then, I wanted to take the two-cell table that holds the naviagation bar and make it always...
1
1636
by: john | last post by:
I have two different problems: 1. When the user has clicked on a button that is causing the browser to post back to the server, it could take a little while for the new page to show up. So in the mean time, I want to change the cursor to an hourglass and disable all of the controls on the form using javascript so the user can't do anything with any of the controls on the page. But when I disable certain controls (e.g. text boxes, radio...
1
1084
by: Eric Caron | last post by:
Hi everybody, I have a form where I have checkbox that triggers javascript code to make a div appear. This is when the user selects "Other" in the list of choices and we ask him to specify his choice using a textbox control. Now if the user has selected the "Other" choice, the entry of the information in the textbox is mandatory, so I want to be able to enable the RequiredFieldValidator associated with the field. In the event when the...
8
5731
by: Adam | last post by:
Hey, I'm using JS to submit a form with image submit buttons, using the following code... (Page is here... http://www.cards2do.co.uk/addcard.php?card_id=292 ) ************************************************************************************** <form action="https://www.cards2do.co.uk/addcard.php" method="post"
1
2186
by: Leszek | last post by:
Hi I have user-side javascript that validates a form. And I have server-side php script thad does the same. Is it possible to disable php script from showing messages about missing values if javascrpt did it before?? i have <div id='wrong"></div> that contains these messages. So I tried to set style.display='none' but it seems that it doesn't work. I guess this is because javascript first sets style.display='none' but it
2
3173
by: kplkumar | last post by:
I have created a asp.net date picker control using Javascript. I wanted to do this to avoid doing post back when the calendar window is launched. It works like charm. But the challenge is - the control does not use any asp.net controls like button or textfield. It uses html "input" for the text field and the button. So after the user has choosen the date and the date is populated in the textfield, I am not able to get the value from the...
1
2400
by: gopalpawar7 | last post by:
how to disable Save as option using java script?
0
9537
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...
1
9319
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9243
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...
0
8241
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6795
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
6073
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
4599
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3309
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
2213
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.