Re: JS question...whats wrong with this...
by Andrej Kostresevic <temporalassassin(at)yahoo.com>
|
Date: |
Sun, 29 Apr 2001 17:01:40 -0700 (PDT) |
To: |
Scott Rushing <srushing(at)wfubmc.edu>, "hwg-languages(at)hwg.org" <hwg-languages(at)hwg.org> |
In-Reply-To: |
wfubmc |
|
todo: View
Thread,
Original
|
|
This is a little bit off topic, but i hope you will find it usefull.
I have used this method many times before, untill I realised that it is
much easier to use the forms onSubmit event.
<form name="myForm" onSubmit="return doChecks()">
All you need to do is validate all your data in the doChecks() function,
and return true/false depending on the data.
True will let the submit action continue, and false will stop it.
Hope this helps,
Andrej
--- Scott Rushing <srushing(at)wfubmc.edu> wrote:
> Hi all,
>
> I'm trying to figure out what I'm doing wrong. I have a complicated web
> application that searches for products, kind of a drill down
> situation. In it I am have a area for them to enter a min and a max
> value for a search parameter. I'm trying to validate that data before
> going on but somethings not working. What I want to ave happen is when
> they click on the update button, validate the range of numbers, call
> another function that sets what field they just hit (this form has MANY
> fields) and then submit the form. Since I have so many buttons and so
> many things I have to keep track of because of the way the application
> works, I was trying to do my buttons as type="button" and use the
> onClick method to kick off the tests. The problem is that the first
> check (validResistance) works but if it comes back true meaning the
> range was valid, I want it to continue through the onClick list but it's
> stopping. It never submits the form as long as I have the return
> validResistance() in the onclick method. if I remove that, everything
> works fine, except I don't get my values tested.
>
> What am I missing?
> Thanks
> S
>
> +++++++++++++++++++++++
> code snippets:
> +++++++++++++++++++++++
> <SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
> <!--
> function setfield(current){
> document.searchform.previous.value=document.searchform.current.value;
>
> document.searchform.current.value=current;
> return true;
> }
> function validResistance() {
> num = parseInt(document.searchform.min_resist.value);
> num = parseInt(document.searchform.max_resist.value);
> if (document.searchform.min_resist.value != "" && num <
> document.searchform.minres.value )
> {
> alert("You must enter a Resistance value between the lowest and
> highest values listed below");
> document.searchform.min_resist.focus;
> document.searchform.min_resist.select;
> return false;
> }
> else if (document.searchform.max_resist.value != "" && num >
> document.searchform.maxres.value )
> {
> alert("You must enter a Resistance value between the lowest and
> highest values listed below");
> document.searchform.max_resist.focus;
> document.searchform.max_resist.select;
> return false;
> }
> else {
> return true;
> }
> }
> //-->
> </SCRIPT>
> <form name="searchform" action="submitme_new.cfm" target="hiddenrow"
> method="post" >
> <some code is here>
> <input type="button" value="Update" onclick="return
> validResistance();setfield('resistance');this.form.submit()">
> <some more code is here>
> </form>
>
>
>
__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/
HWG: hwg-languages mailing list archives,
maintained by Webmasters @ IWA