473,544 Members | 2,437 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem with disabled select

263 Contributor
Problem with disabled select

Hi all.

I have this form:

Expand|Select|Wrap|Line Numbers
  1. <select size="1" name="FRG_FNC">
  2.             <option value="">Select value</option>
  3.             <option value="FRC">FRG</option>
  4.             <option value="FNC">FNC</option>
  5.             <option value="No">No</option>
  6. </select>
  7.  
  8.  
  9. <select size="1" name="core" onchange="var cc = this.options[this.selectedIndex].value; if(cc=='No')Forum();">          
  10.                   <option value="">Select value</option>
  11.                   <option value="Yes">Yes</option>
  12.                   <option value="No">No</option>
  13. </select>
  14.  
  15. <input type="text" name="code" size="10" readonly value="-"></p>
I need:

1) if value = No in the select name="FRG_FNC" disabled the select name="core" and the input type="text" name="code"

2) if value = No in the select name="FRG_FNC" assign a default value in the select name="FRG_FNC" and the input type="text" name="code"


Can you help me?
Aug 27 '08 #1
5 1252
gits
5,390 Recognized Expert Moderator Expert
i'm quite unsure about your 2. point ... you want to select 'NO' in the first select ... the value should be switched to another one? then the point 1 is quite obsolete since you will not need the 'NO'-option there? may be i just don't get it right? ... or you mean the 'core'-select here in point 2.?

kind regards
Aug 27 '08 #2
viki1967
263 Contributor
Problem solved thanks; I change the data form
kind regards and thanks x your reply.
Aug 28 '08 #3
gits
5,390 Recognized Expert Moderator Expert
glad to hear you solved your problem ... may be you could just drop a short note regarding your solution ... just for the users that may find this thread in the future and have a similar problem?

kind regards
Aug 28 '08 #4
viki1967
263 Contributor
glad to hear you solved your problem ... may be you could just drop a short note regarding your solution ... just for the users that may find this thread in the future and have a similar problem?

kind regards
Ok, no problem.

Some people won't like me using id values here but I will in this case for simplicity's sake:

Expand|Select|Wrap|Line Numbers
  1. <select id="FRG_FNC" size="1" name="FRG_FNC">
  2.             <option value="">Select value</option>
  3.             <option value="FRC">FRG</option>
  4.             <option value="FNC">FNC</option>
  5.             <option value="No">No</option>
  6. </select>
  7.  
  8.  
  9. <select id="core" size="1" name="core">          
  10.                   <option value="">Select value</option>
  11.                   <option value="Yes">Yes</option>
  12.                   <option value="No">No</option>
  13. </select>
  14.  
  15. <input id="code" type="text" name="code" size="10" readonly value="-"
  16.  
In an external .js file which you'll link to in the head of your html page write:

Expand|Select|Wrap|Line Numbers
  1. window.onload = initSelects;
  2.  
  3. function initSelects()   {
  4.    var sel1 = document.getElementById("FRG_FNC");
  5.    if (sel1)   {
  6.       sel1.onchange = sel1Change;
  7.    }
  8.    var sel2 = document.getElementById("core");
  9.    if (sel2)   {
  10.       sel2.onchange = sel2Change;
  11.    }
  12. }
  13. function sel1Change()   {
  14.    var sel2 = document.getElementById("core");
  15.    var code = document.getElementById("code");
  16.    if (this.selectedIndex === 3)   {
  17.       sel2.selectedIndex = 2;
  18.       sel2.disabled = true;
  19.       code.value = "default";
  20.       code.disabled = true;
  21.    } else   {
  22.       sel2.selectedIndex = 0;
  23.       sel2.disabled = false;
  24.       code.value = "";
  25.       code.disabled = false;     
  26.    }
  27. }
  28. function sel2Change()   {
  29.    var cc = this.options[this.selectedIndex].value;
  30.    if(cc === 'No') Forum();
  31. }
  32.  
kind regards
viki
Aug 28 '08 #5
gits
5,390 Recognized Expert Moderator Expert
thanks for sharing your solution :)

kind regards
Aug 28 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

6
7911
by: harry | last post by:
Hi, I have a program that runs on multiple client pc's. Occasionally one or more of those pc's use VPN to connect to another corporate network. When using VPN they need to set proxy server in Internet Explorer connection settings (proxy:8080). However, as soon as this setting is enabled, the remoting program running on their pc stops...
12
7280
by: Pudlik, Szymon | last post by:
Hi, I've written some code: function onSubmit(form){ for (var i = 0; i < form.elements.lenght; i++){ if (form.elements.disabled == 1) form.elements.disabled = 0; }
1
3442
by: novice_developer | last post by:
Hi All, there is a radiobuttonlist having 2 list items (state & zipcode). when i select state radiobutton the zipcode textbox should be disabled and when i select a zipcode radiobutton the state textbox should be disabled. And i need to handle this in client side only. i'm not able to call a javascript function for radiobuttonlist. can...
5
2580
by: comshiva | last post by:
Hi all, I have converted my existing ASP.NET project from 1.1 to 2.0 and i have found that everything works fine except the linkbutton control in my datagrid which throws an javascript error when clicked. I thought the control might be the problem, so i deleted the old control and binded the new linkbutton control but am still getting the...
0
3314
by: mathewgk80 | last post by:
HI all, I am having popup calendar Javascript code. But i dont know how it is connecting to asp.net code.. I am using asp.net,c#.net and also using 3tier architecture with master page.... I would like to get the code for connecting the javascript to asp.net page... Please help me... The javascript code is as follows..
3
1015
by: lolodede | last post by:
hi i have trouble with disabled the select list when any of checkboxes is not checked and enable if one of them is checked this is my code <script type="text/javascript"> <!-- function Select() { if (document.getElementById('one').checked ) {document.getElementById('class').disabled=false } if else...
2
3817
by: viki1967 | last post by:
Hi everyone. My form page htm: <html> <head> <script language="javascript"> function controlla_combo() { document.form1.Nacionalidad_text.disabled = document.form1.Nacionalidad.checked;
4
1989
pradeepjain
by: pradeepjain | last post by:
i had posted the same code in javascript area !! this i am posting bcos of different problem. as you can see in ma code there is a dropdown called sort ...its sorts the result by the value he selects . its working fine... say a user selects price as the sort thing . so it lists all mobiles with its price range with mobile in some range together ....
7
2287
by: viki1967 | last post by:
I need one function javascript that: 1) when I enter in this htm page I see enabled only checkbox of categories A, M and T; checkboxes of microcategories all disabled; 2-a) If I select the checkbox of macrocategory A, M and T checkboxes all disabled; 2-b) If I select the checkbox of macrocategory M, A and T checkboxes all disabled; 2-c)...
0
7374
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...
0
7783
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...
0
5931
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...
1
5309
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...
0
3430
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...
0
3422
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1850
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
1
996
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
677
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...

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.