Bethfiander Bethfiander - 2 months ago 8
CSS Question

html Form preset value field

Kind of an odd question and kinda hard to explain so will try my best.

I am wondering if it is possible to take the following:

<label for="page_name">page name</label><br>

<input type="text" name="page_name" maxlength="50" size="30">

and Display none; in the CSS so that this field isn't visible to anyone filling our the form, so that its left blank. Well not blank I would like to have a preset value so that when the form is filled out, I get all their entered details and I get my preset field "page_name" that has text I have entered so that I can put for example "page 5" so that I can see which page the form has been filled out on.

Is it possible to do it in html? I have done in the past by making each page have its own form and this time around I feel like there must be an easier solution?

Thanks in advance!


This is very possible, I used it to track IP adresses once.

You can simply set the value by hand:

<input  type="text" name="page_name" value="Default input value" style="display:none;">

Make sure you set it to display:none; (this can be done from your stylesheet too).

Set the value="default value" wich is what otherwise would be entered by the user.


function showvalue(){
<script src=""></script>

<input  type="text" name="page_name" value="Default input value" style="display:none;">

<button onclick="showvalue()">Show value </button>