KL said the following on 7/21/2006 12:38 AM:
Quote:
Randy Webb wrote:
Quote:
>KL said the following on 7/20/2006 10:31 PM:
Quote:
>>I am trying to get a form to work with validating a checkbox. It
>>validates the checkbox ok, but it always redirects, even if the box
>>isn't checked...it does alert, but I was hoping that it would stay on
>>the current page and not redirect unless the box IS checked. I really
>>can't see what I did wrong. Any and all help would be appreciated.
>You left out the word "else".
>
I added the else...
Quote:
Quote:
>>My code so far is:
>>>
>><HTML>
>><HEAD>
>><TITLE>Application</TITLE>
>><script type="text/javascript">
>>>
>>function validate()
>>{
>>>
>>var test=document.getElementById("CCAcknowledgement"). checked
>>submitOK="true"
>>>
>What is submitOK used for? And, if you are using it as a Boolean, it
>should be submitOK = true, without the parentheses.
>
My bad...I took it out, but forgot that one spot
Actually, I used the wrong word. Not parentheses, but quotation marks.
Quote:
Quote:
Quote:
>>if (test==false)
>if (!test)
>>
>test it.
>
got that now
>
Quote:
Quote:
>>{
>>alert ("To process your information, you must acknowledge that your
>>credit report will be verified and
>>>
>>analyzed. Please check the appropriate box.")
>>>
>>}
>Here is where the word "else" is missing.
>>
Quote:
>> {
>>window.navigate('index3.html');
>window.navigate shouldn't be used. Set the location property.
>
I do not understand what you mean here. I am new to Javascript.
Well, actually, you shouldn't be using either for what you are doing.
Have the function validate the form. If it should be submitted, return
true. Otherwise, return false. Then, the form gets submitted or they
stay where they are.
But, to answer you, you set the location property:
document.location = "someWhere.html";
or:
window.location = "someWhere.html";
Which you use depends on what navigation you want to take place. In a
non-frameset, they do the same thing. In a frameset they don't do the
same thing.
Quote:
Quote:
>Here, there is a closing } missing.
>>
>It is totally surprising that you get an alert from that code.
>>
>Have the function return test. If it is true, then the form gets
>submitted. If it is false, the form won't get submitted.
>>
>And what is with all the HTML3.2 code?
>
Heh, I haven't had the time yet to learn 4.0 ... and I am self taught
for 3.2
Forget HTML3.2, learn HTML4.01 (at a minimum) with CSS. It will make
your life a lot simpler.
For questions about them:
HTML: comp.infosystems.
www.authoring.html
CSS: comp.infosystems.
www.authoring.stylesheets Quote:
Quote:
>There is more that could be said about it, but that is enough to get you
>started.
>
Don't be shy! I really do want to know where I am going wrong...I
won't learn if my mistakes aren't pointed out to me! And I appreciate
your time and efforts to help me!
One thing I don't think I could ever be accused of is being shy.
Fix the errors already shown, then post back with a URL to a sample
page. The critiques around here are endless.
--
Randy
comp.lang.javascript FAQ -
http://jibbering.com/faq & newsgroup weekly
Temporarily at:
http://members.aol.com/_ht_a/hikksnotathome/cljfaq/
Javascript Best Practices -
http://www.JavascriptToolbox.com/bestpractices/