This topic is locked

how do I add two fields of the form?

8/28/2008 3:24:38 PM
PHPRunner General questions
G
guigosnet author

how do I add two fields of the form?

S
swanside 8/28/2008

how do I add two fields of the form?


select(field_1 +field_2)from whatever as Field_3
If you put abit more info like table name and field names, you will more than likley get a longer answer.

G
gr8hands 8/28/2008

If you're trying to do the addition on the form (webpage) and not the database, you need to put it into the HTML at the top of the page like this:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<HTML><HEAD><TITLE>CTS2 Data</TITLE>

<META http-equiv=Content-Type content="text/html; charset=windows-1252"><LINK

href="include/style.css" type=text/css rel=stylesheet>{$includes}

<META content="MSHTML 6.00.6000.16705" name=GENERATOR></HEAD>

<BODY {$bodyonload}>{literal}

<STYLE>

input, select, textarea {

font-size: 14pt;

font-family: Times New Roman;

}

button {

font-size: 18pt;

font-family: Times New Roman;

}

</STYLE>

<script TYPE="text/javascript">

<!-- Begin

function calculate(editform)

{

var cAsk=editform.value_Ask.value;

var cPeriod=editform.value_Period.value;

var cFrequency=editform.value_Frequency.value;

if(cFrequency==5) {editform.value_Pledge.value=cAsk;editform.value_Period.value=0;}

else

{editform.value_Pledge.value=(cAsk * cFrequency * cPeriod);}

}
// End -->

</SCRIPT>{/literal}[/codebox]

Make certain the {literal}{/literal} is there!
I've used a button elsewhere on the page to active the calculation. It looks like this:
[code]<INPUT onclick=calculate(this.form) type=button value=recalculate>

You might find this as a starting point for your own equation.

G
guigosnet author 8/28/2008

LOOK THIS WORG....
function itens_Event1(&$params)

{
{literal}

<script>

var qtd = document.editform.value_QTD;

var unit = document.editform.value_UNITARIO.value;

var total = 0;
total = parseFloat(unitario) * parseFloat(qtd);

total = total.toFixed(2);

document.editform.value_TOTAL.value = total;

document.forms.editform.value_TOTAL.disabled=true;

</script>

{/literal}
} // function itens_Event1
Parse error: parse error, unexpected '}' in D:\sites\php\Pedidos2.0\Pedidos 2\output\include\itens_events.php on line 41

G
gr8hands 8/28/2008

Io sono suggerendo che non porre questo in un "evento". Io sono suggerendo di inserire nel codice HTML in Visual Editor per quella pagina. (Vi preghiamo di perdonare il mio tentativo di italiano.)
I am suggesting you do not put this into an "event". I am suggesting you put it into the HTML code in the Visual Editor for that page.