473,320 Members | 1,865 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Help With Javascript

Hi,

First let me say I do not know java much at all. Anyway, on my new website I have products that I want to have tiered pricing for. (i.e. 1-5 price $17.85, 6-11 price is $14.85, 12-23 price is $13.85, 24+ price is $11.85.) I want to offer tiered pricing but not sure how to do this. Any help or pointing me in the right direction would greatly be appreciated.

Thanks,
Berri
Feb 24 '07 #1
11 1465
r035198x
13,262 8TB
Hi,

First let me say I do not know java much at all. Anyway, on my new website I have products that I want to have tiered pricing for. (i.e. 1-5 price $17.85, 6-11 price is $14.85, 12-23 price is $13.85, 24+ price is $11.85.) I want to offer tiered pricing but not sure how to do this. Any help or pointing me in the right direction would greatly be appreciated.

Thanks,
Berri
Are you sure you want to use Java or did you mean Javascript? You will have to suppy more info and show the codes you have and where you want to put these prices.
Feb 24 '07 #2
Are you sure you want to use Java or did you mean Javascript? You will have to suppy more info and show the codes you have and where you want to put these prices.
Yes, sorry, I want a javascript to allow for multi level prices. If a customer orders 4 sets it is one price if its > 6 another price etc.

Ok, I do not know javascript but I can learn it, I think.

As an example I will have lots of products with different price variations but here is one, http://www.yourgiftspersonalized.com/Sailboat-Tealight-Holders-Set-of-4-p-76.html

Now here is what I think I need to add:

<script language=”javascript”>
Var data = {
<product productid=”76”>
<quantity> <6 </quantity>
<price>17.85</price>
<quantity> <12 </quantity>
<price> 14.85</price>
<quanity> <24 </quantity>
<price> 13.85</price>
<quantity> =>24</quantity>
<price>11.85</price>
</product>
};
</script>

My coding is probably incorrect but hopefully someone will understand.
The pricing for this particular product is: 1-5 = 17.85; 6-11= 14.85; 12-23= 13.85; 24+ = 11.85. I don't know how to do the if quantity is greater than or equal to so any help with this would be appreciated. I just did if greater than.

With xcart there is a place for me to add price modifiers and input javascript for each product I enter but since I don't know javascript I was hoping for help understanding if I am way off or on the right track or just plain help.

Another question with the code I have, do I need to find the productid # for each product or is there a better way to do that?

Thanks for your help!
Berri
Feb 24 '07 #3
abctech
157 100+
Yes, sorry, I want a javascript to allow for multi level prices. If a customer orders 4 sets it is one price if its > 6 another price etc.

Ok, I do not know javascript but I can learn it, I think.

As an example I will have lots of products with different price variations but here is one, http://www.yourgiftspersonalized.com...of-4-p-76.html

Now here is what I think I need to add:

<script language=”javascript”>
Var data = {
<product productid=”76”>
<quantity> <6 </quantity>
<price>17.85</price>
<quantity> <12 </quantity>
<price> 14.85</price>
<quanity> <24 </quantity>
<price> 13.85</price>
<quantity> =>24</quantity>
<price>11.85</price>
</product>
};
</script>

My coding is probably incorrect but hopefully someone will understand.
The pricing for this particular product is: 1-5 = 17.85; 6-11= 14.85; 12-23= 13.85; 24+ = 11.85. I don't know how to do the if quantity is greater than or equal to so any help with this would be appreciated. I just did if greater than.

With xcart there is a place for me to add price modifiers and input javascript for each product I enter but since I don't know javascript I was hoping for help understanding if I am way off or on the right track or just plain help.

Another question with the code I have, do I need to find the productid # for each product or is there a better way to do that?

Thanks for your help!
Berri
Hello Berri,
Java and JavaScript are not the same.This is the Java forum pal, you need to post in the JavaScript forum.They'll be able to help you out with the appropriate suggestions.

By the way here's a good link to start learning JavaScript if you are looking to code in it.
Feb 24 '07 #4
Hi,

First let me say I do not know java much at all. Anyway, on my new website I have products that I want to have tiered pricing for. (i.e. 1-5 price $17.85, 6-11 price is $14.85, 12-23 price is $13.85, 24+ price is $11.85.) I want to offer tiered pricing but not sure how to do this. Any help or pointing me in the right direction would greatly be appreciated.

I want a javascript to allow for multi level prices. If a customer orders 4 sets it is one price if its > 6 another price etc.

Ok, I do not know javascript but I can learn it, I think.

