How to set drop-down-menu of html file to desired parameter given by URL?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Daniel1111
    New Member
    • Jun 2019
    • 31

    How to set drop-down-menu of html file to desired parameter given by URL?

    I am creating a html file with a table over xslt. I am using JavaScript for filtering some rows. Is it possible to write some parameters behind the URL to change the drop-down-menu item when I open the html-file the first time?
    For example I got the html file "my_file.ht ml".
    Is it possible to change this to e.g. "my_file.ht ml -parameter", then read "parameter" with javascript and set my drop-down-menu to Paramter?
    I do not want to make a new entry "Parameter" to my drop-down-menu. I just would like to show the parameter item in my drop-down-menu and my table should be filtered by that.
  • gits
    Recognized Expert Moderator Expert
    • May 2007
    • 5388

    #2
    what you like to do here is a typical GET request with a querystring - basically it could look similar to this:

    Code:
    http://myurl.com?myParam=value
    of course you can use JavaScript for that by using the location-object - but since it is a GET request that first goes through to the server you could even set a selected attribute at the serverside already - since there you would have the parameter as well already.

    Comment

    • Daniel1111
      New Member
      • Jun 2019
      • 31

      #3
      I am sorry I do not like to read the URL but like to read my file name: I have just explained it wrong. See the following:

      I got a html-file in some folder. The file is called "file.html" . I create a link-file to "file.html" on my desktop or anywhere else. The link file's name is "file.html" as well. Now I rename my link file to "file.html -Parameter".

      For my "file.html" I am using some JavaScript to filter some rows of a table which is being created.

      My question is: Is it possible to read "Parameter" of my link file in my JavaScript and how can I do this?

      Comment

      • gits
        Recognized Expert Moderator Expert
        • May 2007
        • 5388

        #4
        well - i dont think that this is possible - the html file is opened in a browser thus your only way to pass something on to that page is through a URL. what your page could do though is - onLoad it could request something.

        On the other hand i am wondering whether the parameter is constant as it looks now? In that case you could even hardcode it in a variable in the page's javascript.

        Comment

        • Daniel1111
          New Member
          • Jun 2019
          • 31

          #5
          The thing is I may have e.g. 10 link files to my originial file "file.html" . Each link file does have an extra constant Parameter. If I open one link file with the Parameter e.g. "Monday" than I want to show "Monday" in my drop-down-menu. This is a selecting by opening a file. A new entry "Monday" to my drop-down-menu shoud not be added.

          So I need a already selected drop-down-menu which depends on the opening of a link-file, not the original file.
          Do you understand? If you understand: Do you have any other ideas how I can change my drop-down-menu by opening a link-file? Should be working with JavaScript as I already have a working JavaScript file.

          PS: I can also name my link-file just Monday, because it is just a link-file.
          Last edited by Daniel1111; Jun 18 '19, 11:24 AM. Reason: PS:

          Comment

          • gits
            Recognized Expert Moderator Expert
            • May 2007
            • 5388

            #6
            i understand - but as i said - you cannot pass something like that to a website (the page wont know anything about your link file or how it was started in the browser) - but what you can do is creating a shortcut to IE for example with the URL and the correct parameters (with quotes where needed).

            if its the case of date/day related selections then you can implement that in JavaScript itself as well so it would always select the correct value.

            Comment

            • Daniel1111
              New Member
              • Jun 2019
              • 31

              #7
              I did create a shortcut. But I don't get it how this should work with parameters as it is the same like the link-file. How should it be possible read the parameters with JavaScript then. They are not in the URL as the URL is the original file.. hm

              Comment

              • gits
                Recognized Expert Moderator Expert
                • May 2007
                • 5388

                #8
                basically the shortcut would look like this:

                Code:
                "path to IE exe" "file://path-to-file.html?param=foo"
                then in javascript you can simply use the location object to work with the querystring.

                Comment

                • Daniel1111
                  New Member
                  • Jun 2019
                  • 31

                  #9
                  Oh wow. Yes that's nice. Thanks :)

                  Comment

                  Working...