3 Replies - 629 Views - Last Post: 24 October 2008 - 10:29 AM

#1 miensta  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 33
  • Joined: 03-May 08

Allowing certain users to order certain items on an order form

Posted 24 October 2008 - 10:09 AM

Basically, this is an order form. I'm trying to create a function where those who wear navy (RNs, CRNPs) are the only ones allowed to order Maternity pants. Also, the fleece jacket is not available in brown, which is what Support Associates wear. Please help!!!

Here's the code for the front end order page:
<script type="text/javascript">
function writeTable(evenorodd, thescrubid, thesize, thequantity){
	document.write('<tr class="');
	if( evenorodd % 2 ==0){
		document.write('even');}
	else if ( evenorodd % 2 == 1){
		document.write('odd');}
	document.write('"><td>' + thescrubid + '</td>');
	var description = getDescription(thescrubid);
	document.write('<td>' + description + '</td>');
	document.write('<td>' + thesize + '</td>');
	var thecost = setCostOfScrubs(thescrubid);
	var value = thequantity * thecost;
	document.write('<td class="alignment">' + thequantity + '</td>');
	document.write('<td class="alignment">$' + value.toFixed(2) + '</td></tr>');
	return value;
}
function endLine(theline, thestring, theammount){
document.write('<tr><td class="hidemybottomother" colspan="2">' + theline + '</td><td class="hidemybottom" colspan="2"><strong>' + thestring + ': </strong></td><td class="bottomline">$' + theammount.toFixed(2) + '</td></tr>');
}
function scrubcolor(){
	if(document.uniforms_f.position[document.uniforms_f.position.selectedIndex].value == "default"){
	document.getElementById('colorwine').style.display = 'none';
	document.getElementById('colorsand').style.display = 'none';
	document.getElementById('colorbrown').style.display = 'none';
	document.getElementById('colornavy').style.display = 'none';
	document.getElementById('colornone').style.display = 'block';
	}
	else if(document.uniforms_f.position[document.uniforms_f.position.selectedIndex].value == "C.N.A."){
	document.getElementById('colorwine').style.display = 'block';
	document.getElementById('colorsand').style.display = 'none';
	document.getElementById('colorbrown').style.display = 'none';
	document.getElementById('colornavy').style.display = 'none';
	document.getElementById('colornone').style.display = 'none';
	}
	else if(document.uniforms_f.position[document.uniforms_f.position.selectedIndex].value == "Unit Secretary"){
	document.getElementById('colorwine').style.display = 'none';
	document.getElementById('colorsand').style.display = 'block';
	document.getElementById('colorbrown').style.display = 'none';
	document.getElementById('colornavy').style.display = 'none';
	document.getElementById('colornone').style.display = 'none';
	}
	else if(document.uniforms_f.position[document.uniforms_f.position.selectedIndex].value == "Support Associate"){
	document.getElementById('colorwine').style.display = 'none';
	document.getElementById('colorsand').style.display = 'none';
	document.getElementById('colorbrown').style.display = 'block';
	document.getElementById('colornavy').style.display = 'none';
	document.getElementById('colornone').style.display = 'none';
	}
		else
	{
	document.getElementById('colorwine').style.display = 'none';
	document.getElementById('colorsand').style.display = 'none';
	document.getElementById('colorbrown').style.display = 'none';
	document.getElementById('colornavy').style.display = 'block';
	document.getElementById('colornone').style.display = 'none';
	}
}
function printSheet(){
	if(document.uniforms_f.deptName[document.uniforms_f.deptName.selectedIndex].value == "default"){
	alert('Please Choose a Department');
	document.uniforms_f.deptName.focus();
	return false;
	}
	if(document.uniforms_f.position[document.uniforms_f.position.selectedIndex].value == "default"){
		alert('Please Choose a Position');
		document.uniforms_f.position.focus();
		return false;
	}
	var thiswindow=window.self
	var discount = 0;
	var discount10106 = 0;
	var discount50106 = 0;
	var total = 0;
	var current = document.uniforms_f;
	var writePhones = "";
	if(document.uniforms_f.dayPhone.value != ""){
		writePhones = writePhones + 'Day: ' + document.uniforms_f.dayPhone.value + '<br />';}
	if(document.uniforms_f.eveningPhone.value !=""){
		writePhones = writePhones + 'Evening: ' + document.uniforms_f.eveningPhone.value + '<br />';}
	if(document.uniforms_f.address1Line2.value != ""){
		var writeAddress2 =  current.address1Line2.value + '<br />';}
	else{
		var writeAddress2 = "";}
	var address1info
	address1info = current.name.value+'<br />' +current.address1Line1.value + '<br />' + writeAddress2 + current.address1City.value + ", " + current.address1State.value + " " + current.address1ZipCode.value + '<br />' + writePhones;
//}
	var address2info;
	if(current.pleaseDeliverTo[0].checked){
		address2info = current.name.value+'<br />' +current.address1Line1.value + '<br />' + writeAddress2 + current.address1City.value + ", " + current.address1State.value + " " + current.address1ZipCode.value;}
	else{
		if(current.address2Line2.value != ""){
			var writeAddress2Line2 =  current.address2Line2.value + '<br />';}
		else{
			var writeAddress2Line2 = "";}
				address2info = current.name.value+'<br />' +current.address2Line1.value + '<br />' + writeAddress2Line2 + current.address2City.value + ", " + current.address2State.value + " " + current.address2ZipCode.value;
	}
	var emailAdd = current.email.value;

	var theid = new Array();
	var thesize = new Array();
	var thequantity = new Array();
	var theoffset = 0;
	var rowclass = 1;

	var first = getElementsIndex(document.uniforms_f.firstfield) +1;
	var last = getElementsIndex(document.uniforms_f.subTotal);
	for (var i=first;i<last;i++){
		current = document.uniforms_f.elements[i];
		if(document.uniforms_f.elements[i].value >= 1){
		rowclass++;
		var temp = current.name.split('-');
		theid[(i-theoffset-first)] = temp[0];
		thesize[(i-theoffset-first)] = temp[1];
		thequantity[(i-theoffset-first)] = current.value;
		if(temp[0] == "10106" || temp[0] == "10106X") {
			discount10106 = current.value * 1 + discount10106 * 1;}
		if(temp[0] == "50106" || temp[0] == "50106X"){
			discount50106 = current.value * 1 + discount50106 * 1;}
		}
		else{
		theoffset++;
		}	
	}
	if(discount10106 <= discount50106){
		discount = discount10106;
	}
	else{
		discount = discount50106;
	}
		
	var department;
	var newindex = document.uniforms_f.deptName.selectedIndex;
	department = document.uniforms_f.deptName[newindex].value;
	
	var position;
	var colorwork;
	position = document.uniforms_f.position[document.uniforms_f.position.selectedIndex].value
	if(position == "C.N.A."){
		colorwork = "Wine";
	}
	else if(position == "Unit Secretary"){
		colorwork = "Sand";
	}
	else if(position == "Suport Associate"){
		colorwork = "Brown";
	}
	else{
		colorwork = "Navy";
	}	
	var payment;
	var current = document.uniforms_f;
	if(document.uniforms_f.paymentType[0].checked == true)
	{
		payment = "Check";
	}
	else
	{
		payment = "Credit Card";
	}

	document.write('<html><head><link href="scrubs/trial.css" rel="stylesheet" type="text/css" /></head><body>');
	document.write('<div class="printinvoice">');
		for(var i=0; i < theid.length; i++)
	{
		total = total + writeTable(i,theid[i],thesize[i],thequantity[i]);
	}
	var delFee = 0;
	if(total <= 20) {
	delFee = 7.00;}
	else if(total<= 50) {
	delFee = 9.00;}
	else{
				var additionals = parseInt((total-50.01) / 25);
					
					if (additionals < 1){
					additionals = 2;
					delFee = parseInt(9.00 + additionals);
					}
					else{
					additionals ++;
					additionals = additionals *2;
					delFee = parseInt(9.00 + additionals);
					}
				}
	document.write('<tr><td class="hidemybottomother1st hidemybottomother" colspan="2" style="text-align:left; border-right:hidden;"><strong>Color:</strong> ' + colorwork + '</td><td colspan="2" class="hidemybottom1st" style="border-left: hidden;"><strong>Subtotal:</strong> </td><td class="bottomline">$' + total.toFixed(2) + '</td></tr>');
	endLine('<strong>Line 1: </strong>HUP Pyramid Logo','Delivery Fee', delFee);
	endLine('<strong>Line 2: </strong>' + department,'Discount', (discount*-1));
	var finaltotal = (total+delFee-discount);
	endLine('<strong>Line 2: </strong>' + position + '<strong> Placement:</strong>#14 ULC <strong>Font:</strong>#2 Full Block <strong>Size:</strong>#2 3/8 <strong>Color:</strong> #2 White','Total', finaltotal);
	
	document.write('</table>');
	document.write('<strong>Payment Method:</strong> ' + payment + '<br />');

	document.close();
	}
	function calculateUpdate(){
		var total=0;
		var theoffset = 0;
		var discount = 0;
		var discount10106 = 0;
		var discount50106 = 0;
		var theid = new Array;
		var thesize = new Array; 
		var thequantity = new Array;
		var first = getElementsIndex(document.uniforms_f.firstfield) + 1;
		var last = getElementsIndex(document.uniforms_f.subTotal);
		for (var i=first;i<last;i++)
		{
			var current = document.uniforms_f.elements[i];
			if(document.uniforms_f.elements[i].value >= 1){
				var temp = current.name.split('-');
				theid[(i-theoffset-first)] = temp[0];
				thesize[(i-theoffset-first)] = temp[1];
				thequantity[(i-theoffset-first)] = current.value;
				if(temp[0] == "10106" || temp[0] == "10106X") {
					discount10106 = current.value * 1 + discount10106 * 1;}
				if(temp[0] == "50106" || temp[0] == "50106X"){
					discount50106 = current.value * 1 + discount50106 * 1;}
			}
			else
			{
				theoffset++;
			}	
		}
		if(discount10106 <= discount50106){
			discount = discount10106;
		}
		else{
			discount = discount50106;
		}
		for(var i=0; i < theid.length; i++){
			var thecost = setCostOfScrubs(theid[i]);
			var value = thequantity[i] * thecost;
			total = total + value;
		}
		var delFee = 0;
		if(total <= 20) {
			delFee = 7.00;}
		else if(total<= 50) {
			delFee = 9.00;}
		else{
			var additionals = parseInt((total-50.01) / 25);
			if (additionals < 1){
				additionals = 2;
				delFee = parseInt(9.00 + additionals);
			}else{
				additionals ++;
				additionals = additionals *2;
				delFee = parseInt(9.00 + additionals);
			}
		}
		var finaltotal = (total+delFee-discount);
		document.uniforms_f.totalPrice.value = finaltotal.toFixed(2);
		document.uniforms_f.theDiscount.value = discount.toFixed(2);
		document.uniforms_f.deliveryFee.value = delFee.toFixed(2);
		document.uniforms_f.subTotal.value = total.toFixed(2);
	}
