The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Passing URL data to form
Justin S.
post Apr 19 2016, 12:59 PM
Post #1





Group: Members
Posts: 2
Joined: 19-April 16
Member No.: 24,178



I'm trying to determine a way to pass URL data into an HTML form. This value would then either populate as a default value when the form is loaded, or just as a hidden form value.

For example, if the URL was:
http://www.mydomain.com?variable1="ABC"

Then a corresponding form on the page containing an input would contain that value, such as:
<input type="hidden" name="variable1" value="ABC">


The end goal then, would be to include that variable/value when the form is submitted.


Not sure if this has to be done with javascript or not, or if it can be done with straight HTML.


Any help would be greatly appreciated!


Thanks!
Justin

This post has been edited by Justin S.: Apr 19 2016, 01:01 PM
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Apr 19 2016, 03:17 PM
Post #2


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,731
Joined: 9-August 06
Member No.: 6



Not with HTML. It could be done with JavaScript, but if it's important you should rather use a server side programming language.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Apr 19 2016, 03:17 PM
Post #3


.
********

Group: WDG Moderators
Posts: 9,656
Joined: 10-August 06
Member No.: 7



It can't be done with HTML alone. Javascript can do it, but a server-side script like PHP is more reliable.

Note that a malicious user can manipulate the web page by using a specially crafted URL, so be sure to sanitize the data or compare it with a whitelist in the script before printing it on the web page.

Edit: good timing, pandy. ninja.gif
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Apr 19 2016, 05:40 PM
Post #4


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,731
Joined: 9-August 06
Member No.: 6



Not on your part. laugh.gif
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Justin S.
post Apr 21 2016, 03:29 PM
Post #5





Group: Members
Posts: 2
Joined: 19-April 16
Member No.: 24,178



Thanks!!
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 26th April 2024 - 09:06 AM