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

Problem with input type radio and select name

263 100+
Hi everyone.

My form page htm:

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3.     <script language="javascript">
  4.         function controlla_combo()
  5.         {
  6.             document.form1.Nacionalidad_text.disabled = document.form1.Nacionalidad[0].checked;
  7.             document.form1.Nacionalidad_text.disabled = document.form1.Nacionalidad[1].checked;
  8.         }
  9.     </script>
  10. </head>
  11. <body>
  12.     <form name="form1" action="insert.jsp" method=post> 
  13.     <table>
  14.         <tr>
  15.             <td><input type="radio" name="Nacionalidad" value="1" onclick="controlla_combo();" CHECKED></td>
  16.             <td><input type="radio" name="Nacionalidad" value="0" onclick="controlla_combo();"></td>
  17.             <td><input type="radio" name="Nacionalidad" value="2" onclick="controlla_combo();"></td>
  18.             <td>
  19.                 <select name="Nacionalidad_text" disabled>
  20.  
  21.     <OPTION VALUE="MX">México</OPTION>
  22.     <OPTION VALUE="IT">Italia</OPTION>
  23.     <OPTION VALUE="ES">España</OPTION>
  24.  
  25.                 </select>
  26.             </td>
  27.         </tr>
  28.     </table>
  29.     </form>
  30. </body>
  31. </html>
I need this:

1) If checked input type="radio" name="Nacionalidad" value="1" the select name="Nacionalidad_text" is DISABLE;

2) If checked input type="radio" name="Nacionalidad" value="0" the select name="Nacionalidad_text" is DISABLE;

3) If checked input type="radio" name="Nacionalidad" value="2" the select name="Nacionalidad_text" is ENABLE;


The function function controlla_combo() NOT working... :

1) If checked input type="radio" name="Nacionalidad" value="1" the select name="Nacionalidad_text" is ENABLE;

2) If checked input type="radio" name="Nacionalidad" value="0" the select name="Nacionalidad_text" is DISABLE;

3) If checked input type="radio" name="Nacionalidad" value="2" the select name="Nacionalidad_text" is ENABLE;

Can you help me ?
Aug 14 '09 #1
2 3807
Dormilich
8,658 Expert Mod 8TB
your approach to the function is totally wrong. if you want the select enabled, check which radio is checked. (this requires a condition to be tested, thus use if () )
Aug 14 '09 #2
viki1967
263 100+
OK, thanks x your answer. This code working: :)

Expand|Select|Wrap|Line Numbers
  1. <html> 
  2.     <head> 
  3.     <title>prova</title> 
  4.     <script type='text/javascript'> 
  5.         function controlla(valore) 
  6.         { 
  7.             if(valore==2) 
  8.             { 
  9.                 document.mioform.Nazionalità_text.disabled=false; 
  10.             } 
  11.             else 
  12.             { 
  13.                 document.mioform.Nazionalità_text.disabled=true; 
  14.             } 
  15.         } 
  16.  
  17.  
  18.  
  19. function submIt(theform) 
  20.  
  21.             var selObj = document.mioform.Nazionalità_text; 
  22.             var selIndex = selObj.selectedIndex; 
  23.             if(selIndex==0  && document.mioform.Nazionalità_text.disabled==true) 
  24.             { 
  25.                 return true; 
  26.             } 
  27.             else if(selIndex ==0 && document.mioform.Nazionalità_text.disabled==false) 
  28.             { 
  29.                 alert("OBBLIGATORIO"); 
  30.                 mioform.Nazionalità_text.focus(); 
  31.                 return false; 
  32.             } 
  33.  
  34.  
  35.  
  36.   return(true);
  37. }        
  38.     </script> 
  39.     </head> 
  40.  
  41.     <body onload="controlla(0)"> 
  42.         <form id="mioform" name="mioform" method="post" onsubmit="return submIt(this);"> 
  43.  
  44.             A <input onclick="controlla(this.value);" type="radio" name="Nazionalità" value="1" CHECKED><br> 
  45.             B <input onclick="controlla(this.value);" type="radio" name="Nazionalità" value="0"><br> 
  46.             C <input onclick="controlla(this.value);" type="radio" name="Nazionalità" value="2"><br> 
  47.             <br><br> 
  48.             <SELECT NAME="Nazionalità_text" SIZE="1"> 
  49.             <OPTION VALUE="">---------------------------</OPTION> 
  50.             <OPTION VALUE="IT">Italiana</OPTION> 
  51.             </SELECT> 
  52.  
  53.             <input type="submit" value="Invia" name="B1">
  54.  
  55.         </form> 
  56.     </body> 
  57. </html>
  58.  
Aug 15 '09 #3

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

Similar topics

3
by: Robert Dell | last post by:
I have a problem comparing strings in an order form i'm writing. I want to give a running total at the bottom of the page and it appears to be working except it doesn't compare correctly (it...
12
by: Randell D. | last post by:
Folks, I have a form called "ourTestForm". Its a test form - nothing special - it contains five input tags - they are named one, two, three, four and five. The input tags are of type...
0
by: jianxin9 | last post by:
Hi everyone, I don't have a lot of experience with ASP and I was hoping someone could help me. I want to use our ASP form along with some javascript code to create a form where our patrons can...
1
by: ahmurad | last post by:
Dear all, I am new group user, computer science graduate; just have joined this established group and thanks to all. I am working in network field but so much interested in web (PHP) field. Recently...
3
by: judge82 | last post by:
Please I need help with this so bad. I have been struggling with it for 2weeks now. on line 206, I what to create a link that will direct you to the detail of the chosen items, like in the...
1
by: volynetsv | last post by:
Hello. I have a small problem, here's code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html...
1
by: tcertain | last post by:
I am totally duh at javascript although I have 2 books trying to learn it. I am trying to add values to a form and have a calculate total at end. this is my form script. I have hours at end of...
2
by: swethak | last post by:
Hi, I am getting the problem the problem with google map in Internet Explorer. This map worked fine in mozilla . When i opened the same map in Internet Explorer i am getting the error...
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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...

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.