Author |
Topic |
|
Biddyman
Starting Member
32 Posts |
Posted - 13 January 2008 : 20:40:31
|
I have a checkbox on a form and was wanting to print a yes or no on a page after it. If the box is unchecked, it is empty. Checked = 1.
I thought it would be a simple:
<script type="text/vbscript">
if isempty(checkbox)then
document.write("No")
else
document.write("Yes")
end if
</script>
But I get an error. "wrong number of arguments or invalid property assignment: 'isempty'"
Any suggestions? It worked on the w3schools site. Hahahah! |
|
Davio
Development Team Member
Jamaica
12217 Posts |
Posted - 13 January 2008 : 21:00:18
|
You need to point to the check box, using the hierarchy. Something like document.formname.checkbox_name
So would be:if isempty(document.form_name.checkbox_name) then I think. Where's the w3schools page you saw this working at? |
Support Snitz Forums
|
|
|
Biddyman
Starting Member
32 Posts |
Posted - 13 January 2008 : 21:14:21
|
http://www.w3schools.com/ / _conditionals.asp It gives a anther window to test on if you click one of those first three links.
I, of course, had to add "x=empty" and also with a value to see if the else worked.
Here is something I forgot, If it has a value it goes to 'else' no problem. It will not print the 'No'. I figured isempty would work since the field is empty if it isn't checked.
I just put 'checkbox' for the variable. It actually has a placeholder carrying the data. |
Edited by - Biddyman on 13 January 2008 21:16:16 |
|
|
Biddyman
Starting Member
32 Posts |
Posted - 13 January 2008 : 21:34:52
|
After 4 hours, I figured it out. It was simple:
<script type="text/vbscript">
if "checkbox"= "" then
document.write("No")
else
document.write("Yes")
end if
</script> |
|
|
JJenson
Advanced Member
USA
2121 Posts |
Posted - 13 January 2008 : 22:02:20
|
I have found biddyman that the simple answer usually is staring you right in the face. At least its always the really dumb mistakes for me. |
|
|
Biddyman
Starting Member
32 Posts |
Posted - 13 January 2008 : 22:56:09
|
So true, I was bugging you over the favicon and finally posted my code in another topic which was copied from another thread. Turns out the code was wrong on the first topic all along.
I'm not a coder, but I did take (showing my age) 'Basic' back in the early 90s and in high school in the early 80s. One thing I remember my instructors always saying:
1. Always write the shortest code you have to, afterall programmers are lazy and trying to make things easier in the first place. 2. Always flow chart and remark your code. I laugh at this one. The instructor works for State Farm and hates going into code and not seeing remarks when he is updating stuff.
|
|
|
JJenson
Advanced Member
USA
2121 Posts |
Posted - 14 January 2008 : 00:14:27
|
Yeah sorry I forgot to mention that there was a few instances. Just been a bad week jsut now getting a few minutes for something I wanted to do then I got stuck with building a HOA site so I am working on that.
I will try and look a little harder next time for ya |
|
|
Shaggy
Support Moderator
Ireland
6780 Posts |
Posted - 14 January 2008 : 05:33:57
|
If you're running this clientside, you need to use javascript as vbscript is only supported by IE.
|
Search is your friend “I was having a mildly paranoid day, mostly due to the fact that the mad priest lady from over the river had taken to nailing weasels to my front door again.” |
|
|
Biddyman
Starting Member
32 Posts |
Posted - 14 January 2008 : 06:17:41
|
Thanks Shaggy, I hadn't gotten to test it on firefox. |
|
|
|
Topic |
|