As an example I will have lots of products with different price variations but here is one, http://www.yourgiftspersonalized.com/Sailboat-Tealight-Holders-Set-of-4-p-76.html

Now here is what I think I need to add:

<script language=”javascript”>
Var data = {
<product productid=”76”>
<quantity> <6 </quantity>
<price>17.85</price>
<quantity> =6<12 </quantity>
<price> 14.85</price>
<quanity> =12<24 </quantity>
<price> 13.85</price>
<quantity> =>24</quantity>
<price>11.85</price>
</product>
};
</script>

My coding is probably incorrect but hopefully someone will understand.
The pricing for this particular product is: 1-5 = 17.85; 6-11= 14.85; 12-23= 13.85; 24+ = 11.85. I don't know how to do the if quantity is greater than or equal to so any help with this would be appreciated. I just did if greater than.

With xcart there is a place for me to add price modifiers and input javascript for each product I enter but since I don't know javascript I was hoping for help understanding if I am way off or on the right track or just plain help.

Another question with the code I have, do I need to find the productid # for each product or is there a better way to do that?

Thanks,
Berri
Feb 24 '07 #5
I'm not sure but it looks like X-Cart provides that feature without needing Javascript.

Search for "price modifier" in the X-Cart Manual.

Btw...

On your page, in every place where you have this:

onclick="javascript: js_code...

you need to remove "javascript:".

:)
Feb 25 '07 #6
I'm not sure but it looks like X-Cart provides that feature without needing Javascript.

Search for "price modifier" in the X-Cart Manual.

Btw...

On your page, in every place where you have this:

onclick="javascript: js_code...

you need to remove "javascript:".

:)
Hi Mike,

Yes, X-Cart does have the price modifier, the problem with that is I have to list each number 1-100 and for 1-5 leave blank since the default price is already in place with the product. So when I set up the product modifier it would say tiered price 1, 2, 3, 4, 5, 6, etc and than the qty box is there and it is really confusing. I was trying to add a javascript code to so when a customer put in "14" in the qty. box it would calculate the cost at the 13.85 price. 13.85 x 14. The way X-Cart has it with the price modifier is really confusing.

I was hoping to put in a java code that would do that but I don't know the correct java code.

Berri
Feb 25 '07 #7
I don't know anything about X-Cart - I only just peeked at the manual.

Here is some basic Javascript - this is only for you to have an idea of what the script might look like. It is not intended to be a final solution.

First, add the following onchange handler to the select:

Expand|Select|Wrap|Line Numbers
  1. <select id="product_avail" name="amount" onchange='adjustPrice(this)'>
  2.  
Now put this in one of the script elements (preferably in the head):
Expand|Select|Wrap|Line Numbers
  1. function adjustPrice(sel)
  2. {
  3.   var p = '', q = parseInt(sel.options[sel.selectedIndex].value);
  4.   if (!q) {
  5.     alert('Error!');
  6.     return;
  7.   }
  8.   else if (q >= 24) {
  9.     p = '11.85';
  10.   }
  11.   else if (q >= 12) {
  12.     p = '13.85';
  13.   }
  14.   else if (q >= 6) {
  15.     p = '14.85';
  16.   }
  17.   else {
  18.     p = '17.85';
  19.   }
  20.   document.getElementById('product_price').innerHTML = '$' + p;
  21. }
  22.  
This updates the price on the page (but not actually in the right place) - but it does not put it in the form to be submitted.

Where does the original price come from? Is it in a database on the server? If so then can you change the server-side code to output Js into the html file? I'm assuming you don't want to hard-code these prices in each page.

I could go on but...

as you can see, the Javascript is the easiest part of this task - the real changes should be made in the server-side script. Using Javascript to select a price should only be used for convenience. Your server-side code must still validate the users choices.
Feb 25 '07 #8
I don't know anything about X-Cart - I only just peeked at the manual.

Here is some basic Javascript - this is only for you to have an idea of what the script might look like. It is not intended to be a final solution.

First, add the following onchange handler to the select:

Expand|Select|Wrap|Line Numbers
  1. <select id="product_avail" name="amount" onchange='adjustPrice(this)'>
  2.  
