473,468 Members | 3,847 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Disable field input type in the form

263 Contributor
Hi there.

I have this form with three fields:

Expand|Select|Wrap|Line Numbers
  1. <HTML>
  2. <HEAD>
  3.  
  4. <script language="javascript">
  5. <!--
  6.  
  7.  
  8.  function ApriPopup(larg,alte,url) 
  9.  
  10. var w = screen.width; 
  11. var h = screen.height;
  12.  
  13. var x = Math.round(w / 2) - Math.round(larg / 2); 
  14. var y = Math.round(h / 2) - Math.round(alte / 2); 
  15.  
  16. window.open(url,'','width='+larg+',height='+alte+',top='+y+',left='+x+''); 
  17.  
  18.  
  19. //-->
  20. </script>
  21.  
  22. </HEAD>
  23.  
  24. <BODY> 
  25.  
  26. <form method="POST" action="test.asp">
  27.  
  28.   <select size="1" name="Stato">
  29.   <option>Seleziona</option>
  30.   <option value="Assente">Assente</option>
  31.   <option value="Presente">Presente</option>
  32.   </select>
  33.  
  34.   <select size="1" name="Stato_g">
  35.   <option>Seleziona</option>
  36.   <option value="Ferie">Ferie</option>
  37.   <option value="Malattia">Malattia</option>
  38.   <option value="In sede">In sede</option>
  39.   <option value="Fuori sede">Fuori sede</option>
  40.   </select>  
  41.  
  42. <input type="text" name="ore" size="20">
  43. <a href="javascript:ApriPoup(500,500,'popup.asp');">
  44.     <img border="0" src="apripopup.gif" width="12" height="12"></a>
  45.  
  46. </form>
  47.  
  48. </BODY>
  49. </HTML>
  50.  
  51.  
I have to disable the field input type="text" name="ore" AND the link <a href="javascript:ApriPoup(500,500,'popup.asp');"> when the select "Stato" value "Assente".

Help please, thanks regards
Viki1967
Mar 7 '08 #1
17 2159
hsriat
1,654 Recognized Expert Top Contributor
Add a function onchange of Stato. In that function, if value of Stato is Assente, disable all the thing you require to disable, and if value is not Assente, enable them back.

You may not disable the link, so set its href to "#" or "javascript:void(0)" instead.
Mar 7 '08 #2
viki1967
263 Contributor
Thanks, but one example ?
Mar 7 '08 #3
hsriat
1,654 Recognized Expert Top Contributor
Expand|Select|Wrap|Line Numbers
  1. function disOrEnb(sel) {
  2.     document.forms[0].ore.disabled = sel.value == 'Assente' ? true : false;
  3.     document.getElementById('link').href = sel.value == 'Assente' ? 'javascript:void(0)' : 'javascript:ApriPoup(500,500,\'popup.asp\')';
  4. }
Add onchange="disOrEnb(this)" to the select tag.
Mar 8 '08 #4
viki1967
263 Contributor
Thanks, but sorry not working:

http://www12.asphost4free.com/viki1967/form.htm

Expand|Select|Wrap|Line Numbers
  1. <HTML>
  2. <HEAD>
  3.  
  4. <script language="javascript">
  5. <!--
  6.  
  7.  
  8.  function ApriPopup(larg,alte,url) 
  9.  
  10. var w = screen.width; 
  11. var h = screen.height;
  12.  
  13. var x = Math.round(w / 2) - Math.round(larg / 2); 
  14. var y = Math.round(h / 2) - Math.round(alte / 2); 
  15.  
  16. window.open(url,'','width='+larg+',height='+alte+',top='+y+',left='+x+''); 
  17.  
  18.  
  19. function disOrEnb(sel) {
  20.     document.forms[0].ore.disabled = sel.value == 'Assente' ? true : false;
  21.     document.getElementById('link').href = sel.value == 'Assente' ? 'javascript:void(0)' : 'javascript:ApriPoup(500,500,\'popup.asp\')';
  22. }
  23.  
  24.  
  25. //-->
  26. </script>
  27.  
  28. </HEAD>
  29.  
  30. <BODY> 
  31.  
  32. <form method="POST" action="test.asp">
  33.  
  34.   <select size="1" name="Stato" onchange="disOrEnb(this)">
  35.   <option>Seleziona</option>
  36.   <option value="Assente">Assente</option>
  37.   <option value="Presente">Presente</option>
  38.   </select>
  39.  
  40.   <select size="1" name="Stato_g">
  41.   <option>Seleziona</option>
  42.   <option value="Ferie">Ferie</option>
  43.   <option value="Malattia">Malattia</option>
  44.   <option value="In sede">In sede</option>
  45.   <option value="Fuori sede">Fuori sede</option>
  46.   </select>  
  47.  
  48. <input type="text" name="ore" size="20">
  49. <a href="javascript:ApriPoup(500,500,'popup.asp');">
  50.     <img border="0" src="php/modifica.gif" width="12" height="12"></a>
  51.  
  52. </form>
  53.  
  54. </BODY>
  55. </HTML>
  56.  
  57.  
Mar 8 '08 #5
hsriat
1,654 Recognized Expert Top Contributor
Make this change...

<a id="link" href="javascript:ApriPoup(500,500,'popup.asp');">
Mar 8 '08 #6
viki1967
263 Contributor
Thanks.

When "Stato" is "Presente" not working:

http://www12.asphost4free.com/viki1967/form.htm
Mar 8 '08 #7
hsriat
1,654 Recognized Expert Top Contributor
Thanks.

When "Stato" is "Presente" not working:

http://www12.asphost4free.com/viki1967/form.htm
In this link I can see it is working!!

