473,797 Members | 3,148 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 #1
33 3536
acoder
16,027 Recognized Expert Moderator MVP
With JavaScript, you'd use the disabled property. However, if you're going to set it whilst the page is loading with ASP, just include it within the tag:
Expand|Select|Wrap|Line Numbers
  1. <input type="text" <% if it should be disabled, just print out: disabled="true" %> ...>
Re. the validation, please provide more details.
Jan 12 '08 #2
kunal pawar
297 Contributor
Hi..
u can used directly in page
like
[HTML]<input type='control- text/button etc' name='' id='' <%if rs("field")=1 then%>
disabled=true <%elseif re("field")=2 then%>disabled= false<%end if%>>[/HTML]
Jan 14 '08 #3
idsanjeev
241 New Member
hi
I wants to use it in asp with vbscripts
and my need is to if selected option is floopy and cd then purpose Input filed is enable(show) ohterwiese purpose input field is(hide)
Thanks
Jan 16 '08 #4
gits
5,390 Recognized Expert Moderator Expert
hi ...

i'm not familiar with vb-script but in case you want to set the disabled-attribute dynamically then use something like this (javascript):

Expand|Select|Wrap|Line Numbers
  1. var input_node = document.getElementById('your_input_node_id');
  2.  
  3. // to disable the box
  4. input_node.setAttribute('disabled', 'disabled');
  5.  
  6. // to make it readonly (text stays selectable)
  7. input_node.setAttribute('readonly', 'readonly');
  8.  
  9. // to enable it simply remove the attributes
  10. input_node.removeAttribute('disabled');
  11.  
  12. // or 
  13. input_node.removeAttribute('readonly');
  14.  
kind regards
Jan 16 '08 #5
idsanjeev
241 New Member
hello
where i have to use it can you sugest any position of code .
code would write within javascript tag
Jan 16 '08 #6
gits
5,390 Recognized Expert Moderator Expert
hi ...

you have to assign an eventhandler to your select-element and call a function:

[HTML]<select name="my_name" onchange="toggl e_state(this);" >[/HTML]
now in the head of your page define the script-node:

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 == 'floppy_cd';
  5.  
  6.         var input_node = document.getElementById('your_input_node_id');
  7.  
  8.         if (val) {
  9.             input_node.setAttribute('readonly', 'readonly');
  10.         } else {
  11.             input_node.removeAttribute('readonly');
  12.         }
  13.     }
  14. </script>
  15.  
kind regards
Jan 16 '08 #7
idsanjeev
241 New Member
Hello
My need is if option value is slected cd or floopy then show input filed if option selected is cartidge then hide input filed but when the above code is used no any chnges in forms so please help me in this
Jan 16 '08 #8
gits
5,390 Recognized Expert Moderator Expert
you have to adapt the val-check to your option values of course.

are you sure that there are no changes? :) ... try to input something in case it should have been readonly ...

and please now tell clearly: should it be disabled, readonly or hidden?

kind regards

ps: please post your option html-code
Jan 16 '08 #9
idsanjeev
241 New Member
Hi sorry
I think i can't give you crrect need or little mistak
ok i am trying to decribe in brif
i have a form that has option select from table and click on add for requition of material that is in loop
my need is if select option is cd or floppy then automatic show input field for input purpose and if option is selected cartidge then hide input field and the requestion is submitted one by one in loop i can't able to do this.there are three field in select option cd,floppy and cartidge
code for select option
Expand|Select|Wrap|Line Numbers
  1.      <option Selected Value>Select Item</option>
  2. <%
  3. Set RSITEM = CON.EXECUTE("SELECT * FROM CONSUM_ITEMS ORDER BY Item_code")
  4. %>
  5. <%
  6. Do While Not RSITEM.EOF
  7. %>        <option Value="<%=RSITEM("Item_code")%>"><%=RSITEM("Item_desc")%></option>
  8. <%
  9.  
  10. RSITEM.MoveNext
  11. Loop
  12.  
thanks
Jan 16 '08 #10

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

Similar topics

2
9747
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
6472
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
8885
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
4256
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
26376
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
14281
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
5101
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
9115
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
9536
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10245
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
10205
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
9063
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...
0
6802
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
5458
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5582
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4131
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 we have to send another system
2
3748
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.