ClueLess
12-13-2002, 03:03 PM
I have an information form; actually, it works great so far as what I want. But, I still need help.
Here is how the form works:
I have 1 form, it handles for 2 situations: DELETE and ADD.
1- If the form has values (information), it shows a DELETE checkbox and the form (has values). It works great.
2- If it is new (no information), it shows an ADD checkbox and a blank form - it works fine too. But, I need your help for this new form. We would like to DISABLE all the textboxes, if the add checkbox has not checked/selected. The question is: Can 1 form handle for both DISABLE and ABLE? If it is, how can we do it?
below is the code:
<html>
<head>
<title>Information</title>
</head>
<body>
<script language="JavaScript">
function ManageAction(doit) {
var result
var Name
document.SubmitForm.Action.value = ''
Name = doit.name
switch (Name)
{
case "LPdelete":
if (document.SubmitForm.LPdelete.checked) {
result=(confirm('Are you sure you want to delete this record?'));
//you assign value to your hidden filed
if (result == true)
{
document.SubmitForm.Action.value = 'D';
}
else
{
document.SubmitForm.LPdelete.checked = 0;
}
}
break;
case "LPadd":
if (document.SubmitForm.LPadd.checked)
{
//if chkbox value "Add" do this
document.SubmitForm.Action.value = 'A';
//return false;
}
break;
}
}
</script>
<FORM action="information.asp" method="post" id="SubmitForm" name="SubmitForm" onsubmit="ShowDate()">
<INPUT type="Hidden" name="Action" id="Action" value="">
<table>
<tr>
<%if request.form ("Action") = "A" then%>
<td width="40" align="right" class="regularParagraph">
DELETE <INPUT type="checkbox" value='Delete' id='LPdelete' name='LPdelete' onClick='ManageAction(this);'>
</td>
<%else%>
<td width="40" align="right" class="regularParagraph">
ADD <INPUT type="checkbox" value='LPadd' id='LPadd' name='LPadd' onClick='ManageAction(this);'>
</td>
<%end if %>
</tr>
<tr>
<td class="SmallHeadingBurg" width="180"> Name: </td>
<td class="regularParagraph" align="left">
<INPUT style="border:1 solid #000000" type="text" id="LPName" name="LPName" value="<%= (LPName) %>" maxlength="30" size="38">
</td>
</tr>
<tr>
<td class="SmallHeadingBurg" width="180">Address: </td>
<td class="regularParagraph" align="left">
<INPUT style="border:1 solid #000000" type="text" id="LPaddress" name="LPaddress" value="<%= (LPAddress) %>" maxlength="30" size="38">
</td>
</tr>
<tr>
<td class="SmallHeadingBurg" width="180">City: </td>
<td class="regularParagraph" align="left">
<INPUT style="border:1 solid #000000" type="text" id="LPCity" name="LPCity" value="<%= (LPCity) %>" maxlength="30" size="38">
</td>
</tr>
<tr>
<td>
<input type="submit" value="Update" name="UpdateInfo" class="ActionButton">
</td>
</tr>
</table>
</body>
</html>
Here is how the form works:
I have 1 form, it handles for 2 situations: DELETE and ADD.
1- If the form has values (information), it shows a DELETE checkbox and the form (has values). It works great.
2- If it is new (no information), it shows an ADD checkbox and a blank form - it works fine too. But, I need your help for this new form. We would like to DISABLE all the textboxes, if the add checkbox has not checked/selected. The question is: Can 1 form handle for both DISABLE and ABLE? If it is, how can we do it?
below is the code:
<html>
<head>
<title>Information</title>
</head>
<body>
<script language="JavaScript">
function ManageAction(doit) {
var result
var Name
document.SubmitForm.Action.value = ''
Name = doit.name
switch (Name)
{
case "LPdelete":
if (document.SubmitForm.LPdelete.checked) {
result=(confirm('Are you sure you want to delete this record?'));
//you assign value to your hidden filed
if (result == true)
{
document.SubmitForm.Action.value = 'D';
}
else
{
document.SubmitForm.LPdelete.checked = 0;
}
}
break;
case "LPadd":
if (document.SubmitForm.LPadd.checked)
{
//if chkbox value "Add" do this
document.SubmitForm.Action.value = 'A';
//return false;
}
break;
}
}
</script>
<FORM action="information.asp" method="post" id="SubmitForm" name="SubmitForm" onsubmit="ShowDate()">
<INPUT type="Hidden" name="Action" id="Action" value="">
<table>
<tr>
<%if request.form ("Action") = "A" then%>
<td width="40" align="right" class="regularParagraph">
DELETE <INPUT type="checkbox" value='Delete' id='LPdelete' name='LPdelete' onClick='ManageAction(this);'>
</td>
<%else%>
<td width="40" align="right" class="regularParagraph">
ADD <INPUT type="checkbox" value='LPadd' id='LPadd' name='LPadd' onClick='ManageAction(this);'>
</td>
<%end if %>
</tr>
<tr>
<td class="SmallHeadingBurg" width="180"> Name: </td>
<td class="regularParagraph" align="left">
<INPUT style="border:1 solid #000000" type="text" id="LPName" name="LPName" value="<%= (LPName) %>" maxlength="30" size="38">
</td>
</tr>
<tr>
<td class="SmallHeadingBurg" width="180">Address: </td>
<td class="regularParagraph" align="left">
<INPUT style="border:1 solid #000000" type="text" id="LPaddress" name="LPaddress" value="<%= (LPAddress) %>" maxlength="30" size="38">
</td>
</tr>
<tr>
<td class="SmallHeadingBurg" width="180">City: </td>
<td class="regularParagraph" align="left">
<INPUT style="border:1 solid #000000" type="text" id="LPCity" name="LPCity" value="<%= (LPCity) %>" maxlength="30" size="38">
</td>
</tr>
<tr>
<td>
<input type="submit" value="Update" name="UpdateInfo" class="ActionButton">
</td>
</tr>
</table>
</body>
</html>