Which browser are you using?
Mar 8 '08 #8
viki1967
263 Contributor
I use Internet Explorer, this is error:

Stato = Presente
Stato_g = Ferie

If you click on image modifica.gif:

Mar 8 '08 #9
viki1967
263 Contributor
Yes !!!

Expand|Select|Wrap|Line Numbers
  1. 'javascript:ApriPoup(500,500,\'popup.asp\')';
  2.  
Expand|Select|Wrap|Line Numbers
  1. 'javascript:ApriPopup(500,500,\'popup.asp\')';
  2.  

Not ApriPoup but ApriPopup

THANKS !!!!!!
Bye
Mar 8 '08 #10
viki1967
263 Contributor
Sorry, it's possible change image src="php/modifica.gif" with src="php/NoModifica.gif" when stato = Assente ?
Mar 8 '08 #11
hsriat
1,654 Recognized Expert Top Contributor
Sorry, it's possible change image src="php/modifica.gif" with src="php/NoModifica.gif" when stato = Assente ?
yeah, add this similarly to the existing function.
Mar 8 '08 #12
viki1967
263 Contributor
Sorry, I dont know... :(
Mar 8 '08 #13
hsriat
1,654 Recognized Expert Top Contributor
Sorry, I dont know... :(
Here is an example which can help you.
Mar 8 '08 #14
viki1967
263 Contributor
Thanks, but as edit function disOrEnb ?
Mar 8 '08 #15
viki1967
263 Contributor
I write this, but is not working:

Expand|Select|Wrap|Line Numbers
  1.  
  2. <HTML>
  3. <HEAD>
  4.  
  5. <script language="javascript">
  6. <!--
  7.  
  8.  
  9.  function ApriPopup(larg,alte,url) 
  10.  
  11. var w = screen.width; 
  12. var h = screen.height;
  13.  
  14. var x = Math.round(w / 2) - Math.round(larg / 2); 
  15. var y = Math.round(h / 2) - Math.round(alte / 2); 
  16.  
  17. window.open(url,'','width='+larg+',height='+alte+'  ,top='+y+',left='+x+''); 
  18.  
  19.  
  20. function disOrEnb(sel) {
  21.  
  22.     document.forms[0].ore.disabled = sel.value == 'Assente' ? true : false;
  23.     document.getElementById('link').href = sel.value == 'Assente' ? 'javascript:void(0)' : 'javascript:ApriPopup(500,500,\'popup.asp\')';
  24.     document.getElementById('b1').src = sel.value == 'Assente' == "chiudi_button.gif";
  25. }
  26.  
  27.  
  28. //-->
  29. </script>
  30.  
  31. </HEAD>
  32.  
  33. <BODY> 
  34.  
  35. <form method="POST" action="test.asp">
  36.  
  37.   <select size="1" name="Stato" onchange="disOrEnb(this)">
  38.   <option>Seleziona</option>
  39.   <option value="Assente">Assente</option>
  40.   <option value="Presente">Presente</option>
  41.   </select>
  42.  
  43.   <select size="1" name="Stato_g">
  44.   <option>Seleziona</option>
  45.   <option value="Ferie">Ferie</option>
  46.   <option value="Malattia">Malattia</option>
  47.   <option value="In sede">In sede</option>
  48.   <option value="Fuori sede">Fuori sede</option>
  49.   </select>  
  50.  
  51.  
  52. <input type="text" name="ore" size="20">
  53. <a id="link" href="javascript:ApriPoup(500,500,'popup.asp');">
  54.  
  55.     <img border="0" id="b1" src="invia_button.gif"></a>
  56.  
  57. </form>
  58.  
  59. </BODY>
  60. </HTML>
  61.  
Mar 8 '08 #16
hsriat
1,654 Recognized Expert Top Contributor
This is not the right syntax, use this:
Expand|Select|Wrap|Line Numbers
  1. document.getElementById('b1').src = sel.value == 'Assente' ? 'button1.gif' : 'button2.gif';
This syntax should be in the form:

var a = condition ? b : c;


This means if condition is true, a = b, else a = c
Got it?
Mar 9 '08 #17
viki1967
263 Contributor
Many thanks...

Regards,
Viki1967
Mar 9 '08 #18

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

Similar topics

2
by: HolaGoogle | last post by:
Hi all, Can you please tell me what's wrong with my code??? i do have this database in wich i have to field.One is a "yes/no" field and another one is "number" field. To display the yes/no field...
2
by: HolaGoogle | last post by:
Can you please tell me the right way to do this?? it's realy important! thanks in advance... Hi all, Can you please tell me what's wrong with my code??? i do have this database in wich i have...
12
by: Forti2ude | last post by:
Hello, I have a simple form... <form> <select name="foo" multiple> <option value="1">one</option> <option value="2">two</option> <option value="3">three</option> </select>
2
by: techfuzz | last post by:
I scoured this group and others looking for the best way to disable a button after the first click to prevent multiple submissions, but never did find anything that worked like they said it would. ...
4
by: kschneider | last post by:
Assume there's a form with it's action attribute all set to post to a URL, but without a submit control. Form submission is done via a link and I want to prevent the classic "double submit"....
6
by: Mike | last post by:
I have a form that contains 240 "products". Each Product has a TR. Each TR contains a Yes and No radio button and a Product-Qty text input. A situation exists where I have to go through all the...
9
by: surf_doggie | last post by:
Im not sure if this is the group to post in, if anyone knows a more appropriate one please let me know. Please consider the following example of a feature most all browsers have that I would...
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
marktang
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,...
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...
0
tracyyun
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...
0
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,...
0
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...
0
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...
0
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 ...

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.