Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Old 05-04-2005, 10:08 AM menu
millwalll's Avatar
Webmaster Talker

Posts: 674
Name: James
Location: KENT
Trades: 3
hi can anyone help im trying to get a drop down menu that show the price when you change quanty ive kinder got it jsut the script need a bit of editing ive got it to work with radio button and not a drop down one here the script have a look


<html>
<head>
<script type="text/javascript">
<!--
function updateQuantity(newQuantity) {
var unitPrice = 10.75;
document.forms['myForm'].elements['price'].value = newQuantity * unitPrice;
}
//-->
</script>
</head>

<body>
<form name="myForm">
Select quantity:
<select onchange="updateQuantity(this.value);">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="5">5</option>
<option value="10">10</option>
</select>
<br />
<input type="text" name="price" value="0.00" />
</form>
</body>
</html>



this is excatly what i want except when you click another button is has writing instead of just the pricen and i dont want it to be radio button i want the number to be in a drop down box instead help please
millwalll is offline
Reply With Quote
View Public Profile Visit millwalll's homepage!
 
 
Register now for full access!
Old 05-04-2005, 10:17 AM
Novice Talker

Posts: 13
Location: Sydney Australia
Trades: 0
i can't understand your grammar. could you repeat that?
__________________

Please login or register to view this content. Registration is FREE
rimian is offline
Reply With Quote
View Public Profile Visit rimian's homepage!
 
Old 05-04-2005, 10:20 AM
millwalll's Avatar
Webmaster Talker

Posts: 674
Name: James
Location: KENT
Trades: 3
what grammer do you not understand
millwalll is offline
Reply With Quote
View Public Profile Visit millwalll's homepage!
 
Old 05-04-2005, 10:24 AM
Novice Talker

Posts: 13
Location: Sydney Australia
Trades: 0
the last sentence. you just have a few typos in there. i can probably fix the javascript for you.
__________________

Please login or register to view this content. Registration is FREE
rimian is offline
Reply With Quote
View Public Profile Visit rimian's homepage!
 
Old 05-04-2005, 10:26 AM
millwalll's Avatar
Webmaster Talker

Posts: 674
Name: James
Location: KENT
Trades: 3
ok well the code above is excalty what i want it to do but instead of haveing the little buttons i want a drop down menu like that colour one with the numbers in hope this help clear it up
millwalll is offline
Reply With Quote
View Public Profile Visit millwalll's homepage!
 
Old 05-04-2005, 10:30 AM
Novice Talker

Posts: 13
Location: Sydney Australia
Trades: 0
it works ok yeah? i can see it works. but i can't work out what you don't like about it.

sorry for the confusion
__________________

Please login or register to view this content. Registration is FREE
rimian is offline
Reply With Quote
View Public Profile Visit rimian's homepage!
 
Old 05-04-2005, 10:39 AM
millwalll's Avatar
Webmaster Talker

Posts: 674
Name: James
Location: KENT
Trades: 3
you see the number 1 2 20 40 60 and so on i dont want them to be like that i want them to be in a drop down menu and if you click another number you dont get the price you get this &pound;20.00 i want get ride of the &pound: bit and jsut have the price hope this helps if not this is code is what im trying to get what may help is display the layout but it dont work


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<TABLE width="100%" border=0 cellPadding=0 cellSpacing=0
bgColor=#ffffff id=Table_02b>
<!--DWLayoutTable-->
<SCRIPT language=JavaScript>
<!--

function SymError()
{
return true;
}

window.onerror = SymError;

var SymRealWinOpen = window.open;

function SymWinOpen(url, name, attributes)
{
return (new Object());
}

window.open = SymWinOpen;

//-->
</SCRIPT>
<SCRIPT type=text/javascript>
<!--
function Dollar (val) { // force to valid dollar amount
var str,pos,rnd=0;
if (val < .995) rnd = 1; // for old Netscape browsers
str = escape (val*1.0 + 0.005001 + rnd); // float, round, escape
pos = str.indexOf (".");
if (pos > 0) str = str.substring (rnd, pos + 3);
return str;
}

