07. oktober 2006 - 21:50Der er
6 kommentarer og 1 løsning
omskrivning af function
Nogen der har mod på at skrive denne om så jeg ikke få punktummer, men komma'er i alle felter, samt momsfeltet og totalfeltet kun må have 2 decimaler ?
function addformdata(theform) { var total = 0; var tal; tal = parseFloat(theform.softwarepris.value.replace(/,/g,".")); if (isNaN(tal)==false) { total += tal; } tal = parseFloat(theform.hardwarepris.value.replace(/,/g,".")); if (isNaN(tal)==false) { total += tal; } tal = parseFloat(theform.netværkpris.value.replace(/,/g,".")); if (isNaN(tal)==false) { total += tal; } tal = parseFloat(theform.tilbehørpris.value.replace(/,/g,".")); if (isNaN(tal)==false) { total += tal; } tal = parseFloat(theform.timeogkvarterpris.value.replace(/,/g,".")); if (isNaN(tal)==false) { total += tal; } theform.momspris.value = total*0.25; theform.total.value=total + parseFloat(theform.momspris.value); }
Denne side indeholder artikler med forskellige perspektiver på Identity & Access Management i private og offentlige organisationer. Artiklerne behandler aktuelle IAM-emner og leveres af producenter, rådgivere og implementeringspartnere.
så er den rettet med 2 decimaler, så er det kun punktum til komma, anyone ?
function addformdata(theform) { var total = 0; var tal; tal = parseFloat(theform.softwarepris.value.replace(/,/g,".")); if (isNaN(tal)==false) { total += tal; } tal = parseFloat(theform.hardwarepris.value.replace(/,/g,".")); if (isNaN(tal)==false) { total += tal; } tal = parseFloat(theform.netværkpris.value.replace(/,/g,".")); if (isNaN(tal)==false) { total += tal; } tal = parseFloat(theform.tilbehørpris.value.replace(/,/g,".")); if (isNaN(tal)==false) { total += tal; } tal = parseFloat(theform.timeogkvarterpris.value.replace(/,/g,".")); if (isNaN(tal)==false) { total += tal; } theform.momspris.value = (total.toFixed(2)*0.25).toFixed(2); theform.total.value=parseFloat(total.toFixed(2)) + parseFloat(theform.momspris.value); }
function addformdata(theform) { var total = 0; var tal; tal = parseFloat(theform.softwarepris.value.replace(/,/g,".")); if (isNaN(tal)==false) { total += tal; } tal = parseFloat(theform.hardwarepris.value.replace(/,/g,".")); if (isNaN(tal)==false) { total += tal; } tal = parseFloat(theform.netværkpris.value.replace(/,/g,".")); if (isNaN(tal)==false) { total += tal; } tal = parseFloat(theform.tilbehørpris.value.replace(/,/g,".")); if (isNaN(tal)==false) { total += tal; } tal = parseFloat(theform.timeogkvarterpris.value.replace(/,/g,".")); if (isNaN(tal)==false) { total += tal; } theform.momspris.value = (total.toFixed(2)*0.25).toFixed(2).replace(".",","); theform.total.value=(parseFloat(total.toFixed(2)) + parseFloat(theform.momspris.value.replace(",","."))).toFixed(2).replace(".",","); }
<script> function addformdata(theform) { var total = 0; var tal; tal = parseFloat(theform.softwarepris.value.replace(/,/g,".")); if (isNaN(tal)==false) { total += tal; } tal = parseFloat(theform.hardwarepris.value.replace(/,/g,".")); if (isNaN(tal)==false) { total += tal; } tal = parseFloat(theform.netværkpris.value.replace(/,/g,".")); if (isNaN(tal)==false) { total += tal; } tal = parseFloat(theform.tilbehørpris.value.replace(/,/g,".")); if (isNaN(tal)==false) { total += tal; } tal = parseFloat(theform.timeogkvarterpris.value.replace(/,/g,".")); if (isNaN(tal)==false) { total += tal; } theform.momspris.value = (total.toFixed(2)*0.25).toFixed(2); theform.total.value=parseFloat(total.toFixed(2)) + parseFloat(theform.momspris.value); }
var callvals={};
function callval(e){
var f=e.form;
var tv=parseFloat(e.value); var tv2=(tmp=callvals[e.name])?tmp:0; callvals[e.name]=tv;
<font face="" size=""> <form method="post" action="test.asp"> <script> function addformdata(theform) { var total = 0; var tal; tal = parseFloat(theform.softwarepris.value.replace(/,/g,".")); if (isNaN(tal)==false) { total += tal; } tal = parseFloat(theform.hardwarepris.value.replace(/,/g,".")); if (isNaN(tal)==false) { total += tal; } tal = parseFloat(theform.netværkpris.value.replace(/,/g,".")); if (isNaN(tal)==false) { total += tal; } tal = parseFloat(theform.tilbehørpris.value.replace(/,/g,".")); if (isNaN(tal)==false) { total += tal; } tal = parseFloat(theform.timeogkvarterpris.value.replace(/,/g,".")); if (isNaN(tal)==false) { total += tal; } theform.momspris.value = (total.toFixed(2)*0.25).toFixed(2).replace(".",","); theform.total.value=(parseFloat(total.toFixed(2)) + parseFloat(theform.momspris.value.replace(",","."))).toFixed(2).replace(".",","); }
var callvals={};
function callval(e){
var f=e.form;
var tv=parseFloat(e.value);
var tv2=(tmp=callvals[e.name])?tmp:0; callvals[e.name]=tv;
Ikke det eksempel jeg lagde ... hvis du bruger <option value="73,60">McAfee Epolicy</option> ... står der 73,60 i inpur feltet Hvis du skriver 73,6 står der 73,6 i feltet ...
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.