This is a discussion on "Simple if statement question." within the Classic ASP section. This forum, and the thread "Simple if statement question. are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
Simple if statement question.
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
#1
|
|||
|
|||
|
Simple if statement question.
Hello everybody, I have only just started using ASP so if this question seems pretty obvious to you guys then bare with me.
Basically I have one page with a form on it and two dropdown menus. I want to take the result from both drop down boxes and on the next page use these differing answers to generate a quote. However I don't know the proper syntax of how to do this (although I'm pretty sure an If then else statement would suffice). I have put all the code on the second page and it is just pulling through the data from the drop down menus on the first page. Here is my code: //Type and Level are the names of the drop down menus on the previous page strType = request.form("Type") strLevel = request.form("Level") myQuote = "0" if (strType="Type A")&&(strLevel="Level 1") then myQuote = "8.60" else if (strType="Type A")&&(strLevel="Level 2") then myQuote = "10.20" etc etc etc else myQuote = "2" end if Any help would be much appreciated. |
|
|
|
#2
|
||||
|
||||
|
It would make more sense to use a nested Select statement:-
__________________
Click the 'Thanks!' button if this post has helped you Rob - Webforumz Founder
Last Blog Entry: Creative Labs threaten developer over home made drivers.... (Apr 1st, 2008)
|
|
#3
|
|||
|
|||
|
I'd do it something like this...
Lol, sorry for being lazy, I put in text boxes, so just type in the different combinations to see your result. |
|
#4
|
|||
|
|||
|
Rob.. why would you use a select Case statement here? Its a yes or no question... nothing worth going through all of that for.
|
|
#5
|
||||
|
||||
|
<blockquote id="quote" class="ffs">quote:<hr height="1" noshade="noshade" id="quote" />Its a yes or no question... nothing worth going through all of that for.<hr height="1" noshade="noshade" id="quote" /></blockquote id="quote">
Funny Court Jester.... I cannot see one single mention of the fact it is a yes / no question!! The presence of 'etc, etc, etc' would suggest it is not. Besides, the Select Case statement is far easier to read, and debug, as any ASP developer here will tell ya!
__________________
Click the 'Thanks!' button if this post has helped you Rob - Webforumz Founder
Last Blog Entry: Creative Labs threaten developer over home made drivers.... (Apr 1st, 2008)
|
|
#6
|
|||
|
|||
|
...and its faster
|
|
#7
|
|||
|
|||
|
Well.. Its an A or its going to be B. So If A was Yes, then be would be No.... I figured you had some good reason why you used that.
|
|
#8
|
||||
|
||||
|
I think the presense of 'etc, etc, etc' means he could not be bothered to use C, D and E
__________________
Click the 'Thanks!' button if this post has helped you Rob - Webforumz Founder
Last Blog Entry: Creative Labs threaten developer over home made drivers.... (Apr 1st, 2008)
|
|
#9
|
|||
|
|||
|
Ahh and there it is ladies and gents... lol
ok... but do you use quotes around the numbers in your code?? I thought quotes made them where they don't add but attatch them to the end of the previous number.. |
|
#10
|
||||
|
||||
|
in this case, it aint numbers.... it is a string.
__________________
Click the 'Thanks!' button if this post has helped you Rob - Webforumz Founder
Last Blog Entry: Creative Labs threaten developer over home made drivers.... (Apr 1st, 2008)
|
|
#11
|
|||
|
|||
|
Ahh, ok. Thanks for explaining it to me
|
|
#12
|
|||
|
|||
|
Yes you are right Rob, I was just being lazy and couldn't be bothered to type out the whole code. I have Type A to Type D in the actual code.
I have tried your nested select statement but all I get is an HTTP 500 - Internal server error. My code now reads like this:
Should it matter whereabouts on the page I put this code? |
|
#13
|
||||
|
||||
|
not quite right.... use this:-
__________________
Click the 'Thanks!' button if this post has helped you Rob - Webforumz Founder
Last Blog Entry: Creative Labs threaten developer over home made drivers.... (Apr 1st, 2008)
|
|
#14
|
|||
|
|||
|
Cheers Rob, you're a star.
|
|
#15
|
||||
|
||||
|
I know...
__________________
Click the 'Thanks!' button if this post has helped you Rob - Webforumz Founder
Last Blog Entry: Creative Labs threaten developer over home made drivers.... (Apr 1st, 2008)
|
|
#16
|
|||
|
|||
|
lol
|
![]() |
| Tags |
| simple, statement, question |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| hopefully a simple question | newoptical | Hosting & Domains | 9 | Sep 21st, 2007 22:02 |
| simple question | Daniel | Web Page Design | 29 | Feb 6th, 2007 17:23 |
| a simple question (I think) | Colm Osiris | Web Page Design | 2 | Feb 5th, 2006 09:17 |