function ReadForm (obj1, tst) { // Read the user form
var i,j,amt,des,obj,pos,val,op1a="",op1b="",op2a="",op 2b="";
amt = obj1.baseamt.value*1.0; // base amount
des = obj1.basedes.value; // base description
if (obj1.baseon0) op1a = obj1.baseon0.value; // base options
if (obj1.baseos0) op1b = obj1.baseos0.value;
if (obj1.baseon1) op2a = obj1.baseon1.value;
if (obj1.baseos1) op2b = obj1.baseos1.value;
for (i=0; i<obj1.length; i++) { // run entire form
obj = obj1.elements[i]; // a form element
if (obj.type == "select-one" && // just selects
obj.name == "") { // must be un-named
pos = obj.selectedIndex; // which option selected
val = obj.options[pos].value; // selected value
pos = val.indexOf ("@"); // price set?
if (pos >= 0) amt = val.substring (pos + 1)*1.0;
pos = val.indexOf ("+"); // price increment?
if (pos >= 0) amt = amt + val.substring (pos + 1)*1.0;
pos = val.indexOf ("%"); // percent change?
if (pos >= 0) amt = amt + (amt * val.substring (pos + 1)/100.0);
if (des.length == 0) des = val;
else des = des + ", " + val; // accumulate value
} else
if (obj.type == "checkbox" || // just get checkboxex
obj.type == "radio") { // and radios
if (obj.checked) {
val = obj.value; // the value of the selection
pos = val.indexOf ("@"); // price set?
if (pos >= 0) amt = val.substring (pos + 1)*1.0;
pos = val.indexOf ("+"); // price increment?
if (pos >= 0) amt = amt + val.substring (pos + 1)*1.0;
pos = val.indexOf ("%"); // percent change?
if (pos >= 0) amt = amt + (amt * val.substring (pos + 1)/100.0);
if (des.length == 0) des = val;
else des = des + ", " + val; // accumulate value, or text
}
} else
if (obj.type == "select-multiple") { //one or more
for (j=0; j<obj.options.length; j++) { // run all options
if (obj.options[j].selected) {
val = obj.options[j].value; // selected value (default)
if (des.length = 0) des = amt;
else des = des + ", " + val;// accumulate value, or text
pos = val.indexOf ("+"); // price increment?
if (pos >= 0) amt = amt + val.substring (pos + 1)*1.0;
}
}
} else
if ((obj.type == "text" || // just read text,
obj.type == "textarea") &&
obj.name != "tot" && // but not from here
obj.name != "quantity") {
val = obj.value; // get the data
if (val == "" && tst) { // force an entry
alert ("Enter data for " + obj.name);
return false;
}
tag = obj.name.substring (obj.name.length-2); // get flag
if (tag == "1a") op1a = op1a + " " + val;
else if (tag == "1b") op1b = op1b + " " + val;
else if (tag == "2a") op2a = op2a + " " + val;
else if (tag == "2b") op2b = op2b + " " + val;
else if (des.length == 0) des = val;
else des = des + ", " + val;
}
}
// Now summarize stuff we just processed, above
if (op1a.length > 0) obj1.on0.value = op1a;
if (op1b.length > 0) obj1.os0.value = op1b;
if (op2a.length > 0) obj1.on1.value = op2a;
if (op2b.length > 0) obj1.os1.value = op2b;
obj1.item_name.value = des;
obj1.amount.value = Dollar (amt);
if (obj1.tot) obj1.tot.value = "&pound;" + Dollar (amt);
}
//-->
</SCRIPT>
<TBODY>
<TR>
<TD width=9 height=1309>&nbsp;</TD>
<TD vAlign=top width=641> <FORM
onsubmit="this.target = 'paypal'; return ReadForm(this, true);"
action=https://www.paypal.com/cgi-bin/webscr method=post>
<P class=mainheadings>
<INPUT type=hidden value=_cart name=cmd>
<INPUT type=hidden value=1 name=add>
<INPUT type=hidden
value=millwalll@aol.com name=business>
<INPUT type=hidden
value="PERSONALISED SIDE WINDOW STICKERS" name=item_name>
<INPUT
type=hidden name=amount>
<INPUT type=hidden value=GBP
name=currency_code>
<INPUT type=hidden value=8 name=baseamt>
<INPUT
type=hidden value="PERSONALISED SIDE WINDOW STICKERS" name=basedes>
<INPUT type=hidden value=TEXT name=baseon0>
<INPUT type=hidden
name=baseos0>
<INPUT type=hidden name=on0>
<INPUT type=hidden
name=os0>
<BR>
</P>
<P class=smallbody>Size: 20cm width x 2cm height</P>
<P class=smallbody>TEXT (ARIAL BLACK)
<INPUT size=15
name=first_name_1b>
<BR>
COLOUR
<SELECT name="select">
<OPTION value=WHITE
selected>WHITE</OPTION>
<OPTION value=SILVER>SILVER</OPTION>
<OPTION value=YELLOW>YELLOW</OPTION>
<OPTION
value=RED>RED</OPTION>
<OPTION value=BLUE>BLUE</OPTION>
<OPTION
value=ORANGE>ORANGE</OPTION>
<OPTION value=PURPLE>PURPLE</OPTION>
<OPTION value=GREEN>GREEN</OPTION>
<OPTION
value=GOLD>GOLD</OPTION>
<OPTION value=BLACK>BLACK</OPTION>
</SELECT>
</P>
<P class=smallbody>QUANTITY
<select name="select2">
<option selected>1</option>
<option>2</option>
<option>20</option>
<option>40</option>
<option>60</option>
<option>80</option>
<option>100</option>
<option>200</option>
</select>
<BR>
<BR>
<BR>
<INPUT type=submit value="Add to Cart" name=submit>
&nbsp; &nbsp; &nbsp; Total item cost
<INPUT class=nbor size=8
value=&pound;8.20 name=tot>
&nbsp;&nbsp; </P>
</FORM>
<FORM
onsubmit="this.target = 'paypal'; return ReadForm(this, true);"
action=https://www.paypal.com/cgi-bin/webscr method=post>
</FORM>
<FORM action=https://www.paypal.com/cgi-bin/webscr method=post
target=paypal>
<DIV align=left><SPAN class=smallbody>so when you change qty the price changes </SPAN></DIV>
</FORM></TD>
</TR>
</TBODY>
</TABLE>
</body>
</html>
millwalll is offline
Reply With Quote
View Public Profile Visit millwalll's homepage!
 
Old 05-05-2005, 04:47 AM
millwalll's Avatar
Webmaster Talker

Posts: 674
Name: James
Location: KENT
Trades: 3
can anyone help as i need this asap i know it gonna be somethink simple
millwalll is offline
Reply With Quote
View Public Profile Visit millwalll's homepage!
 
Reply     « Reply to menu
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.30574 seconds with 11 queries