samedi 11 avril 2015

Get Input Value From Separate HTML File

For a project I am working on, I have to put together a large form (120+ fields) and store the information in the database.


I put together the form by creating a separate HTML file for each section of the form and then using one central PHP file to render all the files on one page (the entire form). A user can then fill out the form from that central page and submit the information, which will store everything in a database.


I am now needing to allow a user to edit a form that has been stored in the database. So, my plan is to create an edit file that, like the central file, will include all the sections of the form. I want to query the database to pull the specified row and populate all the fields of the form with the column values of that row.


The problem I am running into is I cannot figure out how to populate the fields of the form of the separate HTML files with a value.


All I have found that might be able to do this is javascript's getElementById() method. I have been trying to set the value of just one field with a test value, but have had no luck. This is the code I have right now



<html>

<head>
<h1 align="center">New Report</h1>
</head>

<form action="submit.php" method="POST">
<?php
include ("section1.html");
include ("section2.html");
include ("section3.html");
?>
<script>
document.getElementById("last_name").value = "Nathan"
</script>
<input type="submit" value="Submit">
</form>
</html>


The id "last_name" is from section1.html. However, that code seems to do nothing at all.


I am unsure how to do this. Any help would be appreciated.


Aucun commentaire:

Enregistrer un commentaire