JS Problem

Discussion in 'ASP General' started by James Baker, Aug 11, 2004.

  1. James Baker

    James Baker Guest

    I'm having a problem with JavaScript and ASP that need to be intermixed.
    I'm querying a database, and creating JavaScript arrays for use on the
    client side...which works fine. Basically I have two drop down lists, and
    when you select an item in the first drop down, the items in the second one
    change. The functionality there is no problem.

    My problem lies in the fact that I'm embedding ASP code within a javascript
    function, and it's causing my form to post every time I try to do validation
    or some other client side function. Is there a simple way around this?

    Thanks,
    James
    James Baker, Aug 11, 2004
    #1
    1. Advertising

  2. James Baker

    joker Guest

    I sounds like your javascript is doing a http submit. At least that is
    my guess without any code.

    At this point to do anything other then guess we will need to see some code.

    James Baker wrote:

    > I'm having a problem with JavaScript and ASP that need to be intermixed.
    > I'm querying a database, and creating JavaScript arrays for use on the
    > client side...which works fine. Basically I have two drop down lists, and
    > when you select an item in the first drop down, the items in the second one
    > change. The functionality there is no problem.
    >
    > My problem lies in the fact that I'm embedding ASP code within a javascript
    > function, and it's causing my form to post every time I try to do validation
    > or some other client side function. Is there a simple way around this?
    >
    > Thanks,
    > James
    >
    >
    joker, Aug 11, 2004
    #2
    1. Advertising

  3. James Baker

    James Baker Guest

    <script language="javascript">
    var formTypes = new Array();
    <%
    ' Code to write out arrays here
    %>
    </script>

    ....

    <script language="Javascript">
    <!--
    function validater()
    {
    // FormType must be selected
    if (document.appraisalorder.formtype.value.length <= 1)
    {
    alert("Please select a Form type.")
    document.appraisalorder.formtype.focus();
    return false;
    }

    document.appraisalorder.action = 'Order_Submit.asp';
    window.document.appraisalorder.submit();
    return true;
    }
    -->
    </script>

    ....

    <input type="image" name="Submit" src="../../../images/submitfile.gif"
    alt="Submit File" border="0" onclick="validater()">


    When I click the button named Submit, it fires the validater function. If
    the form type isn't selected, it does the alert, but the page "refreshes"
    and definitely hits the server again.

    James
    James Baker, Aug 11, 2004
    #3
  4. James Baker

    Evertjan. Guest

    James Baker wrote on 11 aug 2004 in
    microsoft.public.inetserver.asp.general:
    > window.document.appraisalorder.submit();
    > return true;


    Though it has nothing to do with ASP and so is OT:

    Both the above '...submit()' and the 'return true;'
    will compete which code is fastest internaly to submit your form.
    This will potentially lead to dissastrous and inconsistent behavour.

    Please ask a Javascript NG for these clientside problems.

    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
    Evertjan., Aug 11, 2004
    #4
  5. James Baker

    James Baker Guest

    The return true is essentially irrelevant, I had intended to comment it out.
    I have asked in a javascript newsgroup and will post in
    microsoft.public.scripting.jscript. It appears to be a conflict between ASP
    and jscript so I figured I'd post it to both. My apologies for filling your
    newsgroup with OT posts.
    James Baker, Aug 11, 2004
    #5
  6. James Baker

    Evertjan. Guest

    James Baker wrote on 11 aug 2004 in
    microsoft.public.inetserver.asp.general:
    > The return true is essentially irrelevant, I had intended to comment
    > it out. I have asked in a javascript newsgroup and will post in
    > microsoft.public.scripting.jscript. It appears to be a conflict
    > between ASP and jscript so I figured I'd post it to both. My
    > apologies for filling your newsgroup with OT posts.


    Not at all, James, it is not my or even our NG.

    If you can show us why you suspect a serverside ASP conflict with
    clientside j(ava)script [btw, ASP can in jscript, vbscript, and perhaps
    other languages] You are totally OT [= ON-topic in this case] here.

    ===========

    I do not trust the javascript submit() to be so fast or single tasking,
    that the html-form-submit will not interfere on any current browser.

    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
    Evertjan., Aug 11, 2004
    #6
  7. James Baker

    Mark Schupp Guest

    <form name="theform" onsubmit="return validater();" ....

    <input type="image" name="Submit" src="../../../images/submitfile.gif"
    alt="Submit File" border="0" onclick="document.theform.submit();">

    --
    Mark Schupp
    Head of Development
    Integrity eLearning
    www.ielearning.com


    "James Baker" <> wrote in message
    news:%...
    > <script language="javascript">
    > var formTypes = new Array();
    > <%
    > ' Code to write out arrays here
    > %>
    > </script>
    >
    > ...
    >
    > <script language="Javascript">
    > <!--
    > function validater()
    > {
    > // FormType must be selected
    > if (document.appraisalorder.formtype.value.length <= 1)
    > {
    > alert("Please select a Form type.")
    > document.appraisalorder.formtype.focus();
    > return false;
    > }
    >
    > document.appraisalorder.action = 'Order_Submit.asp';
    > window.document.appraisalorder.submit();
    > return true;
    > }
    > -->
    > </script>
    >
    > ...
    >
    > <input type="image" name="Submit" src="../../../images/submitfile.gif"
    > alt="Submit File" border="0" onclick="validater()">
    >
    >
    > When I click the button named Submit, it fires the validater function. If
    > the form type isn't selected, it does the alert, but the page "refreshes"
    > and definitely hits the server again.
    >
    > James
    >
    >
    Mark Schupp, Aug 11, 2004
    #7
  8. James Baker

    Bã§TãRÐ Guest

    An image is usd as a submit button in JavaScript. The OnClick event shouldnt even be needed.

    Bastard



    On Wed, 11 Aug 2004 08:28:11 -0700, "Mark Schupp" <> wrote:

    ><form name="theform" onsubmit="return validater();" ....
    >
    ><input type="image" name="Submit" src="../../../images/submitfile.gif"
    > alt="Submit File" border="0" onclick="document.theform.submit();">
    Bã§TãRÐ, Aug 12, 2004
    #8
    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. Andreas Suurkuusk
    Replies:
    0
    Views:
    3,967
    Andreas Suurkuusk
    Jul 27, 2003
  2. Ted Miller
    Replies:
    0
    Views:
    5,145
    Ted Miller
    Sep 13, 2003
  3. Merek
    Replies:
    0
    Views:
    1,954
    Merek
    Dec 3, 2003
  4. Scott Meddows
    Replies:
    1
    Views:
    385
    John Saunders
    Jun 8, 2004
  5. Mike

    Problem problem problem :( Need Help

    Mike, May 7, 2004, in forum: ASP General
    Replies:
    2
    Views:
    543
    Bullschmidt
    May 11, 2004
Loading...

Share This Page