Clearing WML variables in forms

If a form is reused (or a second form is used with the same input field names as the first) on a WML device during a single session, the browser may recall the input values previously entered by the user, rather than the default values specified in the XDIME markup. This is normal behavior on WML devices, where the variables used to store input data are scoped more widely than in HTML forms.

If a form is reused (or a second form is used with the same input field names as the first) on a WML device during a single session, the browser may recall the input values previously entered by the user, rather than the default values specified in the XDIME markup. This is normal behavior on WML devices, where the variables used to store input data are scoped more widely than in HTML forms.

If you wish to avoid this behavior then there are two ways to clear the variables:

You can specify the uaContext attribute value of "new" on the XDIME canvas element surrounding the form. This method will clear all variables and other context in the WML browser when the canvas is loaded. However, it will also clear all navigation history from the browser, so you should use it with caution.

As an alternative you can use the nativemarkup element to explicitly specific WML variables. In the example, two input elements, Field1 and Field2, are cleared when the WML card containing the form is entered in a forward direction. The values are preserved if the form is re-entered using the 'back' button. MCS ignores this when rendering output for non-WML protocols.

<nativemarkup targetLocation="wml.card.onevent">  
  <onevent type="onenterforward">  
    <refresh>   
      <setvar name="Field1" value=""/>  
      <setvar name="Field2" value=""/> 
    </refresh> 
  </onevent>
</nativemarkup>

Related topics