Jump to content

dealing with variables in forms

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
2 replies to this topic

#1
pioneer27

pioneer27

    Newbie

  • Members
  • PipPip
  • 14 posts
i have a JS calculator on my site right now that lets users calculate what an order will cost, i'm trying to figure out how to determine a cost by the amount input by an user to determine delivery cost, say the users inputs 1-3, the amount will be 8, 4-7 will be 10, etc.

#2
pioneer27

pioneer27

    Newbie

  • Members
  • PipPip
  • 14 posts
i know with php i could use a switch or if function, is there something simliar with JS?

#3
Turk4n

Turk4n

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 3,847 posts

pioneer27 said:

i know with php i could use a switch or if function, is there something simliar with JS?

Yes, there is...
Small example taken from site
switch(n)

{

case 1:

  execute code block 1

  break;    

case 2:

  execute code block 2

  break;

default:

  code to be executed if n is

  different from case 1 and 2

}
JavaScript Switch Statement
Posted Image