Input Tag and Java Script Tag

The input tag can be used under enclosing Anchor Tag <a> (optional). The method call buttonClicked(this) is used as the first method on the event onClick() for providing the look and feel of clicking a button. The overlibWrapper('Clear') function shows the externalized tool tip. Clear is passed as the key for the tool tip whose externalized value is present in jsresources.properties file.

  • TYPE=button: Shows a button without any submit action. If you want to submit the page using button type input tag, set the submit action on the onClick event of <INPUT> or <ANCHOR> tag.
    <INPUT ID="btnClearImage" NAME="clear" TYPE="button" VALUE="Clear" onClick="buttonClicked(this); someMethod ();” CLASS="buttonCls" onMouseOver="return overlibWrapper('Clear');" onMouseOut="return nd();">
  • TYPE=submit: Shows a button with submit action. In this case, there is no need to set any explicit submit action. For the submit input type, ensure that you do not call submit action again in any of the method set on the event onClick().
    <INPUT ID="btnClearImage" NAME="clear" TYPE="submit" VALUE="Clear" CLASS="buttonCls" onClick=" buttonClicked(this); someMethod ();" onMouseOver="return overlibWrapper('Clear');" onMouseOut="return nd();">

Each <INPUT> tag has one associated <SCRIPT> tag, which is responsible for showing the externalized text on the button.

The following JavaScript section checks whether the ID is present or deleted in the HTML template. If it is present, the externalized text from the jsresources.properties file is set. The function getLocalizedString("Clear") is used to show the externalized button value. ‘Clear’ is the key for the button text which is present in jsresources.properties file.

<SCRIPT> if(document.getElementById("btnClearImage") != null)
document.getElementById("btnClearImage").value = getLocalizedString("Clear")
</SCRIPT>

Sample (Type=button)

<INPUT ID="btnClearImage" NAME="clear" TYPE="button" VALUE="Clear" onClick="buttonClicked(this); someMethod ();” CLASS="buttonCls" onMouseOver="return overlibWrapper('Clear');" onMouseOut="return nd();">
<SCRIPT>   if(document.getElementById("btnClearImage") != null)
document.getElementById("btnClearImage").value = getLocalizedString("Clear")
</SCRIPT>

Sample (Type=button: With anchor tag)

<A ID="btnClearHRef" onClick="buttonClicked(this); someMethod (); clearSearch();">
<INPUT ID="btnClearImage" NAME="clear" TYPE="button" VALUE="Clear" CLASS="buttonCls" onMouseOver="return overlibWrapper('Clear');" onMouseOut="return nd();">
<SCRIPT>   if(document.getElementById("btnClearImage") != null)
document.getElementById("btnClearImage").value = getLocalizedString("Clear")
</SCRIPT>
</A>

Sample (Type=submit)

<INPUT ID="btnClearImage" NAME="clear" TYPE="submit" VALUE="Clear" CLASS="buttonCls" onClick=" buttonClicked(this);" onMouseOver="return overlibWrapper('Clear');" onMouseOut="return nd();">
<SCRIPT>   if(document.getElementById("btnClearImage") != null)
document.getElementById("btnClearImage").value = getLocalizedString("Clear")
</SCRIPT>

Sample (Type=button: With anchor tag)

There is no need to use anchor tag if we are using input tag with type ‘submit’.