Problem in document.formName.OnSubmit("return validationCheck(a,b,c)") event used in a function in a

Discussion in 'ASP General' started by Varun, Mar 4, 2004.

  1. Varun

    Varun Guest

    Hi There,
    I have a form("myRequest.asp") and the values from it are
    retrieved into the page ("output_Print.asp") on which I have two
    buttons('Save As Complete' and 'Save As Incomplete'). When the 'Save
    as Incomplete' button is Clicked the form will be going to the
    "SaveAsincomplete.asp" without validation of the fields. And when the
    'save as complete' is clicked certain fileds are to be validated and
    by the function return value, if false stays in "output_Print.asp"
    else, if true, it will taken to saveasComplete.asp.

    Problems:
    1. After the function returns false the actual values in the
    "output_Print.asp" are not retaining as is.

    2. The onSubmit() when used in a javaScript function as
    (* document.Review.onsubmit= "return requiredCheck(valArray,
    keywords, SpecPop, CntrctArray)";) is not working the way it should.



    Code:

    "output_Print.asp"

    -------
    Code for the form retrieving values and showing as
    <HTML>
    <BODY>
    <FORM method="post" name="Revew">

    var1=Request.form("Title")
    var2...........
    ..............

    Response.Write "Title:"&var1
    ...........
    ..........
    ......
    .....

    <input type=submit name="submit complete" value="Save as complete"
    onClick="saveComplete('SaveInComplete.asp', this)">
    <input type=submit name="Save as Incomplete" value="Save as
    Incomplete" onClick="saveInComplete('SaveInComplete.asp')">
    <input type=submit name="back" value="Edit Submission"
    onclick=""history.back()"">


    <Script language=javaScript>
    function saveInComplete(var1)
    {
    document.Review.method ="POST";
    document.Review.action=var1;
    document.Review.submit();
    }

    function saveComplete(var1, frmName)
    {
    var errString="";
    var rtnString="";
    var valArray, keywords, SpecPop, CntrctArray

    valArray=Review.valuesArray.value;
    keywords=Review.Keywords.value;
    SpecPop=Review.SpecPop.value;
    CntrctArray=Review.CntrctArray.value;
    document.Review.method ="post";
    document.Review.onsubmit= "return requiredCheck(valArray, keywords,
    SpecPop, CntrctArray)";

    document.Review.action=var1;
    document.Review.submit();
    }
    </script>
    </form>
    </body>
    </html>


    When I call the function in the javaScript

    ( Just like-- var bool=requiredCheck(valArray, keywords, SpecPop,
    CntrctArray)";) its checking and returning the results correctly.
    But when used in "document.Review.onsubmit= "return
    requiredCheck(valArray, keywords, SpecPop, CntrctArray)";" I am not
    returning (or even the function is not called) any values from the
    function.

    Any ideas on how to deal with this issue. Or any other method without
    using the onsubmit() would be highly appreciated.

    Awaiting for your suggestions,
    Varun.
     
    Varun, Mar 4, 2004
    #1
    1. Advertising

  2. Varun

    Varun Guest

    "Peter Foti" <> wrote in message news:<>...
    > "Varun" <> wrote in message
    > news:...
    > > 2. The onSubmit() when used in a javaScript function as
    > > (* document.Review.onsubmit= "return requiredCheck(valArray,
    > > keywords, SpecPop, CntrctArray)";) is not working the way it should.

    >
    > > function saveComplete(var1, frmName)
    > > {
    > > var errString="";
    > > var rtnString="";
    > > var valArray, keywords, SpecPop, CntrctArray
    > >
    > > valArray=Review.valuesArray.value;
    > > keywords=Review.Keywords.value;
    > > SpecPop=Review.SpecPop.value;
    > > CntrctArray=Review.CntrctArray.value;
    > > document.Review.method ="post";
    > > document.Review.onsubmit= "return requiredCheck(valArray, keywords,
    > > SpecPop, CntrctArray)";
    > >
    > > document.Review.action=var1;
    > > document.Review.submit();
    > > }

    >
    > Why not just do something like this:
    >
    > function saveComplete(var1, frmName)
    > {
    > var errString="";
    > var rtnString="";
    > var valArray, keywords, SpecPop, CntrctArray
    >
    > valArray=Review.valuesArray.value;
    > keywords=Review.Keywords.value;
    > SpecPop=Review.SpecPop.value;
    > CntrctArray=Review.CntrctArray.value;
    > document.Review.method ="post";
    >
    > document.Review.action=var1;
    > return requiredCheck(valArray, keywords,SpecPop, CntrctArray);
    > }
    >
    > I think that will work for you.
    > Regards,
    > Peter Foti


    Ya, your idea was right and works if requiredCheck() returns
    false(the onClick event has valse flase and does nothing(that is what
    we wanted). But if the requiredCheck() returns true, since we are not
    mentioning the document.Review.submit(); there is no action taking
    place for which it should execute the form whatever.asp.

    I have come up with this idea (glad that it worked):

    function saveComplete(formaction, frmName)
    {
    var errString="";
    var rtnString="";
    document.Review.method ="post";
    rtnString=requiredCheck(frmName);
    if (rtnString){
    document.Review.action=formaction;
    document.Review.submit();
    }
    else {
    return false;}
    }

    Thank you for your time in replying to this message.

    Good Day.
    Varun.
     
    Varun, Mar 5, 2004
    #2
    1. Advertising

  3. Varun

    Varun Guest

    "Peter Foti" <> wrote in message news:<>...
    > "Varun" <> wrote in message
    > news:...
    > > 2. The onSubmit() when used in a javaScript function as
    > > (* document.Review.onsubmit= "return requiredCheck(valArray,
    > > keywords, SpecPop, CntrctArray)";) is not working the way it should.

    >
    > > function saveComplete(var1, frmName)
    > > {
    > > var errString="";
    > > var rtnString="";
    > > var valArray, keywords, SpecPop, CntrctArray
    > >
    > > valArray=Review.valuesArray.value;
    > > keywords=Review.Keywords.value;
    > > SpecPop=Review.SpecPop.value;
    > > CntrctArray=Review.CntrctArray.value;
    > > document.Review.method ="post";
    > > document.Review.onsubmit= "return requiredCheck(valArray, keywords,
    > > SpecPop, CntrctArray)";
    > >
    > > document.Review.action=var1;
    > > document.Review.submit();
    > > }

    >
    > Why not just do something like this:
    >
    > function saveComplete(var1, frmName)
    > {
    > var errString="";
    > var rtnString="";
    > var valArray, keywords, SpecPop, CntrctArray
    >
    > valArray=Review.valuesArray.value;
    > keywords=Review.Keywords.value;
    > SpecPop=Review.SpecPop.value;
    > CntrctArray=Review.CntrctArray.value;
    > document.Review.method ="post";
    >
    > document.Review.action=var1;
    > return requiredCheck(valArray, keywords,SpecPop, CntrctArray);
    > }
    >
    > I think that will work for you.
    > Regards,
    > Peter Foti


    Ya, your idea was right and works if requiredCheck() returns
    false(the onClick event has valse flase and does nothing(that is what
    we wanted). But if the requiredCheck() returns true, since we are not
    mentioning the document.Review.submit(); there is no action taking
    place for which it should execute the form whatever.asp.

    I have come up with this idea (glad that it worked):

    function saveComplete(formaction, frmName)
    {
    var errString="";
    var rtnString="";
    document.Review.method ="post";
    rtnString=requiredCheck(frmName);
    if (rtnString){
    document.Review.action=formaction;
    document.Review.submit();
    }
    else {
    return false;}
    }

    Thank you for your time in replying to this message.

    Good Day.
    Varun.
     
    Varun, Mar 5, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Scott
    Replies:
    2
    Views:
    130
  2. Data Guy
    Replies:
    10
    Views:
    171
    Michael Winter
    Jun 13, 2005
  3. michael
    Replies:
    7
    Views:
    124
    Randy Webb
    Oct 10, 2005
  4. JV

    document.formname wildcard?

    JV, Dec 8, 2006, in forum: Javascript
    Replies:
    4
    Views:
    88
    Evertjan.
    Dec 9, 2006
  5. Stanimir Stamenkov

    document.forms[formName].elemName

    Stanimir Stamenkov, May 25, 2008, in forum: Javascript
    Replies:
    22
    Views:
    312
    Stanimir Stamenkov
    May 26, 2008
Loading...

Share This Page