Quantcast
Channel: ASPRunner forums
Viewing all articles
Browse latest Browse all 2586

Prefill Form via URL Parameters

$
0
0
Sometimes it is convenient to prefill forms via URL so that the user has less data entry and you do not have to make multiple versions of the same form.

Example Use Case:

1. A user is on a page listing all items in a particular category.
2. Clicking on the "Add New" button goes to the add form, but has the category of the calling page already selected.

So, if there is a field called "category" on the form:

Going to example.com/form_add.php?category=1 (or something similar)...

...would show the add form as usual but would have category 1 automatically selected (from the drop-down, radio button, etc.).

You could also have it prefill text fields as well.

If passing variables via GET is not possible, passing them via POST would work as well. Both scenarios have their uses.

How is the best way to go about doing this?

Viewing all articles
Browse latest Browse all 2586

Trending Articles