The Four Word Film Review Fourum
Home | Profile | Register | Active Topics | Members | Search | FAQ
Return to my fwfr
Frequently Asked Questions Click for advanced search
 All Forums
 Off-Topic
 General
 Show and Tell

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkInsert Email Insert CodeInsert QuoteInsert List
   
Message:

Smilies
Angry [:(!] Approve [^] Big Smile [:D] Black Eye [B)]
Blush [:I] Clown [:o)] Cool [8D] Dead [xx(]
Disapprove [V] Duh [7] Eight Ball [8] Evil [}:)]
Gulp [12] Hog [13] Kisses [:X] LOL [15]
Moon [1] Nerd [18] Question [?] Sad [:(]
Shock [:O] Shy [8)] Skull [20] Sleepy [|)]
Smile [:)] Tongue [:P] Wink [;)] Yawn [29]

   -  HTML is OFF | Forum Code is ON
 
   

T O P I C    R E V I E W
duh Posted - 02/18/2007 : 06:53:28
OK, so I've been working on this web coding project (sort of a classifieds for a client) for the past couple of weeks, nearly 24/7. In the process I've had to learn how to do some things with ASP that I didn't know how to do before.

For example, I decided that on the ad submission forms, the price field needed to be sanitized to make sure the correct numerical value went into the database.

I'm not good with numbers at all but ASP requires logic, which is a bit easier for me.

Anyhow, after I got it all figgered out I wrote up another tutorial on it. You can see it HERE. I'm not clever like the younger, cuter and smarter Benj, which makes it all the more satisfying to get something like this to work.

In fact, if I'm lucky, Benj will suggest a more efficient way to do the same thing. (hint hint)
4   L A T E S T    R E P L I E S    (Newest First)
duh Posted - 02/18/2007 : 16:50:47
quote:
Originally posted by benj clews

I simplified the d.p. cropping code a bit- if you're not bothered about rounding up or down, you could even remove the ELSE condition entirely and leave the formatNumber function to do the majority of the work for you.

Also, I wasn't sure what you wanted to be output in the instance of the input not being a number, so I've defaulted the code to make it 0.00

I also added in a check to see if the input value was "". Quite often an isNumeric check on such a value will say it is a number (0), so I've written the code to deal with this too.

<%
dim strOurValue

strOurValue = request.form("PRICE")

'Let's sanitize our Price field

'OK let's first make sure the price string is numeric
if NOT isNumeric(strOurValue) or (trim(strOurValue) = "") then
response.write "Not a number." ' you could put in code to remove nonnumeric characters
strOurValue = 0

else
strOurValue = strOurValue * 100 'Shift the d.p two places to the right
strOurValue = int(strOurValue) 'Remove anything after the d.p. now
strOurValue = (strOurValue / 100) 'Shift the d.p. back two places to the left

end if

strOurValue = FormatNumber(strOurValue, 2)

response.write "<br>The sanitized Price is: $" &strOurValue ' and write it out
%>



Fantastic! Thank you, Mr. Benj!!!!!!!!
Edit: The thought just occurred to me -- of course a guy who invented four word film reviewing is going to write lean code!
Whippersnapper. Posted - 02/18/2007 : 13:53:00

Couldn't have put it better myself.

()
benj clews Posted - 02/18/2007 : 13:36:09
I simplified the d.p. cropping code a bit- if you're not bothered about rounding up or down, you could even remove the ELSE condition entirely and leave the formatNumber function to do the majority of the work for you.

Also, I wasn't sure what you wanted to be output in the instance of the input not being a number, so I've defaulted the code to make it 0.00

I also added in a check to see if the input value was "". Quite often an isNumeric check on such a value will say it is a number (0), so I've written the code to deal with this too.

<%
dim strOurValue

strOurValue = request.form("PRICE")

'Let's sanitize our Price field

'OK let's first make sure the price string is numeric
if NOT isNumeric(strOurValue) or (trim(strOurValue) = "") then
response.write "Not a number." ' you could put in code to remove nonnumeric characters
strOurValue = 0

else
strOurValue = strOurValue * 100 'Shift the d.p two places to the right
strOurValue = int(strOurValue) 'Remove anything after the d.p. now
strOurValue = (strOurValue / 100) 'Shift the d.p. back two places to the left

end if

strOurValue = FormatNumber(strOurValue, 2)

response.write "<br>The sanitized Price is: $" &strOurValue ' and write it out
%>
ChocolateLady Posted - 02/18/2007 : 07:05:46
Sanitize prices? What is this? A new type of money laundering?

The Four Word Film Review Fourum © 1999-2024 benj clews Go To Top Of Page
Snitz Forums 2000