Chezshire Posted July 5, 2008 Share Posted July 5, 2008 Hi -- I know next to nothing about JavaScript, beyond that i think it's neat and wonderful and I'm glad it exists because it does so many wonderful things. That said, my java word counter works really spiffy when you enter something into it. However if you use the edit function to go into a post, all the previously entered text that should be in the 'Messages' window evaporates/vanishes rather then staying put so it can be edited. This is the Javascript i added: <SCRIPT language="javascript"> // Live Word Count Script - added May 2nd --> function wordCounter(field, countfield, maxlimit) { wordcounter=0; for (x=0;x<field.value.length;x++) { if (field.value.charAt(x) == " " && field.value.charAt(x-1) != " ") {wordcounter++} // Counts the spaces while ignoring double spaces, usually one in between each word. if (wordcounter > 9999) {field.value = field.value.substring(0, x);} else {countfield.value = maxlimit - wordcounter;} } } function textCounter(field, countfield, maxlimit) { if (field.value.length > maxlimit) {field.value = field.value.substring(0, maxlimit);} else {countfield.value = maxlimit - field.value.length;} } // End --> </script> This is the PHP which displays the text to be edited when in 'edit post mode' <SCRIPT language="javascript"> // Live Word Count Script - added May 2nd --> function wordCounter(field, countfield, maxlimit) { wordcounter=0; for (x=0;x<field.value.length;x++) { if (field.value.charAt(x) == " " && field.value.charAt(x-1) != " ") {wordcounter++} // Counts the spaces while ignoring double spaces, usually one in between each word. if (wordcounter > 9999) {field.value = field.value.substring(0, x);} else {countfield.value = maxlimit - wordcounter;} } } function textCounter(field, countfield, maxlimit) { if (field.value.length > maxlimit) {field.value = field.value.substring(0, maxlimit);} else {countfield.value = maxlimit - field.value.length;} } // End --> </script> If i use this php, the text does not vanish, but the word counter doesn't display/work when in edit mode. <tr> <td align="right" valign="top"><p><b>Message:</b></p></td> <td><textarea name=CONTENT rows=12 cols=50 wrap=virtual><?php echo $content; // <br><a href="javascript:DoSpellCheck(window.document.postMessage.CONTENT.value)">[spell Check]</a> ?></textarea></td> </tr> Any help would be appreciated by everyone on our stupid little homebrewed site. Thank you very much for stopping and taking the time to look at a novices work. Thanks Quote Link to comment Share on other sites More sharing options...
Chezshire Posted July 5, 2008 Author Share Posted July 5, 2008 I just realized i didn't have an 'echo content in the php' so it all works nicely now - sorry to bother! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.