...

View Full Version : Can anyone help!?!?!?



jerel4565
06-02-2009, 09:16 PM
Hello all,

I am building a website order page form and am have some trouble. Im trying to create a page that has various selections and when choosing a selection a total appears updated after each selection. Here is my javascript:


<!-- ***** START SCRIPT --><SCRIPT language="javascript"><!-- // ***** GET TOTAL
function getTTL(form, item){
var total;
var i;
var x;
var temp = document.forms[0].USER1.value;
total=149.99; x=0;
for (var i=0; i < 10; i++) {
if (form.server[i].checked==true){
x++;
total=total+eval(form.server[i].value);}
}
form.AMOUNT.value = total;
form.TOTAL.value = total + 99.99;

return;
}

// --></SCRIPT><!-- ******************************************************* -->
The problem Im having is that im using radio buttons but for the script to work each radio button must have the same 'name'. When i dont have the same name the script refuses to work. Here is my html code:


<tr align="left" valign="top" height="262">
<td width="522" height="262">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr height="76">
<td height="76" align="left" valign="top">
<table align="left" width="500" border="0" cellspacing="0" cellpadding="0">
<tr>
<td colspan="3">
<table width="508" border="0" align="left" cellpadding="0" cellspacing="0">
<tr>
<td height="30" align="left" valign="middle" style="background-image:url(images/dedi_table_top.jpg);">
<table width="500" border="0" align="right" cellpadding="0" cellspacing="0">
<tr>
<td align="left" valign="top">
<table width="504" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="30" align="left" valign="middle">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" class="ver10">
<tr>
<td width="1%" align="left" valign="top" class="ver10"><strong></strong></td>
<td width="66%" align="left" valign="top" class="ver10"><strong><font color="white">Processor</font></strong></td>
<td width="17%" align="center" valign="top" class="ver10"><strong><font color="white">Setup Cost</font></strong></td>
<td width="17%" align="center" valign="top" class="ver10"><strong><font color="white">Monthly Cost</font></strong></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#182535">
<table width="506" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
<tr>
<td align="left" valign="top">
<table width="504" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="30" align="left" valign="middle">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" class="ver10">
<tr>
<td width="1%" align="left" valign="top" class="ver10"><strong></strong></td>
<p><td width="5%" align="left" valign="top" class="ver10"><INPUT TYPE="radio" NAME="processor" VALUE="149.99" checked="checked" onclick="getTTL(this.form,'processor')"> <td width="61%" align="left" valign="middle" class="ver10">Intel Xeon 3040 1.8 GHz Dual Core Processor</td></td></p>
<td width="17%" align="center" valign="middle" class="ver10">$99.99</td>
<td width="17%" align="center" valign="middle" class="ver10">$149.00</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="7" align="left" valign="top"><img src=".images/dedi_table_base.jpg" width="508" height="7"></td>
</tr>
</table>
</td>
</tr>
<td colspan="3">&nbsp;</td>
<tr>
<td height="30" align="left" valign="middle" style="background-image:url(images/dedi_table_top.jpg);">
<table width="500" border="0" align="right" cellpadding="0" cellspacing="0">
<tr>
<td align="left" valign="top">
<table width="504" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="30" align="left" valign="middle">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" class="ver10">
<tr>
<td width="1%" align="left" valign="top" class="ver10"><strong></strong></td>
<td width="66%" align="left" valign="top" class="ver10"><strong><font color="white">Drive Controller</font></strong></td>
<td width="17%" align="center" valign="top" class="ver10"><strong><font color="white">Setup Cost</font></strong></td>
<td width="17%" align="center" valign="top" class="ver10"><strong><font color="white">Monthly Cost</font></strong></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#182535">
<table width="506" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
<tr>
<td align="left" valign="top">
<table width="504" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="30" align="left" valign="middle">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" class="ver10">
<tr>
<td width="1%" align="left" valign="top" class="ver10"><strong></strong></td>
<td width="5%" align="left" valign="top" class="ver10"><INPUT TYPE="radio" NAME="server" VALUE="0.00" checked="checked" onclick="getTTL(this.form,'server')"><td width="61%" align="left" valign="middle" class="ver10">SATA</td></td>
<td width="17%" align="center" valign="middle" class="ver10">$0.00</td>
<td width="17%" align="center" valign="middle" class="ver10">$0.00</td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="30" align="left" valign="middle" bgcolor="#D3EEFA">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" class="ver10">
<tr>
<td width="1%" align="left" valign="top" class="ver10"><strong></strong></td>
<td width="5%" align="left" valign="top" class="ver10"><INPUT TYPE="radio" NAME="server" VALUE="40.00" onclick="getTTL(this.form,'server')"><td width="61%" align="left" valign="middle" class="ver10">RAID 0</td></td>

