473,856 Members | 1,595 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

NEED HELP W/ ENABLE/DISABLE CHECKBOXES AND TEXTBOXES

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 type="checkbox" name="ChkboxNam e"value=1 <%IF
ObjRS("chkbox") = TRUE
THEN %> CHECKED onclick="ChkBox Checked()<% END IF %>
<%if (ObjRS("chkbox" ))Then %>//if the yes/no field value is yes
enable textbox
<input type="text"name ="FieldToEnabe" value=<%=ObjRS( "EnableField")% >>
<%ELSE%>//else if the value field is no. disable text box but if the
user
//clicks enables the checkbox then enable the textbox too.
<input type="text" disabled name="FieldToEn abe"value=<%=Ob jRS
("EnableField") %>
<%End if%>
ObjRS.MoveNext

function ChkBoxChecked()//this method is used when the user
enable/disable the
//checkbox, if it's enabled then the txtbox is enabled too.
{
if(document.Myf orm.ChkboxName. checked==true)
{
document.Myform .FieldToEnabe.d isabled=true;
}
else
{
document.Myform .FieldToEnabe.d isabled=false;
}
}

this obviously doesn't work. So...can someone tell me what i'm doing
wrong please??
thaks a lot!
Jul 19 '05 #1
2 9749
Hi HolaGoogle,

The first thing that you'll have to do is straighten out your HTML issues.
You have missing quotes, spaces, and >'s. For example:

<input type="checkbox" name="ChkboxNam e"value=1 <%IF ObjRS("chkbox") = TRUE
THEN %> CHECKED onclick="ChkBox Checked()<% END IF %>

Strip out the asp, and this will look like:

<input type="checkbox" name="ChkboxNam e"value=1 CHECKED
onclick="ChkBox Checked()

It should look like:

<input type="checkbox" name="ChkboxNam e" value=1 CHECKED
onclick="ChkBox Checked();">

After you get that worked out, try CBooling your recordset values, i.e.

<% If CBool(ObjRS.Fie lds.Item("chkbo x").Value) Then %>
Also, get rid of those // comments. If you want to put comments in, either
use vbscript comments (<% 'comment %>) or html comments <!-- comment
here -->

Ray at work


"HolaGoogle " <ho*****@yahoo. com> wrote in message
news:cd******** *************** ***@posting.goo gle.com...
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 type="checkbox" name="ChkboxNam e"value=1 <%IF
ObjRS("chkbox") = TRUE
THEN %> CHECKED onclick="ChkBox Checked()<% END IF %>
<%if (ObjRS("chkbox" ))Then %>//if the yes/no field value is yes
enable textbox
<input type="text"name ="FieldToEnabe" value=<%=ObjRS( "EnableField")% >>
<%ELSE%>//else if the value field is no. disable text box but if the
user
//clicks enables the checkbox then enable the textbox too.
<input type="text" disabled name="FieldToEn abe"value=<%=Ob jRS
("EnableField") %>
<%End if%>
ObjRS.MoveNext

function ChkBoxChecked()//this method is used when the user
enable/disable the
//checkbox, if it's enabled then the txtbox is enabled too.
{
if(document.Myf orm.ChkboxName. checked==true)
{
document.Myform .FieldToEnabe.d isabled=true;
}
else
{
document.Myform .FieldToEnabe.d isabled=false;
}
}

this obviously doesn't work. So...can someone tell me what i'm doing
wrong please??
thaks a lot!

Jul 19 '05 #2
Hey Ray,
Thansk for your answer..i'm sorry i didn't realize that my posted was
answered ;-)) i just opened my post and didn't see any answer so i
reposted it once again...sorry.. and thanks for your quick answer....
Ok, let me try what you're suggesting and i'll let you know.....OH!
the
comments are not in my asp form ..so, don't worry !! i would never do
something like that ;-) it was just meant to explain what i was trying
to do ...

Thanks!
"Ray at <%=sLocation% >" <myfirstname at lane34 dot com> wrote in message news:<#B******* *******@TK2MSFT NGP11.phx.gbl>. ..
Hi HolaGoogle,

The first thing that you'll have to do is straighten out your HTML issues.
You have missing quotes, spaces, and >'s. For example:

<input type="checkbox" name="ChkboxNam e"value=1 <%IF ObjRS("chkbox") = TRUE
THEN %> CHECKED onclick="ChkBox Checked()<% END IF %>

Strip out the asp, and this will look like:

<input type="checkbox" name="ChkboxNam e"value=1 CHECKED
onclick="ChkBox Checked()

It should look like:

<input type="checkbox" name="ChkboxNam e" value=1 CHECKED
onclick="ChkBox Checked();">

