initial field values

M

MSwanson

Hell

I have created a database driven page where results are shown based on a search field at the top of the page. The user
enters the date and clicks search in order to view the data associated with a given day. Is there a way to make the curren
date appear in these fields automatically. For example, i have three fields year, month, day -- i understand that front page has some values availabe, is there a list on some web page out there or something to see the syntax and available values

Thank
MSwanson
 
J

Jim Buyens

MSwanson said:
Hello
Howdy.

I have created a database driven page where results are shown based on a
search field at the top of the page. The user enters the date and clicks search
in order to view the data associated with a given day. Is there a way to make
the current date appear in these fields automatically. For example, i have three
fields year, month, day -- i understand that front page has some values availabe,
is there a list on some web page out there or something to see the syntax and
available values?

This is something you have to program for the browser in JavaScript, or for
the Web server in whatever environment it supports. Here's an example that
uses JavaScript on the browser.

<html>
<head>
<title>Initialize Date Boxes</title>
<script>
function loadFormFields(){
if (document.forms[0].txtMon.value != "") return;
if (document.forms[0].txtDay.value != "") return;
if (document.forms[0].txtYear.value != "") return;
curDte = new Date();
document.forms[0].txtMon.value = curDte.getMonth() + 1;
document.forms[0].txtDay.value = curDte.getDate();
document.forms[0].txtYear.value = curDte.getYear();
}
</script>
</head>
<body onload="loadFormFields();">
<form method="POST">
<table border="0" cellspacing="1" id="table1">
<tr>
<td>Month</td>
<td><input type="text" name="txtMon" size="5"></td>
</tr>
<tr>
<td>Day</td>
<td><input type="text" name="txtDay" size="5"></td>
</tr>
<tr>
<td>Year</td>
<td><input type="text" name="txtYear" size="10"></td>
</tr>
</table>
<input type="submit" value="Submit" name="B1">
</form>
</body>
</html>

Notice that the onload= attribute in the <body> tag runs the
loadFormFields() function, and that the loadFormFields() function bails if
any of the text boxes already contain a value.

Jim Buyens
Microsoft FrontPage MVP
http://www.interlacken.com
Author of:
*----------------------------------------------------
|\---------------------------------------------------
|| Microsoft Office FrontPage 2003 Inside Out
||---------------------------------------------------
|| Web Database Development Step by Step .NET Edition
|| Microsoft FrontPage Version 2002 Inside Out
|| Faster Smarter Beginning Programming
|| (All from Microsoft Press)
|/---------------------------------------------------
*----------------------------------------------------
 
Top