Click to See Complete Forum and Search --> : nested if's syntax
Rterres
08-18-2006, 03:31 PM
Hello hard coders...!!
do anyone know where i can find a vb script guide..
i need to obtian some field value but it has many options to validate..
that is why i need the nested if's or the "switch" sentence...
thanks for
All-
regards
RT
ahk2chan
08-18-2006, 03:50 PM
Switch statement in VBScript is:
Select Case testopt
Case 1
...
Case 2
...
Case Else
...
End Select
Nested If is:
If testopt = 1 Then
...
If testopt2 = 2 Then
...
Else
...
End If
ElseIf testopt = 2 Then
...
Else
...
End If
Rterres
08-18-2006, 06:00 PM
Ok. thanks in advance!!
but check this..
this is the global Sentence...
with an external If to validate a if producto is equal to "magna"
<%Dim importe
If FP_FieldVal(fp_rs, "producto") = "magna" then
importe = FP_FieldVal(fp_rs, "Nombre_completo_inq")
but the if also have to check this...
if (FP_FieldVal(fp_rs,"monto_mens"))*(0.20)<=4347 Then
Response.Write FormatCurrency(5000)
Else
Response.Write FormatCurrency(FP_FieldVal(fp_rs,"monto_mens")*(0.20))
End If
How do i combine both...???
Thaaaanks!! Again..
RT
Rterres
08-21-2006, 09:35 PM
OK Im gona explain my self..
this code is for a database fields validation..
i have two fields involved...
the "producto" and "monto_mens"
first.. i have to check the producto field..
and if is equal to "magna"..
then make some calculations on "monto_mens"
like this..
"<% if (FP_FieldVal(fp_rs,"monto_mens"))*(0.20)<=4347 Then
Response.Write FormatCurrency(5000)
Else
Response.Write FormatCurrency(FP_FieldVal(fp_rs,"monto_mens")*(0.20))
End If
%>"
then in the same block validate de option for a "producto" field value of.. "superior"..
and for this calculate the "monto_mens" like..
"<% if (FP_FieldVal(fp_rs,"monto_mens"))*(0.10)<=3260 Then
Response.Write FormatCurrency(3750)
Else
Response.Write FormatCurrency(FP_FieldVal(fp_rs,"monto_mens")*(0.15))
End If
%>"
and finally...
check if "producto" is equal to "basica"..
then..calculate like..
"<% if (FP_FieldVal(fp_rs,"monto_mens"))*(0.10)<=2125 Then
Response.Write FormatCurrency(2500)
Else
Response.Write FormatCurrency(FP_FieldVal(fp_rs,"monto_mens")*(0.10))
End If
%>"
there are six validations.. in the same block...
this vb script syntax is a kind of strange to me!!!
well .. any suggestions real hard coders???
ok.. any will be well thanked..!!!!
greetings for aaaaaallll..!!!
RT
russell
08-21-2006, 09:58 PM
here ya go, but ya gotta teach us some espanol in return: for instance what does "monto_mens" mean? And como se dice "some really naughty words" en espanol?
Select Case LCase(producto)
Case "magna"
if (FP_FieldVal(fp_rs,"monto_mens"))*(0.20)<=4347 Then
Response.Write FormatCurrency(5000)
Else
Response.Write FormatCurrency(FP_FieldVal(fp_rs,"monto_mens")*(0.20))
End If
Case "superior"
if (FP_FieldVal(fp_rs,"monto_mens"))*(0.10)<=3260 Then
Response.Write FormatCurrency(3750)
Else
Response.Write FormatCurrency(FP_FieldVal(fp_rs,"monto_mens")*(0.15))
End If
Case "basica"
if (FP_FieldVal(fp_rs,"monto_mens"))*(0.10)<=2125 Then
Response.Write FormatCurrency(2500)
Else
Response.Write FormatCurrency(FP_FieldVal(fp_rs,"monto_mens")*(0.10))
End If
End Select
:)
Rterres
08-21-2006, 10:33 PM
OOOOOKKKKKKKKKKKK!!!!!!
Thanks in a XXXL size...!!!!!
the monto_mens is a code name for "Monto mensual"...
that is a monthly amount money for some rent!!!!
Producto is easy... Product... :)
Then.. naughty words.....
is like "palabrejas", "groserias" "palabras picarescas"
hope it helps...!!!
ok.. thanks.. really from heart!!!
Let me test the code to work!!!!!
best regards!!!!!!!!!!!!!!!!!!!!
RT
russell
08-21-2006, 10:37 PM
Thanks Rterres!!! Of course I'll use my new-found language skills in good taste only... :cool:
Rterres
08-21-2006, 10:58 PM
Ok.. just the final details..!
what if i use
Then
Temp = FP_FieldVal(fp_rs, "Nombre_completo_inq")
instead of
Then
Response.Write FormatCurrency(5000)
and at the end pass the value to a field.....
<input type=text name=box value="<%=producto%>" >
???
Thanks Againnnnnnnnnnnnnnnnn!!!!!!!
RT
russell
08-21-2006, 11:05 PM
should work fine as long as producto has a value.
wow, u edited your post while i was still laughing!
anyway, post back with any questions or problems.
Rterres
08-21-2006, 11:16 PM
ok..!!!!
please laugh!! more..) :D !!
I write this like..
<input type=text name=box value="<%Select Case LCase(producto)
Case "magna"
if (FP_FieldVal(fp_rs,"monto_mens"))*(0.20)<=4347 Then
Response.Write FormatCurrency(5000)
Else
Response.Write FormatCurrency(FP_FieldVal(fp_rs,"monto_mens")*(0.20))
End If
Case "superior"
if (FP_FieldVal(fp_rs,"monto_mens"))*(0.10)<=3260 Then
Response.Write FormatCurrency(3750)
Else
Response.Write FormatCurrency(FP_FieldVal(fp_rs,"monto_mens")*(0.15))
End If
Case "basica"
if (FP_FieldVal(fp_rs,"monto_mens"))*(0.10)<=2125 Then
Response.Write FormatCurrency(2500)
Else
Response.Write FormatCurrency(FP_FieldVal(fp_rs,"monto_mens")*(0.10))
End If
End Select %>"onChange="this.value='Locked text!';" size=10 readonly style="border: 1px solid #FFFFFF">
But the field in a query response.. is still blank...!!!
i did not tell that this is a response from a query from a web based database... do you want to chekit....
ok.. visit this... http://previsionlegal.com/caratulabis.asp
then type in the field MG767153
and watch the response for "Importe" this sould write the
number validated....
i think the query sould have some more code at first lines....
i do some more validations but this involve just one field...
is like..
<%Dim Temp
If FP_FieldVal(fp_rs, "reciboa_nombre") = "inquilino" then
Temp = FP_FieldVal(fp_rs, "Nombre_completo_inq")
ElseIf FP_FieldVal(fp_rs, "reciboa_nombre") = "arrendador" then
Temp = FP_FieldVal(fp_rs, "Nombre_prop")
Else
Temp = FP_FieldVal(fp_rs,"Nombre_fiador")
End If%>
Okkkk!!! don`t go to sleeep yet!!!!
greata thanks again!!!
RT
russell
08-21-2006, 11:35 PM
ok, without seeing all of the code it is hard to say exactly, and i did look at your form... but instead of how u did it, try something like this
Dim v
Case "magna"
if (FP_FieldVal(fp_rs,"monto_mens"))*(0.20)<=4347 Then
v = 5000
Else
v = FP_FieldVal(fp_rs,"monto_mens")*(0.20)
End If
Case "superior"
if (FP_FieldVal(fp_rs,"monto_mens"))*(0.10)<=3260 Then
v = 3750
Else
V = FP_FieldVal(fp_rs,"monto_mens")*(0.15)
End If
...
End Select
%>
<input type=text name=box value="<%=FormatCurrency(v)%>
...
would need to see the rest of your code to be certain. not sure what fp_value function does, for example -- though i'm guessing that u r using front page and it is a generated function...? most importantly, what is your recordset returning? again can better tell by looking at the whole code
rb
russell
08-21-2006, 11:42 PM
"Importe con letra" should show amount owed?
Rterres
08-21-2006, 11:43 PM
Yes.. MS Front Page...
helps in cases..!!..
Well let me check it!!!
the entire source code is in the View source code right click menu of the link i put before.. but if you want it i put all the code here!!!!!!!!
thanks again...Rusell (athletics)..
I love that clothesline...!!!!!
Regards :D .
RT
Rterres
08-21-2006, 11:49 PM
Importe con letra is a field that i cant read from the data base....
cause the code must read the field in numbers and display it in letters... but the field is in currency format.. that makes many problems in order to read it...
i have the code but the field has to be only numbers...
without $ , or .
do you know some other method???
Thanks a loooooooot!!!!
wana more naughty words??? :D
Regards
RT
russell
08-21-2006, 11:50 PM
wait, i got it...
<input type=text name=box value=""onChange="this.value='Locked text!';
for some reason, none of your conditions are returning true. may need a Case Else to apply a default value. more likely, need to see what is returned from your database and why it is empty where you expect a value.
view source isn't what i was talking about (though it helps a bit) -- it's the server side code that is causing your problem...
anyway, u ned to see why "temp" or whtever your variable is called is empty
Rterres
08-21-2006, 11:59 PM
ok..!!!!!!!
as far as i know ..
front page put some codes in the serverside.
and that's why i did not put nothing there...
just the client side... from the coder view....
ok.. im checking the last code you put...
i will write the results...
thakkkkkksssssssss!!!!!
agaiiinnnn!!!!
RT
Rterres
08-29-2006, 03:21 PM
ok..men.. im gonna put this easier..
instead of making an conditional query
i solve this with a validation on the sending form...
but the field has to be authomathic..
if the user write 8900.. other field have to calculate the conditionals...
like
if (FP_FieldVal(fp_rs,"monto_mens"))*(0.10)<=3260 Then
v = 3750
Else
V = FP_FieldVal(fp_rs,"monto_mens")*(0.15)
End If
but this syntax is for a results page..
then the case is to make a function to validate this.. and some
other inconvenient is that the field that is captured is in currency format..
with like $8,900.00
are there any hard coder to give me some adviceee???????
thanks for aaaalllll!!!!!
RT