473,806 Members | 2,661 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how can I disable and enable input type?

idsanjeev
241 New Member
Hi
its urgent
how can enable and desable the input field with condition like
if rs("field")=1 then
desable
elseif re("field")=2 then
enable
end if
and that after chek if the input type is enable then manadatory field can't null
thanks
Jan 12 '08
33 3543
gits
5,390 Recognized Expert Moderator Expert
then we have to do some adaptions, here are the step-by-step hints:

1. give your input node an id and change the function accordingly ... so replace 'your_input_nod e_id' with your id

2. add the onchange-attribute the way i showed you

3. watch the magic ;)

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2.     function toggle_state(obj) {
  3.         // here we check the value of your select-box
  4.         var val = obj.value == 'cartridge';
  5.  
  6.         var input_node = document.getElementById('your_input_node_id');
  7.  
  8.         input_node.style.visibility = val ? 'hidden' : 'visible';
  9.     }
  10. </script>
  11.  
kind regards
Jan 16 '08 #11
idsanjeev
241 New Member
Expand|Select|Wrap|Line Numbers
  1.  
  2. <b>Purpose( In case of CD/FLOPPY )</b> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  3.   <input type="text" name="purpose" id="purpose"  style="width:400px" maxlength="150"></td></tr>
  4.  
Expand|Select|Wrap|Line Numbers
  1.    <script language="javascript">
  2.   function toggle_state(obj) {
  3.         // here we check the value of your select-box
  4.         if var val = obj.value == 'cartridge'; 
  5.  
  6.         var input_node = document.getElementById('purpose');
  7.  
  8.         input_node.style.visibility = val ? 'hidden' : 'visible';
  9.     }
  10.  
  11.   </script>
  12.  
i chnges it like this is the incorrect if not then no magic
Jan 16 '08 #12
gits
5,390 Recognized Expert Moderator Expert
did you add the onchange:

[HTML]<select name="my_name" onchange="toggl e_state(this);" >[/HTML]
to your select-box too?

kind regards
Jan 16 '08 #13
idsanjeev
241 New Member
hi
ya use this
[HTML]<option Value="<%=RSITE M("Item_code")% >" onchange="toggl e_state(this);" ><%=RSITEM("Ite m_desc")%></option>[/HTML]
Jan 16 '08 #14
gits
5,390 Recognized Expert Moderator Expert
hi ...

there is an error here, i overlooked it the first time, sorry, your adaption has the following error:

Expand|Select|Wrap|Line Numbers
  1. if var val = obj.value == 'cartridge';
you don't need the if here ;)

kind regards
Jan 16 '08 #15
idsanjeev
241 New Member
hi
very fun today i am confuse how can solve it
my code is very long there are 286 line if you have some time then i send you my full code i there is any problems or i don't use the code provided in properway so please all works i don't know javascript
Jan 16 '08 #16
gits
5,390 Recognized Expert Moderator Expert
Expand|Select|Wrap|Line Numbers
  1.  
  2. <b>Purpose( In case of CD/FLOPPY )</b> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  3.   <input type="text" name="purpose" id="purpose"  style="width:400px" maxlength="150"></td></tr>
  4.  
Expand|Select|Wrap|Line Numbers
  1.    <script language="javascript">
  2.   function toggle_state(obj) {
  3.         // here we check the value of your select-box
  4.         if var val = obj.value == 'cartridge'; 
  5.  
  6.         var input_node = document.getElementById('purpose');
  7.  
  8.         input_node.style.visibility = val ? 'hidden' : 'visible';
  9.     }
  10.  
  11.   </script>
  12.  
i chnges it like this is the incorrect if not then no magic
have a look at the line 4 ... you added an if here ... that is useless, so simply remove it and it should work ...

sending the code is not a good idea, may be you have a link to a testpage?

