Search these areas:
Help
Support Forums
Product Info



-Introduction
-DataWeb: What's New
-Creating an Application
-The DataWeb Designer
-Application Management
-Data Tables
-Data Tables
-Views
-Templates
-Components
-Data Analysis
-Members
-Security
-Importing
-Exporting
-FTP
-JavaScript
-Object Model
-Full-Text Search
-Domain and Email Hosting
-HotBlock Modules
-Account Management
-Glossary
-New Responsive UI Module





DataWeb Help
Support Forums
Tutorial
Script Library
Knowledge Base

Home > Support

KnowledgeBase


How To: Set a field's default value
Article TypeHow To
TitleSet a field's default value
<i>How do I set the default value for a field?</i><br>
<br>
The answer to this question depends on whether you want to set a default value regardless of where inserts are made from or if your default value is view-specific.<br>
<br>
<br>
To set a default value regardless of how data is inserted into a table, write a script in the table's <a href="http://support.dataweb.com/Help/default.view?Topic=DataWebscript/dataclasses/wsdataclasscreate">BeforeInsert Data Class</a>.<br>
<br>
For example, to set the default value of the <span class="smallCode">state</span> field to "WA":<br>
<br>
<span class="smallCode">// If the user does not specify a state, set state to WA<br>
if ( !record.state ) { record.state = "WA"; }</span><br>
<br>
<br>
To set a default on a specific view form, write a <a href="/default.view?Topic=views/vaddingscripts">script on that view</a> inside a dataregion. Make sure you place the htmlblock <i>before</i> the field whose default value you're setting.<br>
<br>
<span class="smallCode">&lt;ws:htmlblock displaymodes="insert"><br>
&lt;!--#record.state = "WA";#--><br>
&lt;/ws:htmlblock><br>
<br>
&lt;ws:field name="state" displaymodes="insert">&lt;ws:caption>State:&lt;/ws:caption>&lt;/ws:field></span>
Last ReviewedFebruary 20, 2015 14:08:26

  
Affiliate | Partner | Terms of Use | Privacy Policy | Contact Us | Pricing | Bring DataWeb In-House    
Email Us