Removing values from querystring before being sent through form (get method)?

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

    #1

    Removing values from querystring before being sent through form (get method)?

    Just wondeing if there is a way to keep from having a certain
    parameter sent when posting a form to another page (method=get)...

    So as an example a page will post something like this from a form
    using "get":

    http://mypage?firstElement=1&secondElement=2

    How can you completely remove "secondElement= 2" from the
    querystring... Before moving on to the posted page?

    I know you can actually remove the element using removeChild in
    javascript, and therefore it won't show up in the querystring of the
    page posted to:

    ochild.parentNo de.removeChild( ochild);

    But I was wondering if there was a way of doing it? A person can see
    an inputbox for example disappear for a split second before the page
    is posted... Is there a way of accessing the querystring itself in
    javascript? Or some other way then removing the element?
  • Dietmar Meier

    #2
    Re: Removing values from querystring before being sent through form (get method)?

    Utter Newbie wrote:
    [color=blue]
    > But I was wondering if there was a way of doing it? A person can see
    > an inputbox for example disappear for a split second before the page
    > is posted... Is there a way of accessing the querystring itself in
    > javascript?[/color]

    No.
    [color=blue]
    > Or some other way then removing the element?[/color]

    You could set it's disabled property to true, but obviously that is
    useless when JS is disabled, or in user agents that don't support
    that property, so you'd better simply ignore the value on the server
    side.

    ciao, dhgm

    Comment

    • micha

      #3
      Re: Removing values from querystring before being sent through form (get method)?


      Dietmar Meier wrote:[color=blue]
      > Utter Newbie wrote:
      >[color=green]
      > > But I was wondering if there was a way of doing it? A person can[/color][/color]
      see[color=blue][color=green]
      > > an inputbox for example disappear for a split second before the[/color][/color]
      page[color=blue][color=green]
      > > is posted... Is there a way of accessing the querystring itself in
      > > javascript?[/color]
      >
      > No.
      >[color=green]
      > > Or some other way then removing the element?[/color]
      >
      > You could set it's disabled property to true, but obviously that is
      > useless when JS is disabled, or in user agents that don't support
      > that property, so you'd better simply ignore the value on the server
      > side.
      >
      > ciao, dhgm[/color]

      why would you wanna do this? just don't process the unwanted value at
      the other end.

      micha

      Comment

      • Dietmar Meier

        #4
        Re: Removing values from querystring before being sent through form (get method)?

        micha wrote:
        [color=blue][color=green]
        >> so you'd better simply ignore the value on the server side.[/color][/color]
        [color=blue]
        > why would you wanna do this? just don't process the unwanted value at
        > the other end.[/color]

        That's exactly what I meant with "ignore".

        ciao, dhgm

        Comment

        • micha

          #5
          Re: Removing values from querystring before being sent through form (get method)?

          yes, right, didn't read closely enough.

          micha

          Comment

          • Fred Oz

            #6
            Re: Removing values from querystring before being sent through form(get method)?

            micha wrote:[color=blue]
            > Dietmar Meier wrote:
            >[color=green]
            >>Utter Newbie wrote:
            >>
            >>[color=darkred]
            >>>But I was wondering if there was a way of doing it? A person can[/color][/color]
            >
            > see
            >[color=green][color=darkred]
            >>>an inputbox for example disappear for a split second before the[/color][/color]
            >
            > page
            >[color=green][color=darkred]
            >>>is posted... Is there a way of accessing the querystring itself in
            >>>javascript ?[/color]
            >>
            >>No.
            >>
            >>[color=darkred]
            >>>Or some other way then removing the element?[/color]
            >>
            >>You could set it's disabled property to true, but obviously that is
            >>useless when JS is disabled, or in user agents that don't support
            >>that property, so you'd better simply ignore the value on the server
            >>side.
            >>
            >>ciao, dhgm[/color]
            >
            >
            > why would you wanna do this? just don't process the unwanted value at
            > the other end.
            >[/color]

            At a guess, to mess with page content using javascript: in the
            browser address field? If you run javascript from the address field,
            you can disable form elements that you don't want sent to the server,
            or put values in them other than those that the programmer has tried
            to limit you to by using selects, radio buttons or checkboxes.

            One use I've seen is when faced with radio buttons requesting whether
            your sex is male or female, change the value to "gay" or "neuter" or
            some such.

            A well validated page will pick up the fact that a field is missing,
            or that a value is not within the allowable selections, but a shoddy
            site may not.


            --
            Fred

            Comment

            • Utter Newbie

              #7
              Re: Removing values from querystring before being sent through form (get method)?

              This wasn't my script I was modifying. For some reason they don't want
              one field to show up in the querystring when it is sent to the page...
              Even if it is empty...


              They wouldn't want myfirstvalue showing up at all in the first clicked
              link even if there is no value...

              Basically they used each anchor tag within a form to call a javascript
              function through its onclick event. Some of these anchor tags would
              read a value from an input box in the form and also append values
              through the javascript using createElement. Then post the form with
              the added elements through javascript. So the input box would get
              posted along with all the created elements because it was part of the
              orinal form. They were using something like this for that one link in
              particuar....

              the function()
              {

              var input;
              if (document.creat eElement) {
              input = document.create Element('input' );
              input.type = 'hidden';
              input.name = 'NewParameter';
              input.value = 'TheParamValue' ;
              oparent.appendC hild(input);

              document.form1. elementIDontWan t.value = "";
              }

              document.form1. action="http://www.myurl.net/index.asp";

              }
              .... To submit the form along with its newly created elements in
              javascript. All called through the onclick event... You can see they
              blanked out the value but it doesn't get rid of the actual name of
              the form element in the querystring.

              But for one link they didn't want to post the input box param along
              with the created element. Strange way of doing it seems but that is
              what they did. That is why I removed the input box using removeChild
              in the javascript for that one link click...

              I just thought there had to be a better way of doing it... Personally
              this is not how I would have gone about it. But I'm not a javascript
              expert.

              Comment

              • Utter Newbie

                #8
                Re: Removing values from querystring before being sent through form (get method)?

                Actually this worked. Thanks!

                On Wed, 27 Apr 2005 12:37:21 +0200, "Dietmar Meier"
                <usereplytoinst ead@innoline-systemtechnik.d e> wrote:
                [color=blue]
                >Utter Newbie wrote:
                >[color=green]
                >> But I was wondering if there was a way of doing it? A person can see
                >> an inputbox for example disappear for a split second before the page
                >> is posted... Is there a way of accessing the querystring itself in
                >> javascript?[/color]
                >
                >No.
                >[color=green]
                >> Or some other way then removing the element?[/color]
                >
                >You could set it's disabled property to true, but obviously that is
                >useless when JS is disabled, or in user agents that don't support
                >that property, so you'd better simply ignore the value on the server
                >side.
                >
                >ciao, dhgm[/color]

                Comment

                Working...