For simplicity’s sake lets take the following form:
<form>
Title: <?php echo $title; ?><input type="text" name="title" value="">
</form>
The $title variable contains the title of the book. In this example the output would be:
Title: The Hobbit <empty form field>
The idea is that the empty field would allow the user to change the title of the book on clicking Submit OR to copy the book’s title into the field.
Problem is, I have no idea how to create the “copy into field” button.
Furthermore, this form has multiple title fields, each having the option in question so ideally, the page would not reload otherwise the user would never be able to modify all titles at once.
Can anyone point me to the right direction to go for this? Ideally I would not use javascript and stay strictly in php/html.
Why don’t you write the title in the value-attribute by default?
you can use css to let the input-element look like a normal Text, but on :focus it “transfers” to an input by setting a typical border.
the pro is: every input-element has the default value, so if the user sends your form, all values exist.
but, take care of escaping characters.