Connecting Tech Pros Worldwide Help | Site Map

Problem with disabled select

  #1  
Old August 27th, 2008, 02:54 PM
Familiar Sight
 
Join Date: Oct 2007
Posts: 250
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?
  #2  
Old August 27th, 2008, 10:28 PM
gits's Avatar
Moderator
 
Join Date: May 2007
Location: Munich, Germany
Posts: 4,102
Provided Answers: 1

re: Problem with disabled select


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
  #3  
Old August 28th, 2008, 08:53 AM
Familiar Sight
 
Join Date: Oct 2007
Posts: 250

re: Problem with disabled select


Problem solved thanks; I change the data form
kind regards and thanks x your reply.
  #4  
Old August 28th, 2008, 08:57 AM
gits's Avatar
Moderator
 
Join Date: May 2007
Location: Munich, Germany
Posts: 4,102
Provided Answers: 1

re: Problem with disabled select


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
  #5  
Old August 28th, 2008, 09:31 AM
Familiar Sight
 
Join Date: Oct 2007
Posts: 250

re: Problem with disabled select


Quote:
Originally Posted by gits
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
  #6  
Old August 28th, 2008, 11:08 AM
gits's Avatar
Moderator
 
Join Date: May 2007
Location: Munich, Germany
Posts: 4,102
Provided Answers: 1

re: Problem with disabled select


thanks for sharing your solution :)

kind regards
Reply


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with input type radio and select name viki1967 answers 2 August 15th, 2009 09:43 AM
New with ADO in vb6 (Problem with .Edit) atzthegreat answers 3 August 12th, 2008 04:27 PM
problem with fetch rows saeedeh answers 6 September 4th, 2006 10:16 AM
Problem with form.elements.lenght Pudlik, Szymon answers 12 August 5th, 2005 05:55 PM