After you get that worked out, try CBooling your recordset values, i.e.

<% If CBool(ObjRS.Fie lds.Item("chkbo x").Value) Then %>
Also, get rid of those // comments. If you want to put comments in, either
use vbscript comments (<% 'comment %>) or html comments <!-- comment
here -->

Ray at work


"HolaGoogle " <ho*****@yahoo. com> wrote in message
news:cd******** *************** ***@posting.goo gle.com...
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 type="checkbox" name="ChkboxNam e"value=1 <%IF
ObjRS("chkbox") = TRUE
THEN %> CHECKED onclick="ChkBox Checked()<% END IF %>
<%if (ObjRS("chkbox" ))Then %>//if the yes/no field value is yes
enable textbox
<input type="text"name ="FieldToEnabe" value=<%=ObjRS( "EnableField")% >>
<%ELSE%>//else if the value field is no. disable text box but if the
user
//clicks enables the checkbox then enable the textbox too.
<input type="text" disabled name="FieldToEn abe"value=<%=Ob jRS
("EnableField") %>
<%End if%>
ObjRS.MoveNext

function ChkBoxChecked()//this method is used when the user
enable/disable the
//checkbox, if it's enabled then the txtbox is enabled too.
{
if(document.Myf orm.ChkboxName. checked==true)
{
document.Myform .FieldToEnabe.d isabled=true;
}
else
{
document.Myform .FieldToEnabe.d isabled=false;
}
}

this obviously doesn't work. So...can someone tell me what i'm doing
wrong please??
thaks a lot!

Jul 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
6479
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...
9
4962
by: Susan Bricker | last post by:
Hi. I have two questions ... (1) I want to use a Listbox to enable the user to select 1 or many items from the list. However, I'm having trouble figuring out how to find out t which items have been selected. How can I do that? Given the listindex, .selected, .itemsselected, .itemdata properties -- I'm getting confused. (2) I, actually, have two listboxes on the form and I want to ONLY let the user select items in one list. The...
9
4389
by: Marc | last post by:
Okay, here's the problem - I have 3 radio buttons, and 11 check boxes (which are disabled by default). I have the javascript below which when the last radio button is clicked, enables the checkboxes. <script type="text/javascript"> //<!]> </script> I used the JavaScript on 2 pages, on almost identical forms, and for some reason it doesn't work on the 2nd one - they just stay disabled,
4
3545
by: chengsi | last post by:
Hi all, This is my first post, so please excuse if i am posting a silly question. I have an MS Access database and have created a tabulated form (where there are multiple lines, one for each record - similar to a table, hence the name). There are about 10 fields or so, and i have used textboxes, combo-boxes and checkboxes to represent the fields. What I am trying to do is to enable or disable textbox_2, depending on the value of...
2
1824
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...
5
11285
by: masterej | last post by:
Developers, Is there any way to disable all checkboxes on a form? I have a form with 160 checkboxes and I want to be able to disable all of them. Is there a way I can do something like this: for (int i = 0; i < 160; i++) { string checkbox = "checkBox" + i.toString(); (Cast)checkbox.enabled = false;
1
3893
by: javasachin | last post by:
Hello, I want to enable Struts2 Submit button <s:submit> in the client side using JavaScript based on the user inputs in some other controls (textboxes). If user is not entering any values in the text boxes, I want to disable the <s:submit> and if user enters any text, then I want to enable this <s;submit. button. Can you kindly tell me how to do this??? Thanks in advance. Regards, Sachin
1
2250
by: zufie | last post by:
I have a main form containing 2 checkboxes. The respective checkboxes when checked cause the SepcialEffect Property to make all the textboxes to appear Shadowed. 1)Although the Textboxes and Combo Boxes required to appear Shadowed are almost the same regardless of the checkbox that is checked how do I cause individual textboxes to appear Flat? 2)How do I cause the Textboxes and Combo Boxes to highlight upon
19
6599
pradeepjain
by: pradeepjain | last post by:
for($i = 1; $i <= 15 ; $i++){ for($k = 1; $k <= 10 ; $k++){ $myresult .= "<input class='star' type='radio' name='rating".$i."' id='rating".$i."' value='". $k ."' disabled='true' $chk title='". $k." out of 10 ' />"; } } $myresult .= "<a href='#' id=\"rate-it\" onclick=\"test('rating".$i."');\">Rate It</a>"; <script type='text/javascript'> function test(name){ document.ratings.rating1.disabled = false; ...
0
9763
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
10697
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
10786
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
10389
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
9532
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
7097
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
5762
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...
1
4578
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
4175
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.