</script>
<script src="uniformsValidation.js" type="text/javascript"></script>
<script src="scrubobject5.js" type="text/javascript"></script>

<title>New HUP Nursing Uniform Order Form</title>
</head>
<body style="font-size:12px;"> <!--Keep at 12, it is used to define the size of the ems, changes will disrupt layout.-->
<div id="maincontainer">
<div id="topsection">
</div>
<div id="contentwrapper">
<div id="contentcolumn">
<div class="dontPrint">
	<div class="content">
	<div class="container">
	<form name="uniforms_f" method="POST" action="/cgi-bin/FormLogger.asp" style="text-align:left;">
	<label class="long">Position:
									<select name="position" onchange="scrubcolor();">
										<option value="default" selected>Select Your Position</option>
										<option value="C.N.A.">C.N.A.</option>
										<option value="R.N.">R.N.</option>
										<option value="C.R.N.P.">C.R.N.P.</option>
										<option value="Unit Secretary">Unit Secretary</option>
										<option value="Support Associate">Support Associate</option>
										
									</select>
								<br  /><br />Color of Your Scrubs: 
								<img src="scrubs/images/wine.png" id="colorwine" style="display:none;" />
								<img src="scrubs/images/sand.jpg" id="colorsand" style="display:none;" />
								<img src="scrubs/images/chocbrown.jpg" id="colorbrown" style="display:none;" />
								<img src="scrubs/images/navy.png" style="display:none;" id="colornavy" />
								<span id="colornone" style="display: block;">N/A</span>
								</label>



This post has been edited by miensta: 24 October 2008 - 10:15 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Allowing certain users to order certain items on an order form

#2 miensta  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 33
  • Joined: 03-May 08

Re: Allowing certain users to order certain items on an order form

Posted 24 October 2008 - 10:15 AM

"scrubobject5.js" is the pricing component, dont worry about "uniformvalidation.js".
Was This Post Helpful? 0
  • +
  • -

#3 abgorn  Icon User is offline

  • sudo apt-get install brain
  • member icon

Reputation: 30
  • View blog
  • Posts: 1,410
  • Joined: 05-June 08

Re: Allowing certain users to order certain items on an order form

Posted 24 October 2008 - 10:27 AM

If your gonna post Javascript, post it in the Javascript forum (here):
http://www.dreaminco...showforum90.htm
Was This Post Helpful? 0
  • +
  • -

#4 miensta  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 33
  • Joined: 03-May 08

Re: Allowing certain users to order certain items on an order form

Posted 24 October 2008 - 10:29 AM

View Postabgorn, on 24 Oct, 2008 - 10:27 AM, said:

If your gonna post Javascript, post it in the Javascript forum (here):
http://www.dreaminco...showforum90.htm

Oh crap. I've been having trouble posting this at all and i uh. guess i messed up.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1