Jump to content

display text box with number already in it


mckenzie
 Share

Recommended Posts

hello there, simple question. it may not be a simple answer. i have this code which calculates the total price of an order. i would like to have the quantity box's to contain the number 1 when the page is brought up. how would i go about doing this?thanks<html><Head><script> function Fn_Drd_Change(Combo, Text) {eval("document.forms(0)."+ Text +".value = document.forms(0)."+ Combo +".value"); }function CalcTotal(){ var total = 0; var Qty = 0; var line = 0; var fld; var fld2; for(var i = 1; i < 19; i++){ Qty = 0; line = 0; eval("fld = document.forms(0).Txt" + i); eval("fld2 = document.forms(0).amnt" + i); if(!isNaN(fld2.value) && fld2.value != ""){ Qty = parseFloat(fld2.value); } if(!isNaN(fld.value) && fld.value != ""){ line = parseFloat(fld.value); } total += (Qty * line) } document.forms(0).myTotalField.value = total;;}</script><%Dim connDim CmdPopulatefoodDim SQLdim FieldNamedim TableNameset Conn = Server.createobject("ADODB.Connection")conn.open "PROVIDER=Microsoft.jet.OLEDB.4.0;DATA SOURCE=" & server.mappath("Project.mdb") & ";" Set rs = Server.CreateObject("ADODB.RecordSet")%><%Sub Fillcombo (TableName, name, price)SQL= "SELECT " & name & " , "& price&" FROM " & TableNamers.Open SQL, connIf Not rs.EOF Then Do While Not rs.EOF %> <Option value=<%= rs("price")%>><%= rs("name")%></Option> <% rs.MoveNext LoopEnd Ifrs.CloseEnd Sub%><body><form method="get" action="AddOrder.asp"><table border="1"><tr><td><Select Name="Drd1" OnChange=" Fn_Drd_Change('Drd1','Txt1')" /><% Call Fillcombo("BAKERYandCAKES", "name","price") %></Select></td><td><INPUT Name="Txt1" Value="" size=6 /></td><td><INPUT type=text Name="amnt1" Value="" size=6 onkeyup="CalcTotal();" /></td></tr><tr><td><Select Name="Drd2" OnChange=" Fn_Drd_Change('Drd2','Txt2')"><% Call Fillcombo("BEERCIDERALCOPOPS", "name","price") %></Select></td><td><INPUT Name="Txt2" Value="" size=6 /></td><td><INPUT type=text Name="amnt2" Value="" size=6 onkeyup="CalcTotal();" /></td></tr><tr><td><Select Name="Drd3" OnChange=" Fn_Drd_Change('Drd3','Txt3')"><% Call Fillcombo("BISCUITSSNACKSandSWEETS", "name","price") %></Select></td><td><INPUT Name="Txt3" Value="" size=6 /></td><td><INPUT type=text Name="amnt3" Value="" size=6 onkeyup="CalcTotal();" /></td></tr><tr><td><Select Name="Drd4" OnChange=" Fn_Drd_Change('Drd4','Txt4')"><% Call Fillcombo("BREAKFASTCEREALS", "name","price") %></Select></td><td><INPUT Name="Txt4" Value="" size=6 /></td><td><INPUT type=text Name="amnt4" Value="" size=6 onkeyup="CalcTotal();" /></td></tr><tr><td><Select Name="Drd5" OnChange=" Fn_Drd_Change('Drd5','Txt5')"><% Call Fillcombo("COOKINGINGREDIENTS", "name","price") %></Select></td><td><INPUT Name="Txt5" Value="" size=6 /></td><td><INPUT type=text Name="amnt5" Value="" size=6 onkeyup="CalcTotal();" /></td></tr><tr><td><Select Name="Drd6" OnChange=" Fn_Drd_Change('Drd6','Txt6')"><% Call Fillcombo("DAIRYEGGSandCHEESE", "name","price") %></Select></td><td><INPUT Name="Txt6" Value="" size=6 /></td><td><INPUT type=text Name="amnt6" Value="" size=6 onkeyup="CalcTotal();" /></td></tr><tr><td><Select Name="Drd7" OnChange=" Fn_Drd_Change('Drd7','Txt7')"><% Call Fillcombo("FRESHFRUIT", "name","price") %></Select></td><td><INPUT Name="Txt7" Value="" size=6 /></td><td><INPUT type=text Name="amnt7" Value="" size=6 onkeyup="CalcTotal();" /></td></tr><tr><td><Select Name="Drd8" OnChange=" Fn_Drd_Change('Drd8','Txt8')"><% Call Fillcombo("FROZENCHIPSandVEG", "name","price") %></Select></td><td><INPUT Name="Txt8" Value="" size=6 /></td><td><INPUT type=text Name="amnt8" Value="" size=6 onkeyup="CalcTotal();" /></td></tr><tr><td><Select Name="Drd9" OnChange=" Fn_Drd_Change('Drd9','Txt1')"><% Call Fillcombo("FROZENDESERTICECREAM", "name","price") %></Select></td><td><INPUT Name="Txt9" Value="" size=6 /></td><td><INPUT type=text Name="amnt9" Value="" size=6 onkeyup="CalcTotal();" /></td></tr><tr><td><Select Name="Drd10" OnChange=" Fn_Drd_Change('Drd10','Txt10')"><% Call Fillcombo("FROZENMEATFISHandPOULTRY", "name","price") %></Select></td><td><INPUT Name="Txt10" Value="" size=6 /></td><td><INPUT type=text Name="amnt10" Value="" size=6 onkeyup="CalcTotal();" /></td></tr><tr><td><Select Name="Drd11" OnChange=" Fn_Drd_Change('Drd11','Txt11')"><% Call Fillcombo("FROZENREADYMEALSPIZZA", "name","price") %></Select></td><td><INPUT Name="Txt11" Value="" size=6 /></td><td><INPUT type=text Name="amnt11" Value="" size=6 onkeyup="CalcTotal();" /></td></tr><tr><td><Select Name="Drd12" OnChange=" Fn_Drd_Change('Drd12','Txt12')"><% Call Fillcombo("MEATFISHandPOULTRY", "name","price") %></Select></td><td><INPUT Name="Txt12" Value="" size=6 /></td><td><INPUT type=text Name="amnt12" Value="" size=6 onkeyup="CalcTotal();" /></td></tr><tr><td><Select Name="Drd13" OnChange=" Fn_Drd_Change('Drd13','Txt13')"><% Call Fillcombo("READYMEALSandPIZZA", "name","price") %></Select></td><td><INPUT Name="Txt13" Value="" size=6 /></td><td><INPUT type=text Name="amnt13" Value="" size=6 onkeyup="CalcTotal();" /></td></tr><tr><td><Select Name="Drd14" OnChange=" Fn_Drd_Change('Drd14','Txt14')"><% Call Fillcombo("READYMEALSandPIZZA", "name","price") %></Select></td><td><INPUT Name="Txt14" Value="" size=6 /></td><td><INPUT type=text Name="amnt14" Value="" size=6 onkeyup="CalcTotal();" /></td></tr><tr><td><Select Name="Drd15" OnChange=" Fn_Drd_Change('Drd15','Txt15')"><% Call Fillcombo("SPIRITS", "name","price") %></Select></td><td><INPUT Name="Txt15" Value="" size=6 /></td><td><INPUT type=text Name="amnt15" Value="" size=6 onkeyup="CalcTotal();" /></td></tr><tr><td><Select Name="Drd16" OnChange=" Fn_Drd_Change('Drd16','Txt16')"><% Call Fillcombo("TINSPACKETSandJARS", "name","price") %></Select></td><td><INPUT Name="Txt16" Value="" size=6 /></td><td><INPUT type=text Name="amnt16" Value="" size=6 onkeyup="CalcTotal();" /></td></tr><<tr><td><Select Name="Drd17" OnChange=" Fn_Drd_Change('Drd17','Txt17')"><% Call Fillcombo("VEGSALADSandDIPS", "name","price") %></Select></td><td><INPUT Name="Txt17" Value="" size=6 /></td><td><INPUT type=text Name="amnt17" Value="" size=6 onkeyup="CalcTotal();" /></td></tr><tr><td><Select Name="Drd18" OnChange=" Fn_Drd_Change('Drd18','Txt18')"><% Call Fillcombo("WINES", "name","price") %></Select></td><td><INPUT Name="Txt18" Value="" size=6 /></td><td><INPUT type=text Name="amnt18" Value="" size=6 onkeyup="CalcTotal();" /></td></tr><tr><td><input type="submit" value="Submit"><input id="myTotalField" type="text" /></td></tr></table></form></body></html>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...