473,320 Members | 1,948 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,320 software developers and data experts.

Problem with disabled select

263 100+
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 1246
gits
5,390 Expert Mod 4TB
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 100+
Problem solved thanks; I change the data form
kind regards and thanks x your reply.
Aug 28 '08 #3
gits
5,390 Expert Mod 4TB
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 100+
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 Expert Mod 4TB
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
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...
12
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
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...
5
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...
0
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...
3
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() ...
2
by: viki1967 | last post by:
Hi everyone. My form page htm: <html> <head> <script language="javascript"> function controlla_combo() { document.form1.Nacionalidad_text.disabled =...
4
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...
7
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...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
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: 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...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
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)...
0
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...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

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.