0

I'm sure I'm missing something basic here, but I just can't get my finger behind it..

If I land on a url that is say domain.com?key=123 and there is a form on domain.com that has a field called key. I thought it would fill in that field with the value 123 by itself, since it's been passed. Am I missing something here?...

thank you!

Malachi
  • 977
  • 6
  • 16
  • 31
  • Example: http://www.cornerstws.com/test.html?key=1234 As you can see.. it doesn't fill the field with the value 1234. So what am I missing here? This is just html, no php/coldfusion/whatever... – Malachi Jun 21 '13 at 14:58

6 Answers6

0

What language are you using? Normally you start with a question mark...

domain.com/?key=123

If you have other variables you use an ampersand.

domain.com/?key=123&anotherKey=456&lastKey=789

UPDATED: Here is a link to parse the query string using Javascript: How can I get query string values in JavaScript?

Community
  • 1
  • 1
sho
  • 741
  • 1
  • 7
  • 16
  • I think I changed my question right after you answered.. :-) Yes, no slash, but a question mark there. Language: none.. just html. – Malachi Feb 19 '13 at 21:59
  • 1
    You need a slash. If not the domain will be domain.com?key=123 which is not a valid domain name. The slash separates the domain from the query string. – sho Feb 19 '13 at 22:01
0

The webmaster may decide to pass the variable inside of the html form, but that may also be not the case. Most often, GET requests are used to send data from a form to a php script but it's more rare to see the an html form compiled with a php script.

Saturnix
  • 10,130
  • 17
  • 64
  • 120
0

You need to print the value from the GET array into the value attribute of the input element. (ie. if you are using php use <input name="key" value="<?php echo $_GET["key"]; ?>" />)

Derek
  • 3,438
  • 1
  • 17
  • 35
0

If you want a form field that pulls in your URL parameters then do something like this:

PHP

<label>Key:</label>
<input type="text" value="<?php echo $_GET["key"]; ?>">

Coldfusion

<label>Key:</label>
<input type="text" value="<cfoutput>#URL.key#</cfoutput>">
Trey Copeland
  • 3,387
  • 7
  • 29
  • 46
0

Something else happens on that page - you fill the form, and when posted, server GETs your variable KEY for use for whatever page author saw fit. It is a whole other story, whether you will see this variable on the form when it is reloaded after posting

Kitet
  • 855
  • 1
  • 10
  • 20
0

What you see in the browser address bar is an HTTP URL which is just indicative of the HTTP Request being made.To see the complete HTTP Request - use Chrome - Developer tools. (HTTP Request /Response / Body / Cookie)

Your HTML page is formed by the Server you send the HTTP Request to. This HTML page is send back to the Browser in HTTP Response Body. Your browser which has layout (HTML) Engine running "just parses/renders the HTML in the HTTP Response".

The engine would - Parse to check for any HTML inconsistencies , to build DOM tree, to load scripts/images/css

Its purely you and only you who would decide as how to use the data. This data can either be used by JavaScript or Server Side code like JSP.

Other users have already suggested to you the way this can be achieved like running some script.

user1428716
  • 2,078
  • 2
  • 18
  • 37