Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

hidden fields? 2

Status
Not open for further replies.

NeilBelgium

IS-IT--Management
Sep 18, 2001
87
BE
I'm not really sure how these work.
I've created an update form where the user inputs his/her name, weekly news and I also want to include the date in the form, as a hidden field.

How on earth is this accomplished?
thanks, neil
 
Neil,

In the past week have any of the answered posts been what you required? You have not indicated one way or the other. I don't mind helping - but please let us know if your problem is solved prior to jumping into another one.

Stuart
 
Thaniks schase. I should have done that, I know! Will sift through all the oldies immediately
 
Thanks Neil - I wasnt complaining - Just keeping things sorted.

I've run into a similiar date thing - let me find it

Stuart
 
One approach to this task is to setup a hidden field (Insert > Form Objects > Hidden Field). Once the hidden field has been added, select the yellow icon that represents the hidden field and go to the Property inspector. In the Value field, enter the appropriate code for the date function:

ASP: <%= Date() %>
JSP: <%= new java.util.Date() %>

ColdFusion: #Now()#


If you want to give the user the option to change the date to something other than today's date, then use a regular text field instead of a hidden field.

When filling out the Insert Record server behavior dialog box, map the hidden form field to the date field in the database and set the data type to either &quot;Date&quot; or &quot;MS Access Date&quot;.


Note: The date being inserted will be the date on the application server. Keep this in mind if users are in different time zones.
Setting the default value in the database
Another approach to this task is to set the default value of the database's date field to the current system date. Most, if not all, databases will have a &quot;default value&quot; option for database fields. One advantage to using this approach is that you do not have to worry about the date format being sent from the Web page. Here is how to set the default value to today's date in Microsoft Access 2000:

1 Open the database in Microsoft Access. This example uses the UltraDev 4 tutorial database, Compass Travel (compasstravel.mdb).

2 Open the appropriate database in Design View, and select the date field.
3 Go to the General tab in the bottom section of the window and type &quot;Date()&quot; (no quotes) in the Default Value field.


4 Save and close the database, and go back to UltraDev to finish the insert page.
5 When filling out the Insert Record server behavior dialog box in UltraDev, you will not map a form field to the date field in the database. The database will automatically fill in the current date when a new record is created.

Please refer to the Microsoft Access documentation for further detail on setting default values. If you are not using Access, please refer to your database documentation for instructions on how to set the default date value.

Note: The date being inserted will be the date on the database server. Keep this in mind if users are in different time zones.

+++++
***If you found my post or other's posts helpful - please let us know by clicking the helpful link below our posts.

Stuart
 
You bet - let me know if I can help

Stuart
 
thanks.

I'm still having trouble with this very simple form!

I'm getting the error message:
Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][ODBC Microsoft Access Driver] Field 'news.Name' cannot be a zero-length string.
/0301/newsupdate.asp, line 89

this has come about , I think, since I changed the name field into a drop-down menu, which seems to me the logical way to approach the form:
the form only has two visible fields, name (choose from selection) and news, allowing the user to enter their news.
 
Ok, what it is telling you is you tried to enter a record without a value in one of the fields.

Field Name.

You mention you have a drop down menu - in addition to the list do you have their cooresponding value also?

Like this sourcecode I have on a page for a drop down state selection. - cutting out most of the states.

<select name=&quot;State&quot;>
<option selected>Select State</option>
<option value=&quot;AL&quot;>Alabama AL</option>
<option value=&quot;AK&quot;>Alaska AK</option>
<option value=&quot;AR&quot;>ArkansasAR</option> </select>

If that does not work. Check the spelling on both the database - and your form fields. Case sensitive. The field name has to be exactly what the field is on the database.

If that fails. Cut and paste the code here. So I can take a peek.

Hollar if you get stuck :)

Stuart
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top