if else response.write

liunx

Guest
Can someone help me with this please?

I'm trying to response.write to a series of textboxes based on the selection in a dropdown. If 1 is selected in my dropdown, then I want to write to textbox1, if 2 is selected then write to textbox2, etc. However, if I'm writing to textbox2, and textbox1 is already filled, I want to leave the contents of textbox1 alone. I'm using the following code in textbox1.

<%if Request.Form("D1")="1" Then Response.write(cstr(Session.Contents("dateofservice")))End if%>

How can I keep from losing the contents of textbox1 when ("D1")<>"1"?

Thanks,

SupOriginally posted by supmktg
Can someone help me with this please?

I'm trying to response.write to a series of textboxes based on the selection in a dropdown. If 1 is selected in my dropdown, then I want to write to textbox1, if 2 is selected then write to textbox2, etc. However, if I'm writing to textbox2, and textbox1 is already filled, I want to leave the contents of textbox1 alone. I'm using the following code in textbox1.

<%if Request.Form("D1")="1" Then Response.write(cstr(Session.Contents("dateofservice")))End if%>

How can I keep from losing the contents of textbox1 when ("D1")<>"1"?

Thanks,

Sup

Wrong forum(should be in Server Side Programming).Excuse my "shot in the dark" at helping you...I'm a php coder by default..and haven't started learning asp yet...but I do have an idea..why couldn't you do:


<%
dim Output = ''
if Request.Form("D1")="1" Then
Output = Output & cstr(Session.Contents("dateofservice"))
End if
if Request.Form("D1")="2" Then
Output = Output & cstr(Session.Contents("other variable"))
End if
Response.Write(Output)

%>

Tho..I'm guessing you'd have to change the if statements a bit...as of now only 1 will activate at a time.

As I said...I'm not an ASP coder...but you should be able to get the jist of what I mean(eg: add each output to a variable then echo it seperately)...that way you save the values...and output them all.

Hope this helps...it's a shot in the dark tho...I'm not an ASP coder.I wish I could help you but my time is limited. Just kidding. Drop me a PM, I'll fix it for u.

Been there, done it many times before.

<!-- w --><a class="postlink" href="http://www.ex-designz.net">www.ex-designz.net</a><!-- w -->

Dexterpuffin was sorta right but I guess it all depends on your logic.

If you just want any case where D1 wasn't equal to 1 then this is what I'd do....


<%
dim Output = ''
if Request.Form("D1")="1" Then
Output = Output & cstr(Session.Contents("dateofservice"))
else
Output = Output & cstr(Session.Contents("other variable"))
End if
Response.Write(Output)

%>


if it's more complex (like do something when it's equal to 1, something when it's equal to 2 and something else for when it's not either of those) then a Select case would be ideal...



<%
dim Output = ''
select case Request.Form("D1")
case "1"
Output = Output & cstr(Session.Contents("dateofservice"))
case "2"
Output = Output & cstr(Session.Contents("other variable"))
case else
Output = Output & " - Unexpected value
End select
Response.Write(Output)

%>
 
Back
Top