Chris__T
Posts: 339
|
| Posted: 01/24/2007, 12:12 PM |
|
Here is my situation. I have a textarea and a checkbox. What I want is that when the checkbox is checked, then an alert kicks in so that when you click in the text area, the alert pops up. I was able to make the alert pop up on it's on without factoring in the checkbox. Now I'm having a problem implementing the checkbox. Here is my code:
in the script area of the html:
function calculate(){
if (checkbox1.checked = true)
alert("this is a test alert")
}
in my textareas html:
<textarea class="SulfurTextarea" rows="3" cols="50" style="COLOR: #FF0000" onclick="calculate()"></textarea>
any suggestions? thanks.
|
 |
 |
Edd
Posts: 547
|
| Posted: 01/24/2007, 1:53 PM |
|
2 things
1. Fully qualify your checkbox.
2. You only had ONE equals sign in an if statement is should be '==" in javascript,
if (document.formname.checkbox1.checked==true)
or just
if (document.formname.checkbox1.checked)
Edd
_________________
Accepting and instigating change are life's challenges.
http://www.syntech.com.au |
 |
 |
Chris_T
|
| Posted: 01/25/2007, 11:53 AM |
|
Ok, thanks Edd. I keep forgetting about the double equats signs....always gets me. :)
But changing everything still doesn't fix it. Nothing seems to happen. I guess it's not liking something in there. Back to the drawing board.
UP IN SCRIPT AREA OF HTML:
function calculate(){
if (Inspection_maint_test.page_Approved_TOP.CheckBox1.checked==true)
alert("this is a test.")
}
FURTHER DOWN IN TEXTAREA'S CODE:
<textarea class="SulfurTextarea" style="WIDTH: 313px; HEIGHT: 36px" name="Final" cols="44" onclick="calculate()"></textarea>
|
|
|
 |
Edd
Posts: 547
|
| Posted: 01/26/2007, 7:40 PM |
|
Chris
Try
function calculate(){
if (document.page_Approved_TOP.CheckBox1.checked==true)
alert("this is a test.")
}
document is a generic reference to the page in javascript followed by the form name followed by the control name. All references are case sensitive.
Edd
_________________
Accepting and instigating change are life's challenges.
http://www.syntech.com.au |
 |
 |
Chris_T
|
| Posted: 01/31/2007, 10:13 AM |
|
Thanks for the help. Got it working, but the person who wanted this feature changed their mind and wanted something different! D'oh! Thanks!
|
|
|
 |