473,725 Members | 1,942 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 9742
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
6465
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
4949
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
4379
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
3536
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
1808
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
11275
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
3890
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
2244
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
6589
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
8888
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8752
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
9257
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
9174
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,...
1
6702
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
4782
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3221
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
2634
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2157
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.