...

View Full Version : I Want to add to get total but rather script append as string ?



lse123
01-29-2009, 12:44 PM
var subprice, rather added to total in appended ...well ?
eg subprice=5 total=9 addition>59 rather 14

also the third script code below is it correct ?


<script type="text/javascript">
/* <![CDATA[*/
function setCookie(c_name,value)
{
document.cookie=c_name+ "=" +escape(value);
}
function getCookie(c_name)
{
if (document.cookie.length>0)
{
c_start=document.cookie.indexOf(c_name + "=");
if (c_start!=-1)
{
c_start=c_start + c_name.length+1;
c_end=document.cookie.indexOf(";",c_start);
if (c_end==-1) c_end=document.cookie.length;
return unescape(document.cookie.substring(c_start,c_end));
}
}
return "";
}
// below same for others + (march01.valueOf()==(pickup*1000))
if (getCookie('gps')!=null && getCookie('gps')!='') {
document.getElementById('gps').checked = getCookie('gps');
}
function calc() {

var group = document.extras.group.value;
var pickup = document.extras.pickup.value;
var march01 = new Date(2009,2,1);
var days_hd = document.extras.days_hd.value;
var subprice = document.extras.price.value;
var total = 0 ; // total = subprice ;

if (document.extras.drivers.value >= 1) {
total = total + (document.extras.drivers.value - 1)*days_hd*2;
}
if ((document.extras.cseat.value+document.extras.cbseat.value) >= 1) {
total += (document.extras.cseat.value+document.extras.cbseat.value-1)*days_hd*2;
}
if (document.extras.gps.checked == true) {
if (group=="E1") {
total += 0;
} else if (march01.valueOf()==(pickup*1000)) { // go to change this
total += 0;
} else {
total += 1*(days_hd/7)*10;
}
document.getElementById('gps1').value = "YES";
} else {
document.getElementById('gps1').value = "NO";
}
total += subprice; //
document.getElementById('t').innerHTML = "€" + total ;
setCookie('drivers',document.extras.drivers.value);
setCookie('cseat',document.extras.cseat.value);
setCookie('cbseat',document.extras.cbseat.value);
setCookie('gps',document.extras.gps.checked);
setCookie('transmissionchoosen',document.extras.transmissionchoosen.value);
document.getElementById('drivers1').value = document.getElementById('drivers').value;
document.getElementById('cseat1').value = document.getElementById('cseat').value;
document.getElementById('cbseat1').value = document.getElementById('cbseat').value;
// getCookie('gps')==true)?checked:unchecked;
// document.getElementById('gps1').value = document.getElementById('gps').value;
document.getElementById('transmissionchoosen1').value = document.getElementById('transmissionchoosen').value;
document.getElementById('finalprice').value = total;
// "(getCookie('gps')==true)?document.write('checked'):document.write('');"

}

/* ]]>*/
</script>


<table width="450" border="1" align="center" cellpadding="2" cellspacing="2" summary="Extras cost">
<caption>
EXTRAS
</caption>
<tr>
<td width="270" align="left" valign="middle">Extra drivers-1st FREE OF CHARGE (€2/day)</td>
<td width="160" align="left" valign="middle"><select name="drivers" id="drivers" onchange="calc();">
<option value="(getCookie('drivers')!=null && getCookie('drivers')!='') ? getCookie('drivers'):0;" selected="selected"><script type="text/javascript">(getCookie('drivers')!=null && getCookie('drivers')!='')?document.write(getCookie('drivers')):document.write("0");</script></option>
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select></td>
</tr>
<tr>
<td align="left" valign="middle">Small Seat-1st FREE OF CHARGE</td>
<td align="left" valign="middle">&nbsp;</td>
</tr>
<tr align="right" valign="middle">
<td align="left" valign="middle">Child Car Seat (€2/day)</td>
<td align="left" valign="middle"><select name="cseat" id="cseat" onchange="calc();" >
<option value="(getCookie('cseat')!=null && getCookie('cseat')!='') ? getCookie('cseat'):0;" selected="selected"><script type="text/javascript">(getCookie('cseat')!=null && getCookie('cseat')!='')?document.write(getCookie('cseat')):document.write("0");</script></option>
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select></td>
</tr>
<tr>
<td align="left" valign="middle">Child Booster Seat (€2/day)</td>
<td align="left" valign="middle"><label>
<select name="cbseat" id="cbseat" onchange="calc();" >
<option value="(getCookie('cbseat')!=null && getCookie('cbseat')!='') ? getCookie('cbseat'):0;" selected="selected"><script type="text/javascript">(getCookie('cbseat')!=null && getCookie('cbseat')!='')?document.write(getCookie('cbseat')):document.write("0");</script></option>
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
</label></td>
</tr>
<tr>
<td align="left" valign="middle">GPS (€10/week or FREE if special offer)</td>
<td align="left" valign="middle"><label>
<input name="gps" type="checkbox" id="gps" onclick="calc();" value="YES" />
</label></td>
</tr>
<tr>
<td align="left" valign="middle">Choose Transmission</td>
<td align="left" valign="middle"><label>
<select name="transmissionchoosen" id="transmissionchoosen">
<option value="(getCookie('transmissionchoosen')!=null && getCookie('transmissionchoosen')!='') ? document.write(getCookie('transmissionchoosen')):document.write('Automatic');" selected="selected"><script type="text/javascript">(getCookie('transmissionchoosen')!=null && getCookie('transmissionchoosen')!='')?document.write(getCookie('transmissionchoosen')):document.writ e("Automatic");</script></option>
<option value="Automatic">Automatic</option>
<option value="Manual">Manual</option>
<option value="Whatever">Whatever</option>
</select>
</label></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td align="right" valign="middle">TOTAL[Incl. extras]:</td>
<td bgcolor="#CCCCCC" id="t">&nbsp;</td>
</tr>
</table>

------------------------------------------------


<select name="transmissionchoosen" id="transmissionchoosen">
<option value="(getCookie('transmissionchoosen')!=null && getCookie('transmissionchoosen')!='') ? document.write(getCookie('transmissionchoosen')):document.write('Automatic');" selected="selected"><script type="text/javascript">(getCookie('transmissionchoosen')!=null && getCookie('transmissionchoosen')!='')?document.write(getCookie('transmissionchoosen')):document.writ e("Automatic");</script></option>
<option value="Automatic">Automatic</option>
<option value="Manual">Manual</option>
<option value="Whatever">Whatever</option>
</select>

Philip M
01-29-2009, 01:17 PM
You are a professional webdesigner. You ought to know this very elementary topic by now. Look up concatenation of strings, addition of numbers.

You have 671 posts, all of them asking for assistance in your paid work, none offering it, but you have awarded zero thanks and the word "please" is not in your vocabulary. As AeroSpace Engineer would say,
|||| If you are getting paid to do a job, don't ask for help on it ! ||||



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum