Hello All,
I have an interesting one here - I have pieced together the script below which, when a user selects from the dropdown the choice (value of the option) is passed to a text field -- then -- the dropdown is hidden -- that way multiple choices cannot be made -- this works great -- but is there a way to have this pass the (label) instead as a calculate function seems to require the (value) which at the moment is text, be numerical so the calculated amount (added) will be displayed in the (sub field) -- furthermore -- the (qty) input field will then multiply the sub by the qty and display the result in the (amount) field - can this be done? I've been trying for three days now and after 18/22 attempts I'm going nutzoid here is the code as it stands to this point
I have an interesting one here - I have pieced together the script below which, when a user selects from the dropdown the choice (value of the option) is passed to a text field -- then -- the dropdown is hidden -- that way multiple choices cannot be made -- this works great -- but is there a way to have this pass the (label) instead as a calculate function seems to require the (value) which at the moment is text, be numerical so the calculated amount (added) will be displayed in the (sub field) -- furthermore -- the (qty) input field will then multiply the sub by the qty and display the result in the (amount) field - can this be done? I've been trying for three days now and after 18/22 attempts I'm going nutzoid here is the code as it stands to this point
Code:
<html>
<head>
<title> -- </title>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "[URL unfurl="true"]http://www.w3.org/TR/1999/PR-xhtml1-19991210/DTD/xhtml1-transitional.dtd">[/URL]
</head>
<body bgcolor="#FFFFFF" text="#000000" marginwidth="0" marginheight="0" topmargin="0" leftmargin="0">
<table width="317" height="214" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#FF9900">
<tr>
<td><table width="100%" border="0" cellpadding="18" cellspacing="0" bgcolor="#FFFFFF">
<tr>
<td><form name="x_click" id="x_click">
<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center" bgcolor="#FFFFFF">
<tr>
<td width="50%" >
<script language="JavaScript" type="text/javascript">
<!-- Begin passtxt
oldvalue = "";
function passText(passedvalue) {
if (passedvalue != "") {
var totalvalue = passedvalue+":\n"+oldvalue;
document.x_click.itemsbox.value = totalvalue;
oldvalue = document.x_click.itemsbox.value;
}
}
// End passtxt-->
<!-- hide drop downs
function ShowTB(obj,id){
txt=obj.options[obj.selectedIndex].text;
// items in array go here //
if (txt.match('Mens')){
document.getElementById(id).style.visibility='hidden';
}
if (txt.match('Womens')){
document.getElementById(id).style.visibility='hidden';
}
if (txt.match('Girls')){
document.getElementById(id).style.visibility='hidden';
}
// sizes of items in array go here //
if (txt.match('Small')){
document.getElementById(id).style.visibility='hidden';
}
if (txt.match('Medium')){
document.getElementById(id).style.visibility='hidden';
}
if (txt.match('Large')){
document.getElementById(id).style.visibility='hidden';
}
// colors of items in array go here //
if (txt.match('Red')){
document.getElementById(id).style.visibility='hidden';
}
if (txt.match('Blue')){
document.getElementById(id).style.visibility='hidden';
}
if (txt.match('Green')){
document.getElementById(id).style.visibility='hidden';
}
if (txt.match('White')){
document.getElementById(id).style.visibility='hidden';
}
if (txt.match('Yellow')){
document.getElementById(id).style.visibility='hidden';
}
if (txt.match('Black')){
document.getElementById(id).style.visibility='hidden';
}
}
// end hide-->
<!-- rload page
function refresh()
{
window.location.reload( false );
}
//-->
</script>
<font face="Arial, Helvetica, Sans Serif" size="3"><b>Select an Item:</b></font><br />
<select name="gender" size="1" onchange="passText(this.form.gender.options[this.form.gender.selectedIndex].value);ShowTB(this,'gender');" id="gender" style="visibility:visible;" >
<option value="">Make selection</option>
<option value="Mens">Mens</option>
<option value="Womens">Womens</option>
<option value="Girls">Girls</option>
</select>
</td>
<td colspan="2" rowspan="5"><textarea name="itemsbox" cols="15" rows="5" onfocus="this.blur()"></textarea></td>
</tr>
<tr>
<td height="18"> </td>
</tr>
<tr>
<td height="40"><font face="Arial, Helvetica, Sans Serif" size="3"><b>Choose a Size:</b></font><br />
<select name="size" size="1" id="size" onchange="passText(this.form.size.options[this.form.size.selectedIndex].value);ShowTB(this,'size');" style="visibility:visible;" >
<option value="">Choose Size</option>
<option value="Small">Small</option>
<option value="Medium">Medium</option>
<option value="Large">Large</option>
</select></td>
</tr>
<tr>
<td height="18"> </td>
</tr>
<tr>
<td height="40"><font face="Arial, Helvetica, Sans Serif" size="3"><b>Choose a Color:</b></font><br/>
<select name="color" size="1" id="color" onchange="passText(this.form.color.options[this.form.color.selectedIndex].value);ShowTB(this,'color');" style="visibility:visible;" >
<option value="">Choose Color</option>
<option value="Red">Red</option>
<option value="Blue">Blue</option>
<option value="Green">Green</option>
<option value="White">White</option>
<option value="Yellow">Yellow</option>
<option value="Black">Black</option>
</select></td>
</tr>
<tr>
<td> </td>
<td width="1%"> </td>
<td width="49%"><font face="Arial, Helvetica, Sans Serif" size="3"><b>Quantity:</b></font><br/>
<input name="qty" type="text" id="qty" value="1" size="4" /></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td><font face="Arial, Helvetica, Sans Serif" size="3"><b>Sub Total :</b></font><br/>
<input name="sub" type="text" id="sub" size="9" /></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td><font face="Arial, Helvetica, Sans Serif" size="3"><b>Total of Order:</b></font><br/>
<input name="amount" type="text" id="amount" size="9" /></td>
</tr>
</table>
</form></td>
</tr>
<tr>
<td></td>
</tr>
</table>
<table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
<tr>
<td height="21"><form method="GET" action="refreshbutton.htm">
<div align="center">
<input type="button" onclick="refresh()" value="Reset My Selections" name="refresh_page">
</div>
</form></td></tr>
</table></td>
</tr>
</table>
</body>
</html>