Multiple onclick=submit() need to pass name????

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • charlie_M

    Multiple onclick=submit() need to pass name????

    I have a number of applications where I want to have many
    onclick='submit ()' attached to different 'elements' on a single form
    ..... which sends the form to a CGI "script" which does all the
    validation. The problem is.. how can I code the submit()s so the CGI's
    form collection knows which 'element' was clicked??

    I am NOT permitted to use <input type=image...> or any "button" that
    browsers produce for forms.... the reasons are all client related
    ;o)))

    If I can put a string inside the parentheses (i.e.
    onclick='submit ("thisbutton")' .... and have it's characters included in
    the POST information to the CGI.. It will work for me. Can this be
    done?? how?

  • Randy Webb

    #2
    Re: Multiple onclick=submit( ) need to pass name????

    charlie_M wrote:[color=blue]
    > I have a number of applications where I want to have many
    > onclick='submit ()' attached to different 'elements' on a single form
    > ..... which sends the form to a CGI "script" which does all the
    > validation. The problem is.. how can I code the submit()s so the CGI's
    > form collection knows which 'element' was clicked??
    >
    > I am NOT permitted to use <input type=image...> or any "button" that
    > browsers produce for forms.... the reasons are all client related
    > ;o)))
    >
    > If I can put a string inside the parentheses (i.e.
    > onclick='submit ("thisbutton")' .... and have it's characters included in
    > the POST information to the CGI.. It will work for me. Can this be
    > done?? how?
    >[/color]

    onclick="someFu nction(this.id) "

    <input type="text" name="inputUsed ">

    function someFunction(in putID){
    document.forms['formName'].elements['inputUsed'].value = inputID;
    document.forms['formName'].submit();
    }

    And in each of your "elements" have an ID attribute that identifies it.

    In other words, instead of using the element to submit the form, have
    the element give a function its ID attribute, set a form field to that
    value, then submit the form. Then, the server can pick up the value of
    inputUsed to determine what element was used to submit the form.

    And I won't go into the ludicrous idea of setting up a webpage the way
    you are describing. If your client is that ignorant, its *your* job as
    the professional to educate them on the pitfalls of the design.
    Accessibility, non-JS, and many other issues make the entire approach a
    bad design before you have ever started.

    --
    Randy
    comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly

    Comment

    • Lee

      #3
      Re: Multiple onclick=submit( ) need to pass name????

      charlie_M said:[color=blue]
      >
      >I have a number of applications where I want to have many
      >onclick='submi t()' attached to different 'elements' on a single form
      >.... which sends the form to a CGI "script" which does all the
      >validation. The problem is.. how can I code the submit()s so the CGI's
      >form collection knows which 'element' was clicked??
      >
      >I am NOT permitted to use <input type=image...> or any "button" that
      >browsers produce for forms.... the reasons are all client related
      >;o)))
      >
      >If I can put a string inside the parentheses (i.e.
      >onclick='submi t("thisbutton") '.... and have it's characters included in
      >the POST information to the CGI.. It will work for me. Can this be
      >done?? how?[/color]

      1. It's your responsibility to point out to your clients that
      they're making a potentially serious mistake by not allowing
      the form to be submitted if Javascript is disabled.

      2.
      onclick="docume nt.forms[0].myHiddenField. value='thisButt on';document.fo rms[0].submit()"

      Comment

      • charlie_M

        #4
        Re: Multiple onclick=submit( ) need to pass name????

        OK.. 2 things I do not understand...

        1. If I (as the CGI) receive an ID.. how do I know WHICH submit() it
        was ?? Knowing that it was ID #5 tells me what??? This occured to me in
        browsing other people's posts about this and similar topics. I need to
        pass a NAME and somehow have it included in the form data return. The
        CGI can then figure it out.

        2. How do I get the form's data to be submitted with the form data and
        the id(s)?? From your example. I think I see how this is done. Can
        this be used more simply??? .... I only ever have 1 form... like???

        function someFunction(Na meNotId){
        thisform.elemen ts['NameNotId'].value = 'XX';
        thisform.submit ();
        }

        I am only 'guessing' about the 'thisform' syntax..... does this work??

        TIA
        Chuck

        Comment

        • charlie_M

          #5
          Re: Multiple onclick=submit( ) need to pass name????

          You are right Lee.... and I have. These applications are very complex
          and the client has a bug in his butt about looking a "paricular way"
          and javascript must serve. The apps are written in Visual Fox and run
          on a PC based blade server. We can not change how the server side works
          and M$'s buttons and Netscape buttons are abhorent to the client, I am
          attempting to get a <TD> to work as a submit button with appropriate
          stylesheet colorings and rollovers. These are not public access apps...
          they are for logged-in publishers and the ilk and we get to say how
          they access the app!!!

          Thanks
          Chuck

          Comment

          • Randy Webb

            #6
            Re: Multiple onclick=submit( ) need to pass name????

            charlie_M wrote:
            [color=blue]
            > OK.. 2 things I do not understand...
            >
            > 1. If I (as the CGI) receive an ID.. how do I know WHICH submit() it
            > was ?? Knowing that it was ID #5 tells me what??? This occured to me in
            > browsing other people's posts about this and similar topics. I need to
            > pass a NAME and somehow have it included in the form data return. The
            > CGI can then figure it out.[/color]

            Pass the name itself.

            <input type="button" name="button1" value="Button Number 1"
            onclick="someFu nction(this.nam e)">

            function someFunction(el emName){
            myForm = document.forms['formName'];
            myForm.elements['fieldName'].value = elemName;
            myForm.submit() ;
            }

            Then, the server looks at the value of the field named "fieldName" and
            it will know the name of the element that was clicked to submit the
            form. Test it :)
            [color=blue]
            > 2. How do I get the form's data to be submitted with the form data and
            > the id(s)?? From your example. I think I see how this is done. Can
            > this be used more simply??? .... I only ever have 1 form... like???
            >
            > function someFunction(Na meNotId){
            > thisform.elemen ts['NameNotId'].value = 'XX';
            > thisform.submit ();
            > }
            >
            > I am only 'guessing' about the 'thisform' syntax..... does this work??[/color]

            Only in IE if the name of the form is thisform. See above.

            --
            Randy
            comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly

            Comment

            • Grant Wagner

              #7
              Re: Multiple onclick=submit( ) need to pass name????

              "charlie_M" <cmaier12@comca st.net> wrote in message
              news:1116256426 .797416.89740@g 44g2000cwa.goog legroups.com...[color=blue]
              > OK.. 2 things I do not understand...
              >
              > 1. If I (as the CGI) receive an ID.. how do I know WHICH submit() it
              > was ?? Knowing that it was ID #5 tells me what??? This occured to me
              > in
              > browsing other people's posts about this and similar topics. I need to
              > pass a NAME and somehow have it included in the form data return. The
              > CGI can then figure it out.[/color]

              Don't rely on client-side JavaScript at all:

              <%
              Response.write( Request.value(' a1') + ';' + Request.value(' d1'));
              %>
              <form>
              <input type="submit" name="a1" value="Add">
              <input type="submit" name="d1" value="Delete">
              </form>

              If I click -a1- I get Add:null, if I click -d1- I get null;Delete.

              It would be simple matter to loop on the server looking for a known
              input name that has a non-null value, then act on it... for safety you
              may want to pass another hidden input that contains the number
              of -a#-, -d#- items, otherwise you wouldn't know when to stop checking
              on the server.

              --
              Grant Wagner <gwagner@agrico reunited.com>
              comp.lang.javas cript FAQ - http://jibbering.com/faq


              Comment

              • charlie_M

                #8
                Re: Multiple onclick=submit( ) need to pass name????

                Grant..

                I stated earlier I cannot change how the server side works. Also... I
                cannot use any sort of BUTTON... i.e "<input type=submit...>

                It would be a VERY simple matter to catch the value if it were
                there.... but javascript.subm it() does not automatically provide it ..
                which is why the "original" question was posed.......... .?????

                The ANSWER.. BTW has been implimented and it works with some
                limitations:

                onClick="docume nt.forms[0].MYBUTTON.value ='FLASHW';docum ent.forms[0].submit()"

                which requires I supply a hidden variable in the form named "MYBUTTON"
                and my CGI will pickup on it if this submit() element is clicked.
                BTW... this "element" is simply a <TD> with stylesheet rollover-type
                elements..... and there are a number of them. This satisfies the
                client, looks really impressive, works like a charm, was the answer to
                the original question. ;o)))

                Thanks to all that contributed...
                Chuck

                Comment

                • Thomas 'PointedEars' Lahn

                  #9
                  Re: Multiple onclick=submit( ) need to pass name????

                  charlie_M wrote:
                  [color=blue]
                  > [...] M$'s buttons and Netscape buttons are abhorent to the client,[/color]

                  Then use input[type="image"] elements and create your own buttons.
                  I don't see a problem here, especially if it's not a "public app".
                  [color=blue]
                  > I am attempting to get a <TD> to work as a submit button with
                  > appropriate stylesheet colorings and rollovers. [...][/color]

                  Why not format an input[type="submit"] that way?
                  [color=blue]
                  > [...]
                  > !![/color]

                  Looks like you've lost something.


                  PointedEars

                  Comment

                  • charlie_M

                    #10
                    Re: Multiple onclick=submit( ) need to pass name????



                    Thomas 'PointedEars' Lahn wrote:[color=blue]
                    > charlie_M wrote:
                    >[color=green]
                    > > [...] M$'s buttons and Netscape buttons are abhorent to the client,[/color]
                    >
                    > Then use input[type="image"] elements and create your own buttons.
                    > I don't see a problem here, especially if it's not a "public app".
                    >[color=green]
                    > > I am attempting to get a <TD> to work as a submit button with
                    > > appropriate stylesheet colorings and rollovers. [...][/color]
                    >
                    > Why not format an input[type="submit"] that way?
                    >[color=green]
                    > > [...]
                    > > !![/color]
                    >
                    > Looks like you've lost something.
                    >
                    >
                    > PointedEars[/color]

                    I don't know why your ears are pointed.. but your eyes are failing you
                    ;o))

                    REF: the original message says "I am NOT permitted to use <input
                    type=image...> or any "button" that browsers produce for forms.... the
                    reasons are all client related"... therefore: ??? The <TD> is what they
                    wanted... and I posted the solution.

                    Thanks
                    Chuck

                    Comment

                    • Richard Cornford

                      #11
                      Re: Multiple onclick=submit( ) need to pass name????

                      charlie_M wrote:
                      <snip>[color=blue]
                      > REF: the original message says "I am NOT permitted to
                      > use <input type=image...> or any "button" that browsers
                      > produce for forms.... the reasons are all client
                      > related"... therefore: ??? The <TD> is what they
                      > wanted... and I posted the solution.[/color]

                      The 'therefor' is not valid. Experience suggests that such a requirement
                      on the part of a client is usually the product of a misconception, or a
                      lack of thought. And so it is usually an examination of the reasoning
                      behind the requirement that exposes the real solution.

                      Of course if the reasoning behind an apparently bad decision is never
                      revealed then no useful progress can be made, but generally TD elements
                      make very poor GUI components.

                      Richard.


                      Comment

                      • Thomas 'PointedEars' Lahn

                        #12
                        Re: Multiple onclick=submit( ) need to pass name????

                        charlie_M wrote:
                        [color=blue]
                        > Thomas 'PointedEars' Lahn wrote:[color=green]
                        >> charlie_M wrote:[color=darkred]
                        >> > [...] M$'s buttons and Netscape buttons are abhorent to the client,[/color]
                        >>
                        >> Then use input[type="image"] elements and create your own buttons.
                        >> I don't see a problem here, especially if it's not a "public app".
                        >>[color=darkred]
                        >> > I am attempting to get a <TD> to work as a submit button with
                        >> > appropriate stylesheet colorings and rollovers. [...][/color]
                        >>
                        >> Why not format an input[type="submit"] that way?[/color][/color]
                        ^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^[color=blue][color=green]
                        >> [...][/color]
                        > [...]
                        > REF: the original message says "I am NOT permitted to use <input
                        > type=image...> or any "button" that browsers produce for forms.... the
                        > reasons are all client related"... therefore: ??? The <TD> is what they
                        > wanted...[/color]

                        They only wanted it because they do not know better, and they certainly
                        do not know that using `td' elements as controls will reduce the people
                        in the target group and increase maintenance costs since support for
                        client-side scripting is not guaranteed and neither is the required DOM
                        support. It is your job to change that and if you do not do it, you
                        behave incompetent (and deserve all what must follow in the mid-term
                        and long-term).


                        PointedEars
                        --
                        But he had not that supreme gift of the
                        artist, the knowledge of when to stop.
                        -- Sherlock Holmes

                        Comment

                        Working...