<td width="17%" align="center" valign="middle" class="ver10">$0.00</td>
<td width="17%" align="center" valign="middle" class="ver10">$40.00</td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="30" align="left" valign="middle" >
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" class="ver10">
<tr>
<td width="1%" align="left" valign="top" class="ver10"><strong></strong></td>
<td width="5%" align="left" valign="top" class="ver10"><INPUT TYPE="radio" NAME="server" VALUE="40.00" onclick="getTTL(this.form,'server')"><td width="61%" align="left" valign="middle" class="ver10">RAID 1</td></td>
<td width="17%" align="center" valign="middle" class="ver10">$0.00</td>
<td width="17%" align="center" valign="middle" class="ver10">$40.00</td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="30" align="left" valign="middle" bgcolor="#D3EEFA">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" class="ver10">
<tr>
<td width="1%" align="left" valign="top" class="ver10"><strong></strong></td>
<td width="5%" align="left" valign="top" class="ver10"><INPUT TYPE="radio" NAME="server" VALUE="40.00" onclick="getTTL(this.form,'server')"><td width="61%" align="left" valign="middle" class="ver10">RAID 5</td></td>
<td width="17%" align="center" valign="middle" class="ver10">$0.00</td>
<td width="17%" align="center" valign="middle" class="ver10">$40.00</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="7" align="left" valign="top"><img src=".images/dedi_table_base.jpg" width="508" height="7"></td>
</tr>
</table>
</td></tr>
<td colspan="3">&nbsp;</td>
<tr>
<td height="30" align="left" valign="middle" style="background-image:url(images/dedi_table_top.jpg);">
<table width="500" border="0" align="right" cellpadding="0" cellspacing="0">
<tr>
<td align="left" valign="top">
<table width="504" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="30" align="left" valign="middle">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" class="ver10">
<tr>
<td width="1%" align="left" valign="top" class="ver10"><strong></strong></td>
<td width="66%" align="left" valign="top" class="ver10"><strong><font color="white">Hard Drive One</font></strong></td>
<td width="17%" align="center" valign="top" class="ver10"><strong><font color="white">Setup Cost</font></strong></td>
<td width="17%" align="center" valign="top" class="ver10"><strong><font color="white">Monthly Cost</font></strong></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#182535">
<table width="506" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
<tr>
<td align="left" valign="top">
<table width="504" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="30" align="left" valign="middle">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" class="ver10">
<tr>
<td width="1%" align="left" valign="top" class="ver10"><strong></strong></td>
<td width="5%" align="left" valign="top" class="ver10"><INPUT TYPE="radio" NAME="hard drive one" VALUE="0.00" checked="checked" onclick="getTTL(this.form,'hard drive one')"> <td width="61%" align="left" valign="middle" class="ver10">150 GB SATA</td></td>
<td width="17%" align="center" valign="middle" class="ver10">$0.00</td>
<td width="17%" align="center" valign="middle" class="ver10">$0.00</td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="30" align="left" valign="middle" bgcolor="#D3EEFA">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" class="ver10">
<tr>
<td width="1%" align="left" valign="top" class="ver10"><strong></strong></td>
<td width="5%" align="left" valign="top" class="ver10"><INPUT TYPE="radio" NAME="hard drive one" VALUE="15.00" onclick="getTTL(this.form,'hard drive one'')"><td width="61%" align="left" valign="middle" class="ver10">250 GB SATA</td></td>
<td width="17%" align="center" valign="middle" class="ver10">$0.00</td>
<td width="17%" align="center" valign="middle" class="ver10">$15.00</td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="30" align="left" valign="middle">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" class="ver10">
<tr>
<td width="1%" align="left" valign="top" class="ver10"><strong></strong></td>
<td width="5%" align="left" valign="top" class="ver10"><input type="radio" name="hard drive one" value="30.00" onclick="getTTL(this.form,'hard drive one'')"> <td width="61%" align="left" valign="middle" class="ver10">500 GB SATA</td></td>
<td width="17%" align="center" valign="middle" class="ver10">$0.00</td>
<td width="17%" align="center" valign="middle" class="ver10">$30.00</td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="30" align="left" valign="middle" bgcolor="#D3EEFA">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" class="ver10">
<tr>
<td width="1%" align="left" valign="top" class="ver10"><strong></strong></td>
<td width="5%" align="left" valign="top" class="ver10"><input type="radio" name="hard drive one" value="45.00" onclick="getTTL(this.form,'hard drive one'')" > <td width="61%" align="left" valign="middle" class="ver10">750 GB SATA</td></td>
<td width="17%" align="center" valign="middle" class="ver10">$0.00</td>
<td width="17%" align="center" valign="middle" class="ver10">$45.00</td>
</tr>
</table></td></tr>
<tr>
<td height="30" align="left" valign="middle">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" class="ver10">
<tr>
<td width="1%" align="left" valign="top" class="ver10"><strong></strong></td>
<td width="5%" align="left" valign="top" class="ver10"><input type="radio" name="hard drive one" value="60.00" onclick="getTTL(this.form,'hard drive one'')"> <td width="61%" align="left" valign="middle" class="ver10">1000 GB SATA</td></td>
<td width="17%" align="center" valign="middle" class="ver10">$0.00</td>
<td width="17%" align="center" valign="middle" class="ver10">$60.00</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="7" align="left" valign="top"><img src=".images/dedi_table_base.jpg" width="508" height="7"></td>
</tr>
</table>
</td>
<INPUT NAME="AMOUNT" TYPE="text" VALUE="0.00" SIZE="4" onchange="getTTL(this.form)" ALIGN="right">

I guess basically what Im asking is if there is any way for my script to be able to take any 'name' value from the radio buttons.

Philip M
06-02-2009, 10:31 PM
A group of radio buttons must necessarily all have the same name.

Do please read the posting guidelines regarding silly thread titles. The thread title is supposed to help people who have a similar problem in future. Yours is useless for this purpose.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum