Here is the problem i am faced with:
I have a database that people use as a Web Page Management Tool to help some of the staff keep track of the updates to web pages they make.
When someone wishes to add a web page to the database, they use a form on the appropriate page. When they add the web page to the database, the time of last update might be either now or a date in the past if it hasn't been edited since. I have a button on the form that i want to change the value of the last updated input field to today's date. However when i click on the button, it seems to submit the form, despite the fact it is a <button> not an <insert type="submit">.
The code for the form is:
<?php
function addwebpageform(){
$t=time();
$now=date("Y-m-d",$t);
?>
<table border="1">
<tr>
<th>
Webpage ID
</th>
<th>
Reference Number
</th>
<th>
Version Number
</th>
<th>
Description
</th>
</tr>
<tr>
<form action="addwebpage_action.php" method="POST">
<td>
<center> - </center>
</td>
<td>
<input type="text" name="referenceno">
</td>
<td>
<input type="text" name="versionno">
</td>
<td>
<input type="text" name="description">
</td>
</tr>
<tr>
<th>
Last Updated
</th>
<th>
Update Frequency
</th>
<th>
Status
</th>
<th>
URL
</th>
</tr>
<tr>
<td>
<input type="text" name="lastupdated" value="YYYY-MM-DD" id="lastup">
</td>
<td>
<select name="updatefrequency">
<option value="3 Months">3 Months</option>
<option value="6 Months">6 Months</option>
<option value="12 Months">12 Months</option>
<option value="24 Months">24 Months</option>
</select>
</td>
<td>
<select name="status">
<option value="Review">Under Review</option>
<option value="Completed">Completed</option>
<option value="Live">Live</option>
</select>
</td>
<td>
<input type="text" name="url">
</td>
</tr>
<tr>
<td colspan="4">
<button onclick="document.GetElementByID('lastup').value=$now">Now</button><input type="submit" value="Add Webpage">
</td>
</tr>
</form>
</table>
<?php
}
The bits in particular are at the top where i set today's date as the $now variable, and then near the bottom, where i change the value of the field with ID "lastup".
Does anyone have any idea how to go about this?
Cheers
James