kind regards
Jan 16 '08 #17
idsanjeev
241 New Member
Hi Gits
I know that
but here is know file attachment option i am only online 1/2 hour tomorrow from morning 8 am ok
one more page but i send you only first page where first work is done
thanks
Jan 16 '08 #18
gits
5,390 Recognized Expert Moderator Expert
hi ...

in your code you have:

Expand|Select|Wrap|Line Numbers
  1.       <td Width="15%"><select Id="SEL_ITEM" Name="SEL_ITEM" Size="1">
  2.         <option Selected Value>Select Item</option>
  3. <%
  4. Set RSITEM = CON.EXECUTE("SELECT * FROM CONSUM_ITEMS ORDER BY Item_code")
  5. %>
  6. <%
  7. Do While Not RSITEM.EOF
  8. %>        <option Value="<%=RSITEM("Item_code")%>" onchange="toggle_state(this);"><%=RSITEM("Item_desc")%></option>
  9.  
change in a way that the onchange is added to the select-element like:

Expand|Select|Wrap|Line Numbers
  1. <select Id="SEL_ITEM" Name="SEL_ITEM" Size="1" onchange="toggle_state(this);">
  2.  
the onchange mustn't be added to the option-element

kind regards
Jan 16 '08 #19
idsanjeev
241 New Member
hi ...

I Used your code but it not work when select option is selected automatic show input field and hide input field based on option
Jan 17 '08 #20

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

Similar topics

2
9749
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 in my asp form i use a checkbox and fot he other field i use a normal text box. if the yes/no field is checked then the other field is enabled otherwise it has to be disabled.Here's what i've done so far: Do While Not ObjRS.EOF <td><input...
2
6474
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 to field.One is a "yes/no" field and another one is "number" field. To display the yes/no field in my asp form i use a checkbox and fot he other field i use a normal text box. if the yes/no field is checked then the other field is enabled...
12
8901
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>
1
2473
by: Manatee | last post by:
Hi group. I have exactly one external, alternate stylesheet that I want to enable or disable by form controls, on one page only (not saved across pages). I used: <link rel="alternate stylesheet" id="style-compact" etc...> <input name="view" type="radio" onclick="document.getElementById('style-compact').disabled=false">
1
4258
by: hortoristic | last post by:
We are using JavaScript to Enable/Disable certain fields on web pages based on business rules. A simple example is if when using an option type tag, and the two options are Yes and No. If YES is selected - enable a field to use the M$ Datepicker. Using the code below works for most of our fields, however the problem is that when the field is re-enabled - it remembers the original date or data prior to it being disabled - despite the...
2
26379
by: Kevin | last post by:
I've been looking all over and I can't seem to find what ought to be simple. I need to disable a drop down when a checkbox is checked, and enable it when same checkbox is unchecked. I've found any number of scripts to disable / enable a drop down but they are all made to work with 2 different buttons, radio group selections, etc. I can't seem to come up with one that can toggle off a single checkbox.
5
14285
by: metalwing12 | last post by:
Hi guys can someone kindly help me about my code it seems incomplete or i just can make it right .I try using the disabled property of the textbox yes it workss, it disable it but when i set it to false like disabled="false" it does not enable the textbox.This is my code <p><input type="text" name="txtbox1" size="20" disabled="true"> <input type="button" value="Click" name="B3" disabled="true"> Operator</p> <p><input...
10
5102
by: viki1967 | last post by:
Disable/enable icon.gif Hi all. I have this form in the page.htm: <form action="form.asp" method="post" onsubmit="return(validateForm(this));"> <select size="1" name="t_im" onchange="Form()">
10
9116
by: sowmyati | last post by:
HI All, I am new to javascript. I have snippet wherein i am giving a brief note on what i am trying to do. In the below have a variable by name stuff. trying to reset the page. Part of the code which does reset is attached below. there is a reset button which will reset the connection and it takes two min for data loading during which the reset button has to be disabled and later after two mins it should enable the button for the user. ...
0
10620
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10369
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10372
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10110
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9187
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7650
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6877
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5682
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3851
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.