By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,248 Members | 1,979 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,248 IT Pros & Developers. It's quick & easy.

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

P: 31
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.html".
Is it possible to change this to e.g. "my_file.html -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.
Jun 17 '19 #1

✓ answered by gits

basically the shortcut would look like this:

Expand|Select|Wrap|Line Numbers
  1. "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.

Share this Question
Share on Google+
8 Replies


gits
Expert Mod 5K+
P: 5,283
what you like to do here is a typical GET request with a querystring - basically it could look similar to this:

Expand|Select|Wrap|Line Numbers
  1. 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.
Jun 17 '19 #2

P: 31
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?
Jun 18 '19 #3

gits
Expert Mod 5K+
P: 5,283
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.
Jun 18 '19 #4

P: 31
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.
Jun 18 '19 #5

gits
Expert Mod 5K+
P: 5,283
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.
Jun 18 '19 #6

P: 31
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
Jun 18 '19 #7

gits
Expert Mod 5K+
P: 5,283
basically the shortcut would look like this:

Expand|Select|Wrap|Line Numbers
  1. "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.
Jun 18 '19 #8

P: 31
Oh wow. Yes that's nice. Thanks :)
Jun 18 '19 #9

Post your reply

Sign in to post your reply or Sign up for a free account.