Computer Pricer

[Total: 0    Average: 0/5]

This shows how to set up a form that computes costs for building your own computer.

Body Code:

<SCRIPT LANGUAGE="JAVASCRIPT">



var called=false;	//to make sure the function compute() is called
var T_Price=0;
var pr_flag;	//processor flag for keeping track of the choices
var pr_print="";

var sp_flag;	//flag for speed
var sp_print;

var ram_flag;	//flag for ram
var ram_print;

var hdrive_flag;	//flag for Hard Drive
var hdrive_print;

var vram_flag;	//flag for VRAM
var vram_print;

var fdrive_flag;	//flag for Floopy Drive
var fdrive_print;

var cd_flag;	//flag for CD Rom
var cd_print;

var mn_flag;	//flag for Monitor
var mn_print;

var mos_flag;	//flag for Mouse
var mos_print;

var kb_flag;	//flag for KeyBoard
var kb_print;

var modem_flag;	//flag for Modem
var modem_print;

var software_flag; //flag for software
var software_print;

var card_flag;        //flag for sound card
var card_print;

function compute(form){
called=true;

if (form.processor[0].selected){
	pr_print= "None [$0]";
	pr_flag=0;
}
	 
 if (form.processor[1].selected){
	pr_flag =540;
	pr_print="68LCO45 DD [$540]";
}

else if (form.processor[2].selected){
	pr_flag =340;
pr_print="68LCO45 EE [$340]";
}
	

else if (form.processor[3].selected){
	pr_flag =680;
	pr_print="68LCO45 FF [$680]";
}
	

else if (form.processor[4].selected){
	pr_flag =421;
	pr_print="68LCO45 GG [$421]";
}

//-------Speed----------
if (form.speed[0].selected){
	sp_flag=0;
	sp_print="None [$0]";
}

if (form.speed[1].selected){
	sp_flag=110;
sp_print="60 MHz [$110]";
}

if (form.speed[2].selected){
	sp_flag=145;
sp_print="66/33 MHz [$145]";
}

if (form.speed[3].selected){
	sp_flag=199;
sp_print="75 MHz [$199]";
}

if (form.speed[4].selected){
	sp_flag=235;
sp_print="100 MHz  [$235]";
}

//-------RAM-----------
if (form.ram[0].selected){
	ram_flag=0;
	ram_print="None [$0]";
}

if (form.ram[1].selected){
	ram_flag=75;
ram_print="4 RAM [$75]";
}

if (form.ram[2].selected){
	ram_flag=120;
ram_print="8 RAM [$120]";
}

if (form.ram[3].selected){
	ram_flag=200;
ram_print="16 RAM [$200]";
}

if (form.ram[4].selected){
	ram_flag=350;
ram_print="32 RAM [$350]";
}

//-------Hard Drive-------
if (form.hdrive[0].selected){
	hdrive_flag=0;
hdrive_print="None [$0]";
}

if (form.hdrive[1].selected){
	hdrive_flag=100;
hdrive_print="250MB [$100]";
}

if (form.hdrive[2].selected){
	hdrive_flag=200;
hdrive_print="500MB [$200]";
}

if (form.hdrive[3].selected){
	hdrive_flag=300;
hdrive_print="750MB [$300]";
}

if (form.hdrive[4].selected){
	hdrive_flag=399;
	hdrive_print="1.0GB [$399]";
}


//-------VRAM-------

if (form.vram[0].selected){
	vram_flag=0;
	vram_print="None [$0]";
	}

if (form.vram[1].selected){
	vram_flag=50;
	vram_print="1MB DRAM [$50]";
	}

if (form.vram[2].selected){
	vram_flag=89;
	vram_print="4MB DRAM  [$89]";
	}

if (form.vram[3].selected){
	vram_flag=125;
	vram_print="8MB DRAM [$125]";
	}

if (form.vram[4].selected){
	vram_flag=200;
	vram_print="16MB DRAM [$200]";
	}

//-------Floppy-------
if (form.fdrive[0].selected){
	fdrive_flag=0;
	fdrive_print="None [$0]";
	}

if (form.fdrive[1].selected){
	fdrive_flag=75;
fdrive_print=" 1.4 ench. [$75]";
	}

if (form.fdrive[2].selected){
	fdrive_flag=50;
	fdrive_print="5.25 ench. [$50]";
	}

if (form.fdrive[3].selected){
	fdrive_flag=100;
	fdrive_print="BOTH [$100]";
	}

//-------CD ROM-------

if (form.cd[0].selected){
	cd_flag=0;
	cd_print="None [$0]";
	}
if (form.cd[1].selected){
	cd_flag=300;
	cd_print="600E Dual Speed [$300]";
	}

if (form.cd[2].selected){
	cd_flag=450;
	cd_print="800E Quadruple-Speed  [$450]";
	}
//----------Monitor-----------
if (form.monitor[0].selected){
	mn_flag=0;
	mn_print="None [$0]";
	}

if (form.monitor[1].selected){
	mn_flag=210;
	mn_print="12 ench. VGA [ $210]";
	}

if (form.monitor[2].selected){
	mn_flag=300;
	mn_print="14 ench. Super VGA [$300]";
	}

if (form.monitor[3].selected){
	mn_flag=290;
	mn_print="14 ench. VGA [$290]";
	}

if (form.monitor[4].selected){
	mn_flag=370;
	mn_print="14 ench. Super VGA [$370]";
	}

if (form.monitor[5].selected){
	mn_flag=350;
	mn_print="17 ench. VGA [$350]";
	}

if (form.monitor[6].selected){
	mn_flag=475;
	mn_print="17 ench. Super VGA [$475]";
	}

//-----------Mouse------
if (form.mouse[0].selected){
	mos_flag=0;
	mos_print="None [$0]";
}

if (form.mouse[1].selected){
	mos_flag=35;
	mos_print=" Vesa6 [$35]";
}

if (form.mouse[2].selected){
	mos_flag=120;
mos_print=" Titda9 [$120]";
}

//----------KeyBoard-----------

if (form.keyboard[0].selected){
	kb_flag=0;
	kb_print= "None [$0]";
}

if (form.keyboard[1].selected){
	kb_flag=75;
	kb_print="473E SPO [$75]";
}

if (form.keyboard[2].selected){
	kb_flag=120;
	kb_print="48dE SPO [$120]";
}

if (form.keyboard[3].selected){
	kb_flag=150;
	kb_print="874K SPO [$150]";
}

if (form.keyboard[4].selected){
	kb_flag=175;
	kb_print="888i SPO [$175]";
	}

//----------Modem-----------

if (form.modem[0].selected){
	modem_flag=0;
modem_print=" None [$0]";
}

if (form.modem[1].selected){
	modem_flag=100;
modem_print=" External 14.4 [$100]";
}

if (form.modem[2].selected){
	modem_flag=110;
modem_print=" Internal 14.4 [$110]";
}

if (form.modem[3].selected){
	modem_flag=150;
modem_print=" External 28.8 [$150]";
}

if (form.modem[4].selected){
	modem_flag=160;
modem_print=" Internal 28.8 [$160]";
	}

//----------Sound Card-----------
 
if (form.card[0].selected){
	card_flag=0;
card_print="None [$0]";
}

if (form.card[1].selected){
	card_flag=300;
card_print=" Adlib [$300]";
}

if (form.card[2].selected){
	card_flag=258;
card_print=" Sound Blaster [$258]";
}

if (form.card[3].selected){
	card_flag=235;
card_print=" Sound Blaster Pro  [$235]";
}

if (form.card[4].selected){
	card_flag=320;
card_print=" MIDI Mapper   [$320]";
}

T_Price=pr_flag+sp_flag+ram_flag+hdrive_flag+vram_flag+ fdrive_flag
+cd_flag+mn_flag+mos_flag+ kb_flag+modem_flag+card_flag;

form.T_Price.value="     $ "+ T_Price;


}
function print(form){
if(!called){
	compute(form);
}
text = ("<HEAD><TITLE>'On-line Computer Cost Esimator'</TITLE></HEAD>");
text = (text +"<BODY BGCOLOR =  '#C0C0C0' ><CENTER><B><FONT SIZE = 4><FONT COLOR=BLUE>UniVista On-line Computer Cost Esimator</FONT></FONT></B>");
text= (text +"</CENTER>");
text=(text+"<hr>");

text=(text+"<TABLE BORDER =0><TR VALIGN=Top><TD VALIGN=Top>");
text=(text+"<B>Processor:<BR>Speed: <BR>Monitor: <BR>Hardrive: <BR>Floppy Drive: <BR>Memory:");
text=(text+" <BR>VRAM: <BR>CD-ROM: <BR>Sound Card: <BR>Modem: <BR>Key Board: <BR>Mouse: ");
text=(text+"</B></TD><TD>")

text=(text+"<B>"+ pr_print+"<BR>"+sp_print+"<BR>"+ mn_print+"<BR>"+ hdrive_print+"<BR>");
text=(text+ fdrive_print+"<BR>"+ram_print+"<BR>"+ vram_print+"<BR>"+ cd_print+"<BR>");
text=(text+card_print+"<BR>"+ modem_print+"<BR>"+kb_print +"<BR>" +mos_print );
text=(text+"<TD></TR></TABLE><hr>");
text=(text+"<B><FONT COLOR=RED>Total Cost:</FONT>"+" &nbsp &nbsp &nbsp $"+T_Price);
text=(text+"<form><FONT SIZE=-1><FONT COLOR=GREEN>To print, choose FILE and PRINT.</FONT></FONT>");
text=(text+"&nbsp;&nbsp;&nbsp;<input type=button value=Close onClick=window.close()>"+"</form></body></html>");
                msgWindow=window.open("","displayWindow","toolbar=no,location=no,top=8,left=90,width=375,height=400,directories=no,status=no,scrollbars=no,resize=no,menubar=yes")
                msgWindow.document.write(text)
                msgWindow.document.close()
}



