Hi,
I've put together this javascript taken from various sources, but i think it is wrong or missing something. If particular options are selected within a drop down menu, then the check botton will auto check and disable (grey out) at the same time. If seems like if will work fine but int he database it will wont show as selected, but if I manually check it, it will record fine in the DB so the form works, but not the javascript. Here is the code. i need help - i have no idea what is wrong.
<script language="JavaS cript"> function updateCheckBox () {
selectedItem = form1.scrp_arw. options [form1.scrp_arw. selectedIndex].value;
if (selectedItem != '') {
form1.scrp_home _cz.checked=tru e; form1.scrp_home _cz.disabled=tr ue; }
else {
form1.scrp_home _cz.disabled=fa lse form1.scrp_home _cv.checked=fal se;
}
}
updateCheckBox ();
</script>
8 10174 acoder 16,027
Recognized Expert Moderator MVP
Welcome to TSDN.
This may be a typo, but if the javascript is on one line, you should have a semi-colon. After the 'disabled=false ', you have a semi-colon missing.
I put the semi colon in and it did not make any different. I actually had it in the original code but when I pasted in my post above I forgot to add it.
Do you have any other suggestions? Would it have somoething to do with the fact that there are two things happening to the same field at the same time and it can't handle it properly, would there be a better way to write the javascript, for example combine the action (check & disable) at the same time rather than seperate them?
Would it have somoething to do with the fact that there are two things happening to the same field at the same time and it can't handle it properly...
nope... i'm pretty sure this is not the reason... try this: -
<script language="text/JavaScript">
-
-
function updateCheckBox ()
-
{
-
var selectedItem = form1.scrp_arw.options[form1.scrp_arw.selectedIndex].value;
-
if (selectedItem!="")
-
{form1.scrp_home_cz.checked=true; form1.scrp_home_cz.disabled=true;}
-
else
-
{form1.scrp_home_cz.disabled=false; form1.scrp_home_cv.checked=false;}
-
}
-
</script>
-
and i'm pretty sure you also need to define in your HTML code weather your checkbox is initially Checked/Unchecked and Disabled/Enabled for the javascript to use true and false...
nope... i'm pretty sure this is not the reason... try this:
It's not working for me. I would like to try it another way. If the checkbox is checked, then the dropdown menu is enabled. If the checkbox is NOT checked then the dropdown menu is Disabled. I don't know what the whole javascript would be. Hope you can help me.
Anyone can share javascript code for this, please.
If a checkbox is checked (default is unchecked), then a drop down list below it is enabled (that is not greyed out, the default is disabled – greyed out). If the user then unchecks the checkbox, then 2 things happen to the drop down menu, it is disabled (greyed out) and it’s value changes to an option with a value of nothing “”.
Hope someone can assist. I have not idea.
-
<html>
-
<head>
-
-
<script type="text/javascript">
-
function EnableSelectMenu()
-
{
-
if (document.getElementById('Checkbox').checked)
-
{document.getElementById('SelectMenu').disabled=false}
-
else
-
{document.getElementById('SelectMenu').disabled=true}
-
}
-
</script>
-
-
</head>
-
-
<body>
-
<form action="" method="get">
-
<p>
-
<input type="checkbox" name="Checkbox" id="Checkbox" value="checkbox" onClick="EnableSelectMenu();">
-
Check To Enable Select Menu </p>
-
<p>
-
<select name="SelectMenu" id="SelectMenu" disabled="disabled">
-
<option value="SelectionA">Selection A</option>
-
<option value="SelectionB">Selection B</option>
-
<option value="SelectionC">Selection C</option>
-
</select></p>
-
</form>
-
</body>
-
</html>
-
acoder 16,027
Recognized Expert Moderator MVP
I have merged the threads because they were on the same topic.
Did you solve your problem?
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: CJM |
last post by:
I've had some periodic problems on certain (intranet)servers where IIS seems
to be caching thing in an unexpected way, or is server cached pages where
new content is expected.
The first situation is where we have a standard Top + Left + Content
framset; the left frame contains a menu which shows standard options - when
the user logs in, extra menu options are available to them, depending on
their priveleges. The menu is generated from a...
|
by: ACaunter |
last post by:
Hi there,
can someone please tell me what the easiest way to have a dropdown menu bar
positioned on the screen
(eg. Home, company, ... , contact us)
then when the mouse goes over then, the sub menu options are displayed
thanks a lot
--
AdamPC@hotmail.com
|
by: YellowFin Announcements |
last post by:
Introduction
Usability and relevance have been identified as the major factors
preventing mass adoption of
Business Intelligence applications. What we have today are traditional
BI tools that don't work
nearly as well as they should, even for analysts and power users. The
reason they haven't
reached the masses is because most of the tools are so difficult to use
and reveal so little
|
by: balu435 |
last post by:
Hi friends,
I have an (VBA) application which programatically fills the options in a web page.
I have an dropdown menu whose options are selected during run-time by using a function.Is there anyway by which I can select the option in the dropdown menu programatically?
If the dropdown menu had its options explicitily mentioned (like <option value="1">1</option>...) I could have used document.form.objectname.selectedindex=n
But here all I...
|
by: William Youngman |
last post by:
I have a gridview displaying data and would like to use the AJAX dropdown extender so that when the user clicks on a record a dropdown menu will display providing the user with a menu of selections to choose from (yes much like the SharePoint 2007 dropdown menu).
I'm having problems dynamically binding the 'TargetControlID' property of the extender control to the record label in the gridview.
What I'm doing is -
The label's text is the...
| |
by: rakeshvthu |
last post by:
hi all,
can we disable the copy and paste option in edit menu bar of browser my customer does not want copying using any technique so can any one help
how to disable that options copy and paste in menu bar using java script
urgently required
loooking for quick response
|
by: bhanubalaji |
last post by:
hi,
I am unable to disable the text(label) in javascript..it's working fine with IE,but i am using MOZILLA..
can any one help regarding this..
What's the wrong with my code?
I am sending my code here..
Thanks in Advance...
Regards
|
by: Jim |
last post by:
Hi,
I have two questions/problems pertaining to CSS horizontal dropdown
menus and am hoping that someone here can help me out.
(1)
I'm having a problem centering the menu. I picked up the code for
this from a tutorial but that menu was flush-left justified. Not what
I want. Subsequent searches on google on how to center yielded a
|
by: ibeehbk |
last post by:
HI. I have a dropdown menu named arrivalcity (options are Rome, Naples, Palermo, and CAtania).
I also have 4 other dropdown menus which have departure dates for those cities.
Basically I want those 4 dropdown menus disabled by default. Then based on which arrivalcity
option they choose only one of those 4 dropdown menus gets enabled so they can select the departure date from the appropriate menu.
I know this can get accomplished in...
|
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...
|
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,...
| |
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,...
|
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...
|
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...
|
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();...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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...
| |