Question on Value? - Posted (975 Views)
Advanced Member
JJenson
Posts: 2121
2121
Ok so I have a form that is pulling in through a quearystring a value for a field. This is what I have for it:

This is the code to get the referer

Code:

<%

Dim Referer : Referer = Request.ServerVariables("HTTP_REFERER")
Dim Location

Select Case(InStr(Referer, "http://www.jiffylube") > 0)
Case True: Location = Mid(Referer, 21, InStr(21, Referer, ".") - 21)
Case Else:
End Select

%>


<input type="text" value="<%=Location%>" size="20" name="Location" readonly />

What I need to modify this is basically say if location=nothing then show na

I just can't get it right.<
 Sort direction, for dates DESC means newest first  
 Page size 
Posted
Advanced Member
JJenson
Posts: 2121
2121
Any Ideas? <
Posted
Average Member
phy1729
Posts: 589
589
Did you try If location = "" then location="na" end if? Also if there's no reason to use a select case consider using an if then. I cringed.<
Posted
Forum Moderator
AnonJr
Posts: 5768
5768
Originally posted by phy1729
Also if there's no reason to use a select case consider using an if then. I cringed.
Sure there is - if you know that there's going to be a need to add more later on, a Select Case tends to be a little more readable than an endless ElseIf chain. (Your preferences may vary.)

Even if there isn't, I find what he's doing to be much more readable - and therefore maintainable - than some of the convoluted If .. Then bits I've seen floating around. More and more I'm coming to the conclusion that there's a fool's economy in sacrificing maintainability in the name of machine performance. Hardware is cheap, programmer time isn't.<
Posted
Junior Member
gary b
Posts: 267
267
Originally posted by JJenson Dim Referer : Referer = Request.ServerVariables("HTTP_REFERER")
Dim Location

Select Case(InStr(Referer, "http://www.jiffylube") > 0)
Case True: Location = Mid(Referer, 21, InStr(21, Referer, ".") - 21)
Case Else:
End Select

What I need to modify this is basically say if location=nothing then show na

JJ... My usual disclaimer: I only sometimes have a clue about what you want to know!
Why not intercept the process? Once you populate Referer, test it. IF Referer="" THEN
Location = NA
ELSE
'Do nothing
ENDIF

Obviously, remainder of code would have to match this approach. My point is that you are focusing on Location when, I believe, your focus should be on Referer.
Any merit in this idea?
gary b
<
Posted
Advanced Member
JJenson
Posts: 2121
2121
Well in the end they told me its ok to leave it as they though someone could delete the number if it was populated. But I told them it is not possible as it is a read only field they think they are getting this error through another form. So I guess in the end I didn't need it lol.
But I can see where you are going with it Gary I believe it would work but no longer need it thanks though.<
 
You Must enter a message