</SCRIPT>
<H2><font color=Blue> <Center>On-line Computer Cost Estimator
</H2>
<FORM method=post>
<TABLE BORDER CELLPADDING="2" border=0><CAPTION>
</CAPTION><TR><TD>Processor:	 
<P>
<SELECT NAME="processor">		 
<OPTION Selected>	 Select                 
<OPTION>        68LCO45 DD [$540]                 
<OPTION>        68LCO45 EE   [$340]              
<OPTION>        68LCO45 FF    [$680]             
<OPTION>        68LCO45 GG   [$421]    
</SELECT>
</TD><TD>Speed:  
<P>
<SELECT NAME="speed">		 
<OPTION Selected>	 Select                 
<OPTION>        60 MHz  [$110]               
<OPTION>        66/33 MHz  [$145]              
<OPTION>        75 MHz      [$199]           
<OPTION>        100 MHz     [$235]    
</SELECT>
</TD><TD>Memory(RAM): 

<P>
<SELECT NAME="ram">		 
<OPTION>	 Select                 
<OPTION>        4 RAM[$75]                 
<OPTION>        8 RAM [$120]                
<OPTION>        16 RAM [$200]                
<OPTION>        32 RAM [$350]        
</SELECT>
</TD></TR><TR><TD>Hard drive: 
<P>
<SELECT NAME="hdrive">		 
<OPTION>	 Select                 
<OPTION>        250MB [$100]                
<OPTION>        500MB  [$200]               
<OPTION>        750MB  [$300]                
<OPTION>        1.0GB    [$399]     
</SELECT>
</TD><TD>VRAM: 
<P>
<SELECT NAME="vram">		 
<OPTION>	 Select                 
<OPTION>        1MB DRAM  [$50]               
<OPTION>        4MB DRAM   [$89]              
<OPTION>        8MB DRAM    [$125]             
<OPTION>        16MB DRAM   [$200]      
</SELECT>
</TD><TD>Floppy Drive: 
<P>
<SELECT NAME="fdrive">		
<OPTION>	 Select                 
<OPTION>        1.4MB [$75]                 
<OPTION>        5.25MB [$50]                
<OPTION>        BOTH    [$100]             
</SELECT>
</TD></TR><TR><TD>CD-Rom: 
<P>
<SELECT NAME="cd">		 
<OPTION>	 Select                 
<OPTION>        600E Dual Speed [$300]                
<OPTION>        800E Quadruple-Speed  [$450]                        
</SELECT>
</TD><TD>Monitor:
 
