Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Exclude an item from being taxed on form

Status
Not open for further replies.

mbarandao

Programmer
May 28, 2012
14
US
Good day all:

I'm wondering how does one go about excluding a particular item on a form from being taxed?

I have a check box, which onclick, calculates the sales taxes on all items on the form.

to perform the tax calculation, I'm using:

Code:
var tax = ($('#taxbox').attr('checked')) ? (subtotal * taxRate) : 0;
$('#tax').val(isNaN(tax) ? errorMsg : tax.toCurrency());//Display value or 'error' if calculation failed[/code]

Any ideas on how this can be done?

Best,
 
Flag the item as non=taxable.

mmerlinn


Poor people do not hire employees. If you soak the rich, who are you going to work for?

"We've found by experience that people who are careless and sloppy writers are usually also careless and sloppy at thinking and coding. Answering questions for careless and sloppy thinkers is not rewarding." - Eric Raymond
 
I appreciate the reply, mmerlinn! Could you be a little more specific as to how to structure the flag --where on the code and how?

Best
 
add a rel attribute, the W3c spell check won't like it but hey!

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum
 
Or you could add your own tax="0" attribute.

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum
 
Hi

ChrisHirst said:
add a rel attribute, the W3c spell check won't like it but hey!

Or you could add your own tax="0" attribute.
Or he could do it the proper HTML5 way and use [tt]data-*[/tt] attribute. jQuery's [tt].data()[/tt] method also handles them.

( See HTML5 | Semantics, structure, and APIs of HTML documents | Elements | Global attributes | Embedding custom non-visible data with the data-* attributes. )

Feherke.
[link feherke.github.com/][/url]
 
Thank you all for your thoughts on this!

All those suggestions sound excellent only if I were dealing with inputs or texarea boxes; however, I'm trying to foster the determination based on the selection from a select list --and the data from the select list is populated from db. So essentially, I'm wondering if such tax exclusion could be done based on some sort of flag inputted at the db level and then flagged at selection point? and if so, how so?

If a visual assessment of the form is necessary, may I direct you to a link of the form? if so, please,Click here!

Your thoughts, please!
 
feherke, not sure of your question, but I suspect you are asking why I'm not dealing with input boxes? What I meant is this:

The form consist of 1 table row, in which I have a cascading pair of select boxes. The first select box contains data that determines the content of the second box and then the content of three other html elements.

Now this process can be added to the form dynamically. So the issue is that I may have some selection that I want to be tax exempted while other not. I don't believe I can perform the exclusion at the html element level with attribute or classes --I'm wrong on this?

This is what I meant by
 
Hi

Why sounds excellent only if you were dealing with [tt]input[/tt]s or [tt]texarea[/tt] ?

Or, why not sounds excellent while you are dealing with [tt]select[/tt]s ?


Feherke.
[link feherke.github.com/][/url]
 
I'm sorry, Feherke, I'm not following your question. Are you stating that I'm able to use rel attributes to the html structure I describe above? if so, may I ask for a sample code for a visual understanding. At the moment, I'm failing to understand!

Best,
Mossa
 
I'm wondering if such tax exclusion could be done based on some sort of flag inputted at the db level and then flagged at selection point? and if so, how so?

Probably! though not with javascript.

Although you could add a flag (as proposed earlier) to whatever elements you happen to be using, with some code whatever server side code you use to pull the data from whatever database server you happen to be using.







Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum
 
Thanks, Chris! That is exactly what I think would work, but I'm failing with the code's construction. I suspect that Javascript will still be required; whereas, if I append a "nontax" flag to a select list value on the db and once populated at the html level like so:

Code:
<select><option value="Disposal Fees:nontax">Disposal Fees</option></select>

I still needs javascript to then split the selected value to determine whether the selected item is taxable or not.

I think this is my best bet, I need help with the js code if my select box as a flag appended to its value --as demonstrated in the above code.
 
Hi

Mossa said:
Are you stating that I'm able to use rel attributes to the html structure I describe above?
No. But with [tt]data-*[/tt] attributes, yes.
HTML5 said:
Every HTML element may have any number of custom data attributes specified, with any value.

I put together a minimal example on jsFiddle. The [tt]tr[/tt] can be repeated, the calculation will be performed on the one firing the [tt]onchange[/tt].

Feherke.
[link feherke.github.com/][/url]
 
Very kind, Feherke! I'll take a look it and advise shortly.

Thank you!
Mossa
 
Feherke, I appreciate the example on jsFiddle. The example binds the tax amount to the total; whereas, I need my form to be able keep the total taxes on all taxable items separate. It would be something like:

item1=(selected) | item1_subucat=(selected) | qty=2 | cost=$$ | item1_total =$$$
(notax) item2=(selected) | item2_subucat=(selected) | qty=3 | cost=$$ | item1_total =$$$

subtotal = $$$$$
tax =$$$
total $$$

Pardon the terrible schematic, but it is something this that I'm trying to implement. Is something like so doable?

Mossa
 
Hi

Sorry, I do not really understand the whole problem.

Excepting that your sketch indicates the presence of a second [tt]select[/tt], apparently not related to the tax calculation, I see no difference. So I would say, it is doable.

Just to clarify. As I understand, each item can either have or not have tax and this is influenced only by the selection made in the first [tt]select[/tt] control of the same row. Right ?

Feherke.
[link feherke.github.com/][/url]
 
ust to clarify. As I understand, each item can either have or not have tax and this is influenced only by the selection made in the first select control of the same row. Right ?

Your understanding is correct! the second select is linked with the selection of the first, but the relevant tax identifier would be based on the first.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top