I need JAVASCRIPT help - code editing (counting)

Discussion in 'JavaScript' started by Exhuminator, Jan 7, 2010.

  1. #1
    Hello, everyone.

    I found this JavaScript online - it's for calculating translation prices. Everything is working alright, except the characters count. This script now calculates all the characters, including spaces. I would like it to count only letters/numbers without spaces. Is that possible to edit?

    Here's the code.js code :)

    
    function countit(vorm){
    	
    	// Tähemärkide sisu
    	var sisu = vorm.form.tahemargid.value;
    	
    	// Tähemärkide pikkus
    	vorm.form.tahemarke.value = sisu.length;
    	var tahemargid = vorm.form.tahemarke.value;
    	
    	// Sőnadeks jaotamine
    	var sonad = sisu.split(" ");
    	var sonadehulk = sonad.length;
    	
    	//Sőnade arv
    	if (sonadehulk == 1) {
    		vorm.form.sonadehulk.value = 0;	
    	}
    	else {
    		vorm.form.sonadehulk.value = sonadehulk;
    	}
    	
    	// Lehekülgede arv
    	var pikkus = (sisu.length / 1500).toFixed(1);
    	vorm.form.lehekylgi.value = pikkus;
    	var lehekylgi = vorm.form.lehekylgi.value;
    	
    	/* Tőlkebüroo valitud hind */
    	var tolkeburoohind = vorm.form.buroohind.value;
    	
    	/* Kliendi enda lisatud hind */
    	var kliendihind = vorm.form.kliendivalitudhind.value;
    	
    	/* Kujundamise tasud */
    	var lisatasu =  vorm.form.toimetamine.value;
    	var lisatasud = lisatasu * lehekylgi;
    	
    	/* Tőlke hinna arvutamine */
    	var maksuvaba;
    	
    	if (tolkeburoohind == 0 && kliendihind == 0){alert("Select from and to languages or enter price per 1 page");}
    	if (tolkeburoohind != 0 && kliendihind != 0){alert("Both options cannot be chosen simultaneously. Select the language combination (from and to languages) or enter price per 1 page.");}
    	
    	
    	if (tolkeburoohind == 0 && kliendihind != 0 ){
    		maksuvaba = lehekylgi * kliendihind + lisatasud;
    	}
    	if (kliendihind == 0 && tolkeburoohind != 0){
    		maksuvaba = lehekylgi * tolkeburoohind + lisatasud;
    	}
    	vorm.form.maksuta.value = maksuvaba.toFixed(2);
    	
    	/* Käibemaksuga */
    	var maksuga = maksuvaba * 0.20;
    	maksuga = 0;
    	var loplikhind = maksuvaba + maksuga;
    	vorm.form.maksudega.value =  "EUR " + loplikhind.toFixed(2);
    	
    	//var remark = getElem
    
    }
    
    Code (markup):
    I will be very glad of every help.


    Cheers,


    Tilen
     
    Exhuminator, Jan 7, 2010 IP