<P>
<SELECT NAME="monitor">		 
<OPTION Selected>	 Select                 
<OPTION>        12" VGA   [ $210]             
<OPTION>        12" Super VGA   [$300]              
<OPTION>        14" VGA   [$290]              
<OPTION>        14" Super VGA [$370]		 
<OPTION>        17" VGA  [$350]               
<OPTION>        17" Super VGA  [$475]     
</SELECT>
</TD><TD>Mouse: 
<P>
<SELECT NAME="mouse">		 
<OPTION Selected>	 Select  
<OPTION>	 Vesa6  [$35]           
<OPTION>         Titda9    [$120]             
</SELECT>
</TD></TR><TR><TD>KeyBoard: 
<P>
<SELECT NAME="keyboard">		 
<OPTION Selected>	 Select                 
<OPTION>        473E SPO   [$75]             
<OPTION>        48dE SPO   [$120]              
<OPTION>        874K SPO   [$150]              
<OPTION>        888i SPO      [$175]   
</SELECT>
</TD><TD>Modem: 
<P>
<SELECT NAME="modem">		 
<OPTION Selected>	 Select                 
<OPTION>        External 14.4 [$100]                 
<OPTION>        Internal 14.4   [$110]              
<OPTION>        External 28.8   [$150]              
<OPTION>        Internal 28.8     [$160]    
</SELECT>
</TD><TD>Sound Card: 
<P>
<SELECT NAME="card">		 
<OPTION>	 Select                 
<OPTION>        Adlib   [$300]                
<OPTION>        Sound Blaster    [$258]            
<OPTION>        Sound Blaster Pro  [$235]              
<OPTION>        MIDI Mapper   [$320]     
</SELECT>
</TD></TR></TABLE><P>
<TABLE BORDER CELLPADDING="2"><TR><TD><center><BR>
<INPUT TYPE="BUTTON" NAME="Price" Value="Update Price" onClick="compute(this.form)"></center>
<BR>
<INPUT TYPE="text" SIZE=15 NAME="T_Price" value=""><br>

</TD><TD><INPUT TYPE="BUTTON" NAME="Print_data" Value="Print Preview" onClick="print(this.form)"></center><center><br><input type=reset value=Reset> </center>
</TD></TR></TABLE><P>
</FORM><P>
</FORM>

Times Viewed: 0

Leave a Reply

Your email address will not be published. Required fields are marked *