wood burning stoves*
The moose likes HTML, CSS and JavaScript and the fly likes Disable Form - Java Script Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Disable Form - Java Script" Watch "Disable Form - Java Script" New topic

Disable Form - Java Script

Wu Tang

Joined: Oct 31, 2008
Posts: 4
Hello I'm unfamiliar with JS and I need to find a way to disable a form I've created once a condition is met. Essentially, I will pull data from a database and bases on that data the page will be editable or read only. I know how the pull the information, but don't know how to disable the page using Java Script. Here is my code:

<html:form action="/SpecifyProjectRank.do">
<input type="hidden" name="allAppByUser" value="<bean:write name="sessionUser" property="username"/>" />
<html:hidden property="projectCode"/>
<html:hidden property="allocationID"/>
<table width="100%" height="100%">
<td id="projectHeader" height="20%">
<h1 style="font-size:9pt;font-weight:bold;height:20px;margin:0;padding:0">Allocation</h1>
<table width="100%" class="main">
<td align="left"><b>Fiscal Year:</b><br>
<html:text property="years" style="border:none;"disabled="false"/></td>
<td align="left"><b>Service:</b><br>
<html:text property="serviceName" style="border:none;"disabled="false"/></td>
<td align="left"><b>Base:</b><br>
<html:text property="baseName" style="border:none;"disabled="false"/></td>
<td align="left"><b>State:</b><br>
<html:text property="stateCode" style="border:none;"disabled="false"/></td>
<td align="left" width="20%"><a href="#">View Proposal PDF</a></td>
<td align="left"><b>Primary Justification:</b>
<html:text property="justDesc" style="border:none;" disabled="false"/></td>
<td align="left"><b>Serivce Rank:</b>
<html:text property="serviceProjectRank" style="border:none;" disabled="false"/></td>
<td align="left"><b>Project Status:</b>
<html:text property="statusDesc" style="border:none;" disabled="false"/></td>
<td> </td>
<td align="left"><a href="EditProject.do?projectCode=<%=((HttpServletRequest)req).getParameter("projectCode")%>"/>Edit Details</a></td>
<td align="left"><b>Created On:</b>
<html:text property="dateCreated" style="border:none;"disabled="false" /></td>
<td align="left"><b>Created By:</b>
<html:text property="createdByUser" style="border:none;" disabled="false"/></td>
<td align="left"><b>Updated On:</b>
<html:text property="dateLastUpdated" style="border:none;" disabled="false"/></td>
<td align="left"><b>Updated By:</b>
<html:text property="updatedByUser" style="border:none;" disabled="false"/></td>
<td align="left"><b>Headquarters POC Name:</b><br>
<html:text property="hQPocName" style="border:none;" disabled="false"/></td>
<td valign="top" align="left"><b>Headquarters POC Phone:</b><br>
<html:text property="hQPocPhone" style="border:none;" disabled="false"/></td>
<td valign="top" align="left"colspan="2"><b>Headquarters POC Email:</b><br>
<html:text property="hQPocEmail" style="border:none;" disabled="false"/></td>
<td align="left">
<b>Total Proposed Project Funds:</b><br>
<html:text property="proposedTotal" style="border:none;" disabled="false"/>
<td align="left">
<b>Total Project Funds Expended to Date:</b><br>
<html:text property="expToDate" style="border:none;" disabled="false"/>
<td id="projectTabs" height="%" valign="top" align="left">
<table class="main">
<td style="border:solid grey 1px;background-color:lightgrey"><a href="ProjectDetailProposalService.do?projectCode=<%=((HttpServletRequest)req).getParameter("projectCode")%>"/>Proposal</a></td>
<td style="border:solid grey 1px">Allocation</td>
<td style="border:solid grey 1px;background-color:lightgrey"><a href="ProjectDetailObligation.do?projectCode=<%=((HttpServletRequest)req).getParameter("projectCode")%>"/>Obligation</a></td>
<td style="border:solid grey 1px;background-color:lightgrey"><a href="ProjectDetailExpenditure.do?projectCode=<%=((HttpServletRequest)req).getParameter("projectCode")%>"/>Expenditure</a></td>
<table width="100%" class="main" >
<td valign="top" align="left"><b>Initial OSD Rank:</b><br>
<html:text property="initialOsdRank" styleClass="required" disabled="false"/>
<td valign="top" align="left"><b>Initial Allocation:</b><br>
<html:text property="initialAllAmount" disabled="false"/>
<td valign="top" align="left"><b>Revised OSD Rank:</b><br>
<html:text property="revisedOsdRank"disabled="false"/>
<td valign="top" align="left"><b>Revised Allocation:</b><br>
<html:text property="revisedAllAmount"disabled="false"/>
<td valign="top" align="left"><b>Final OSD Rank:</b><br>
<html:text property="finalOsdRank" styleClass="required" disabled="false"/>
<td valign="top" align="left"><b>Final Allocation:</b><br>
<html:text property="finalAllAmount" styleClass="required" disabled="false"/>
<td valign="top" align="left" colspan="2"><b> Notes:</b><br>
 <html:textarea property="allNotes" style="width:50%;"disabled="false">
Eric Pascarello

Joined: Nov 08, 2001
Posts: 15376
Maybe some HTML attributes would help:


Arun Kumar
Ranch Hand

Joined: Oct 10, 2007
Posts: 30
Have a form name(form1) and refer to it in javascript.
You could call invoke javascript function on checking condition

<script language="javascript">

function enableForm()
function disableForm()
Jack Berring

Joined: Feb 15, 2013
Posts: 1
Is this topic still active?

Crap, nevermind.
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 60765

If you still have a question feel free to open your own topic on it!

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
I agree. Here's the link: http://aspose.com/file-tools
subject: Disable Form - Java Script
Similar Threads
Struts: Getting a blank page instead of the form
HTML does not print properly - table width exceeding 100%?
Visualizing Struts Froms
Tiles error, not able to find a value for attribute
radio buttons and buttons