Newbie with probabley simple problem

L

Lukelrc

Hi,

I have an ASP page in which are two textfields. What i want is these
to be disabeled if a checkbox is ticked in the previous page. However
it doesnt work.

This is what i have:


<script type="text/javascript">
function disableischecked()
var ischecked = "<%=request("chkall")%>"
if (ischecked = "on")
{
document.fmChoice.cboPickYear.disabled=true;
document.fmChoice.cboPickMonth.disabled=true;
alert("it works!")
}
</script>

</head>

<body onload ="disableischecked()">

<form action="Edit.asp" method="get" name="fmChoice" id="fmChoice">

<select name="cboPickYear" id="cboPickYear" size="2"
style="width:100px;" onChange="submit()></select>

<select name="cboPickMonth" size = "2" style="width:100px;"
id="cboPickMonth" onChange="submit()"></select>

.........

If i take out:

var ischecked = "<%=request("chkall")%>"
if (ischecked = "on")

from the disableischecked()function it will disable the textboxes and
the message will pop up, but i need it to be conditional on wheather
chkall = "on".

Any help would be much appreciated!
 
L

Lee

Lukelrc said:
Hi,

I have an ASP page in which are two textfields. What i want is these
to be disabeled if a checkbox is ticked in the previous page. However
it doesnt work.

This is what i have:


<script type="text/javascript">
function disableischecked()
var ischecked = "<%=request("chkall")%>"
if (ischecked = "on")

The Javascript problem is that you're trying to use the assignment
operator "=" to test for equality. You need to use "==".

A more basic error is that you're using a combination of server
side ASP and client side Javascript to do what could be done in
ASP alone. Rather than using ASP to set a variable, use it to
set the DISABLED attribute in the HTML definition of your form
elements.
 
K

kaeli

Hi,

I have an ASP page in which are two textfields. What i want is these
to be disabeled if a checkbox is ticked in the previous page. However
it doesnt work.

This is what i have:


<script type="text/javascript">
function disableischecked()
var ischecked = "<%=request("chkall")%>"

Try
var ischecked = "<%= Request.Form("chkall") %>";

--
 
G

Grant Wagner

Luke said:
Thanks for the help, here's how i did it:

<select <% if Request("chkall") = "on" then %>DISABLED<% end if %>
name="cboPickYear" id="cboPickYear" style="width:60px;"
onChange="submit()" ></select>

Easy as that!

*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!

Somewhere along the way, a virus got attached to your newsgroup posting.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top