As due to same ID of the text box the JS function is not showing the proper result and the characterleft count is not decreasing automatically.
<script type="text/javascript">
currentSelectionOnPage = <%=currentSelectionOnPage%>;
function charsleft()
{
theInputBox = document.getElementById('messageText');
theCountBox = document.getElementById('charsLeft');
var currentChars = theInputBox.value.length;
theCountBox.value = Math.max((maxChars - currentChars),0);
if(currentChars > maxChars)
{
theInputBox.value = theInputBox.value.substring(0,maxChars);
}
}
</Script>
for( int i = 0; i < 10; i++ ) {
if(competencyAreaDTO.getComment()) {
String commentSelKey = new String(String.valueOf(counter+1)+"_COMMENTS");
String prevCommetSelection = new String();
int charLeft =(int) new Integer(500);
if(userSelection.get(commentSelKey) != null) {
prevCommetSelection = (String) userSelection.get(commentSelKey);
charLeft = 500 - (prevCommetSelection.length());
}
<tr>
<td height="10" > </td>
</tr>
<tr>
<td height="10" ></td>
</tr>
<tr>
<td colspan="8"><textarea id="messageText" onchange="charsleft()" ><%=prevCommetSelection%></textarea></td>
</tr>
<tr>
<td colspan="8">
<input type="text" ><b> Characters Left</b></font>
</td>
</tr>
<tr>
<td height="10" > </td>
</tr>
}
This post has been edited by Dormilich: 11 March 2011 - 04:48 AM
Reason for edit:: please use [code] /* your code source here */ [/code] tags when posting code

New Topic/Question
Reply


MultiQuote



|