Aleks
asked on
click chekbox in repeated region to enable field for that one row
I have a repeated region with a checkbox and a textbox. The textbox is disabled by default, but if user checks the box for that one row then the text box for that one row should be enabled.
The checkbox name is:
<input name="itemid" type="checkbox" id="itemid" value="<%=(PaymentLines.Fi elds.Item( "Id").Valu e)%>">
The text field is:
<input name="amount" type="text" class="bodytext" id="amount" value="0" size="5" maxlength="10" disabled ="true">
As you can see it is disabled by default.
Checking the box should only enable the field for that particular row.
I tried using a script I have to disable a field and tweaking it but so far no luck.
I have:
<SCRIPT LANGUAGE="javaScript">
function disableme(first, second)
{
((first.checked == true)?second.disabled = true:second.disabled = false );
}
</SCRIPT>
The checkbox name is:
<input name="itemid" type="checkbox" id="itemid" value="<%=(PaymentLines.Fi
The text field is:
<input name="amount" type="text" class="bodytext" id="amount" value="0" size="5" maxlength="10" disabled ="true">
As you can see it is disabled by default.
Checking the box should only enable the field for that particular row.
I tried using a script I have to disable a field and tweaking it but so far no luck.
I have:
<SCRIPT LANGUAGE="javaScript">
function disableme(first, second)
{
((first.checked == true)?second.disabled = true:second.disabled = false );
}
</SCRIPT>
ASKER
Correction: This is the checkbox code:
<input name="itemid" type="checkbox" id="itemid" value="<%=(PaymentLines.Fi elds.Item( "Id").Valu e)%>" onClick="enableme(document .form1.ite mid,docume nt.form1.a mount);" >
I get no errors but the amount stays disabled when I check the box.
<input name="itemid" type="checkbox" id="itemid" value="<%=(PaymentLines.Fi
I get no errors but the amount stays disabled when I check the box.
Your function is expecting two parameters - you are only sending first
ASKER
I just updated but nothing happens. This is my current code:
Checkbox:
<input name="itemid" type="checkbox" id="itemid" value="<%=(PaymentLines.Fi elds.Item( "Id").Valu e)%>" onClick="enableme(document .form1.ite mid,docume nt.form1.a mount);" >
Text field:
<input name="amount" type="text" class="bodytext" id="amount" value="0" size="5" maxlength="10" >
Script:
<SCRIPT LANGUAGE="javaScript">
function enableme(first, second)
{
((first.checked == true)?second.disabled = true:second.disabled = false );
}
</SCRIPT>
Checkbox:
<input name="itemid" type="checkbox" id="itemid" value="<%=(PaymentLines.Fi
Text field:
<input name="amount" type="text" class="bodytext" id="amount" value="0" size="5" maxlength="10" >
Script:
<SCRIPT LANGUAGE="javaScript">
function enableme(first, second)
{
((first.checked == true)?second.disabled = true:second.disabled = false );
}
</SCRIPT>
Your logic is the wrong way round, should be
function enableme(first, second) {
((first.checked == true) ? second.disabled = false : second.disabled = true);
}
ASKER
Works fine when not inside a repeat region. When inside of it doenst work, this is the code for my repeat region using the script above.
--- Code ---
<%
Dim RecordCounter
RecordCounter = 0
%>
<%
While ((Repeat1__numRows <> 0) AND (NOT PaymentLines.EOF))
%>
<tr <%
RecordCounter=RecordCounte r + 1
If RecordCounter Mod 2 = 1 Then
Response.Write("bgcolor=#F BFBFB")
End If
%>
bgcolor="#FFFFFF" onMouseOver="this.style.ba ckgroundCo lor='#FFFF CC'" onMouseOut="this.style.bac kgroundCol or=''">
<td width="10"> </td>
<td><div align="center">
<input name="itemid" type="checkbox" id="itemid" value="<%=(PaymentLines.Fi elds.Item( "Id").Valu e)%>" onClick="enableme(document .form1.ite mid,docume nt.form1.a mount);" >
</div></td>
<td><table width="9" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="4"><img src="../../Images/blank.gi f" alt="" width="4" height="25" /></td>
<td width="2" height="14"><img src="../../Images/menus/se parator.gi f" alt="" /></td>
<td width="10"><img src="../../Images/blank.gi f" alt="" width="4" height="25" /></td>
</tr>
</table></td>
<td><span class="bodytext"><%=(Payme ntLines.Fi elds.Item( "ItemDesc" ).Value)%> </span></t d>
<td width="15" valign="middle"><table width="9" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="4"><img src="../../Images/blank.gi f" alt="" width="4" height="25" /></td>
<td width="2" height="14"><img src="../../Images/menus/se parator.gi f" alt="" /></td>
<td width="10"><img src="../../Images/blank.gi f" alt="" width="4" height="25" /></td>
</tr>
</table></td>
<td class="bodytextreports" ><div align="right" class="bodytext"><%= FormatCurrency((PaymentLin es.Fields. Item("PmtR ecd").Valu e), 2, -2, -2, -2) %></div></td>
<td width="17"><table width="12" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="4"><img src="../../Images/blank.gi f" alt="" width="4" height="25" /></td>
<td width="10" height="14"><img src="../../Images/menus/se parator.gi f" alt="" /></td>
<td width="4"><img src="../../Images/blank.gi f" alt="" width="4" height="25" /></td>
</tr>
</table>
<div align="center"></div></td>
<td width="81" ><div align="right"><%= FormatCurrency((PaymentLin es.Fields. Item("Bala nce").Valu e), 2, -2, -2, -2) %></div></td>
<td ><table width="12" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="4"><img src="../../Images/blank.gi f" alt="" width="4" height="25" /></td>
<td width="10" height="14"><img src="../../Images/menus/se parator.gi f" alt="" /></td>
<td width="4"><img src="../../Images/blank.gi f" alt="" width="4" height="25" /></td>
</tr>
</table>
<div align="center"></div></td>
<td width="106" ><div align="center">$
<input name="amount" type="text" class="bodytext" id="amount" value="0" size="5" maxlength="10" disabled>
</div></td>
</tr>
<tr>
<td colspan="11" background="../../Images/m enus/separ atortop.gi f"><img src="../../Images/blank.gi f" alt="" width="10" height="3"></td>
</tr>
<%
Repeat1__index=Repeat1__in dex+1
Repeat1__numRows=Repeat1__ numRows-1
PaymentLines.MoveNext()
Wend
%>
------
--- Code ---
<%
Dim RecordCounter
RecordCounter = 0
%>
<%
While ((Repeat1__numRows <> 0) AND (NOT PaymentLines.EOF))
%>
<tr <%
RecordCounter=RecordCounte
If RecordCounter Mod 2 = 1 Then
Response.Write("bgcolor=#F
End If
%>
bgcolor="#FFFFFF" onMouseOver="this.style.ba
<td width="10"> </td>
<td><div align="center">
<input name="itemid" type="checkbox" id="itemid" value="<%=(PaymentLines.Fi
</div></td>
<td><table width="9" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="4"><img src="../../Images/blank.gi
<td width="2" height="14"><img src="../../Images/menus/se
<td width="10"><img src="../../Images/blank.gi
</tr>
</table></td>
<td><span class="bodytext"><%=(Payme
<td width="15" valign="middle"><table width="9" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="4"><img src="../../Images/blank.gi
<td width="2" height="14"><img src="../../Images/menus/se
<td width="10"><img src="../../Images/blank.gi
</tr>
</table></td>
<td class="bodytextreports" ><div align="right" class="bodytext"><%= FormatCurrency((PaymentLin
<td width="17"><table width="12" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="4"><img src="../../Images/blank.gi
<td width="10" height="14"><img src="../../Images/menus/se
<td width="4"><img src="../../Images/blank.gi
</tr>
</table>
<div align="center"></div></td>
<td width="81" ><div align="right"><%= FormatCurrency((PaymentLin
<td ><table width="12" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="4"><img src="../../Images/blank.gi
<td width="10" height="14"><img src="../../Images/menus/se
<td width="4"><img src="../../Images/blank.gi
</tr>
</table>
<div align="center"></div></td>
<td width="106" ><div align="center">$
<input name="amount" type="text" class="bodytext" id="amount" value="0" size="5" maxlength="10" disabled>
</div></td>
</tr>
<tr>
<td colspan="11" background="../../Images/m
</tr>
<%
Repeat1__index=Repeat1__in
Repeat1__numRows=Repeat1__
PaymentLines.MoveNext()
Wend
%>
------
Post the rendered HTML
Every input has the same name, you should give each one a unique name or ID - otherwise how is the code supposed to know which one to enable.
Every input has the same name, you should give each one a unique name or ID - otherwise how is the code supposed to know which one to enable.
ASKER
I understand this, how can I do this ? Say for example I use the id of the row to be added to both the checkbox and the amount ?
this is the id value: <%=(PaymentLines.Fields.It em("Id").V alue)%>
Right now the name is:
name="itemid"
name="amount"
what would the syntax be to append the id to the name so that it is unique ?
this is the id value: <%=(PaymentLines.Fields.It
Right now the name is:
name="itemid"
name="amount"
what would the syntax be to append the id to the name so that it is unique ?
ASKER
I tried:
<input name="itemid<%=(PaymentLin es.Fields. Item("Id") .Value)%>" type="checkbox" id="<%=(PaymentLines.Field s.Item("Id ").Value)% >" value="<%=(PaymentLines.Fi elds.Item( "Id").Valu e)%>" onClick="enableme(document .form1.ite mid,docume nt.form1.a mount);" >
and
<input name="amount<%=(PaymentLin es.Fields. Item("Id") .Value)%>" type="text" class="bodytext" id="amount" value="0" size="5" maxlength="10" disabled >
<SCRIPT LANGUAGE="javaScript">
function enableme(first, second) {
((first.checked == true) ? second.disabled = false : second.disabled = true);
}
</SCRIPT>
I check the box .. nothing happens :#
<input name="itemid<%=(PaymentLin
and
<input name="amount<%=(PaymentLin
<SCRIPT LANGUAGE="javaScript">
function enableme(first, second) {
((first.checked == true) ? second.disabled = false : second.disabled = true);
}
</SCRIPT>
I check the box .. nothing happens :#
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
There is a problem though. The values are passed on to the next page where an array is created from the comma delimited value that is passed under the name of 'itemid' ...
If I change the name it messes up the second page : (
Is there a way to enable the field without having to change the names ?
If I change the name it messes up the second page : (
Is there a way to enable the field without having to change the names ?
I haven't changed the name
ASKER
How can I make it unique for the toggle to work without changing the name then ?
Did you not see the code I posted above?
ASKER
I didn't my apologies, let me try it
ASKER
AWEEESOOOMEEE !!! Thank you so much .. I am getting closer to finishing this page :)
ASKER
:) !!!
ASKER
<SCRIPT LANGUAGE="javaScript">
function enableme(first, second)
{
((first.checked == true)?second.disabled = false:second.disabled = true );
}
</SCRIPT>
<input name="itemid" type="checkbox" id="itemid" value="<%=(PaymentLines.Fi
No luck so far