Home » Nyheder » Blog » Joomla » Text Area Word Counter

Text Area Word Counter

I needed to get a word counter for a text area that could calculate the amount of words and then multiply that number to get a price for carrying out a translation - you can see the script in action here: http://easytranslate.dk/da/korrekturlaesning.html

The line with pri.value = cnt*5; The five is the multiplication factor you need to change.

The script:

<label style="width: 150px;"><br />Insert your tekst here:</label><br />
<textarea rows="15" id="text_12" title="" cols="60" name="text_12" onkeyup="wordcount(this.value)"></textarea>
<script type=""text/javascript"">
var cnt;
function wordcount(count) {
var words = count.split(/\s/);
cnt = words.length;
var ele = document.getElementById('w_count');
ele.value = cnt;
var pri = document.getElementById('price');
pri.value = cnt*5;
}
document.write("<input type=hidden id=w_count size=14 readonly>");
document.write("<input type=text id=price size=14 readonly>");


</script>
DKK incl. tax for your translation.

Tilføj kommentar


Sikkerhedskode
Opdater