Now put this in one of the script elements (preferably in the head):
Expand|Select|Wrap|Line Numbers
  1. function adjustPrice(sel)
  2. {
  3.   var p = '', q = parseInt(sel.options[sel.selectedIndex].value);
  4.   if (!q) {
  5.     alert('Error!');
  6.     return;
  7.   }
  8.   else if (q >= 24) {
  9.     p = '11.85';
  10.   }
  11.   else if (q >= 12) {
  12.     p = '13.85';
  13.   }
  14.   else if (q >= 6) {
  15.     p = '14.85';
  16.   }
  17.   else {
  18.     p = '17.85';
  19.   }
  20.   document.getElementById('product_price').innerHTML = '$' + p;
  21. }
  22.  
This updates the price on the page (but not actually in the right place) - but it does not put it in the form to be submitted.

Where does the original price come from? Is it in a database on the server? If so then can you change the server-side code to output Js into the html file? I'm assuming you don't want to hard-code these prices in each page.

I could go on but...

as you can see, the Javascript is the easiest part of this task - the real changes should be made in the server-side script. Using Javascript to select a price should only be used for convenience. Your server-side code must still validate the users choices.
Mike,

Thanks!

This site uses X-Cart which I am not familiar with and am trying to learn, I know for each product I can add a customer side but will have to look at the server-side. Yeah, I do not want to hard code this on all pages, some products will have tiered prices that will all have different price points so I am trying to find the best way to do this and make it easy for the customers at the same time.

Where in AL?

Berri
Feb 25 '07 #9
North Etowah county :)
Feb 25 '07 #10
r035198x
13,262 8TB
Yes, sorry, I want a javascript to allow for multi level prices. If a customer orders 4 sets it is one price if its > 6 another price etc.

Ok, I do not know javascript but I can learn it, I think.

As an example I will have lots of products with different price variations but here is one, http://www.yourgiftspersonalized.com/Sailboat-Tealight-Holders-Set-of-4-p-76.html

Now here is what I think I need to add:

<script language=”javascript”>
Var data = {
<product productid=”76”>
<quantity> <6 </quantity>
<price>17.85</price>
<quantity> <12 </quantity>
<price> 14.85</price>
<quanity> <24 </quantity>
<price> 13.85</price>
<quantity> =>24</quantity>
<price>11.85</price>
</product>
};
</script>

My coding is probably incorrect but hopefully someone will understand.
The pricing for this particular product is: 1-5 = 17.85; 6-11= 14.85; 12-23= 13.85; 24+ = 11.85. I don't know how to do the if quantity is greater than or equal to so any help with this would be appreciated. I just did if greater than.

With xcart there is a place for me to add price modifiers and input javascript for each product I enter but since I don't know javascript I was hoping for help understanding if I am way off or on the right track or just plain help.

Another question with the code I have, do I need to find the productid # for each product or is there a better way to do that?

Thanks for your help!
Berri
Moved to Javascript forum.
Feb 26 '07 #11
acoder
16,027 Expert Mod 8TB
Threads merged.
Feb 27 '07 #12

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Edward King | last post by:
Hi! I am trying to achieve the following: I have a number of help pages (in the format help_nn.php where nn=helpid). I want to be able to open a particular help page by calling the function...
5
by: TrvlOrm | last post by:
HI There, I have been struggling with JavaScript code for days now, and this is my last resort! Please help... I am trying to create a JavaScript slide show with links for Next Slide,...
7
by: mike | last post by:
Hello, I am kind of new to this javascript stuff and I am constantly having problems trying to get my webpage validated. I have the following <script>printdate();</script> and when I validate it...
9
by: YZK | last post by:
Hello. I'm not a Web developer, just a user, and I think I may have somehow messed myself up majorly. I'm not quite sure how. Right now, javascript used by websites I go to either does not work at...
5
by: Craig Keightley | last post by:
Please help, i have attached my page which worksin IE but i cannnot get the drop down menu to fucntion in firefox. Any one have any ideas why? Many Thanks Craig ...
0
by: Erland | last post by:
Hello All, I am using AJAX library( AjaxEngine from http://www.mathertel.de/AJAXEngine/) and having problems and hope someone here can help me. I have some piece of javascript code that I...
1
by: JumpingOffPlace | last post by:
Hi, I'm hoping that the wealth of knowledge here can stop me from spinning my wheels on this syntax error for hours. :) Below is the code, and the error I am recieving.... Code: <!DOCTYPE...
36
by: aljamala | last post by:
Hi, I keep getting this warning on a page, but I do not know what the problem is...does anyone have an idea about what could be wrong? line 88 column 7 - Warning: missing </formbefore <td> it...
0
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted...
7
by: gubbachchi | last post by:
Hi all, In my application I need to display the data fetched from mysql database after the user selects date from javascript calender. I have written the code in which after the user selects the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.