By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,846 Members | 1,631 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,846 IT Pros & Developers. It's quick & easy.

writing " in asp instead of ""

100+
P: 229
Hi, from help in the javascript forum I found the error in some code but need help. This bit of code works perfectly, trouble is I am writing it to a javascript function so the height needs to be in "" instead of "" otherwise I get an error message.

Can anyone suggest how to write it so that it writes " instead of "".
I have tried all combinations of adding " to the code but as soon as I think I am there I get throw out again.

Expand|Select|Wrap|Line Numbers
  1. if CurrentRatio > TargetRatio then ' We'll scale height
  2. strResize = "width=""" & intDesiredWidth & """"
  3. else
  4. strResize = "height=""" & intDesiredHeight & """" ' We'll scale width
  5. end if
  6. else
  7. strResize = ""
  8. end if
  9.  
  10. ImageResize = strResize


I got to this point and it wrote the "to the page but kept the inner "", when I took them out I got asp errors again.

Expand|Select|Wrap|Line Numbers
  1. strResize = "height= " """ & intDesiredHeight & """"" ' We'll scale width
  2. end if
  3. else
  4. strResize = ""
  5. end if
Is there a function that could tell it to write the " differently.
Any help would be great before I pull my hair out!
Thanks
Richard
Mar 3 '08 #1
Share this Question
Share on Google+
4 Replies


DrBunchman
Expert 100+
P: 979
Hi Richard,

You could use a different set of chars to represent the quote marks. Try something like the following which uses &qt instead:

Expand|Select|Wrap|Line Numbers
  1.  
  2. if CurrentRatio > TargetRatio then ' We'll scale height
  3. strResize = "width=&qt" & intDesiredWidth & "&qt"
  4. else 
  5. strResize = "height=&qt" & intDesiredHeight & "&qt" ' We'll scale width
  6. end if
  7. else
  8. strResize = ""
  9. end if
  10.  
  11. ImageResize = strResize
  12.  
Then when you've passed this variable to your javascript code you can replace all the &qt's with double quote's.

Let me know if this helps,

Dr B
Mar 3 '08 #2

100+
P: 229
Dear Dr B, Thanks, The way you wrote out the quotes made it work perfectly, I didnt even have to change the method just the position. Thanks for that.

The only trouble is that solving that one has revealed another problem. As I am calling the script twice it resizes one image and not the other. One reduces to 1pixel in width and height. Although I look at the scource code and it writes the width correctly it does not display correctly which seems strange! I have tried repeating the image resize function with different names but to no avail. Would you have any ideas, if it can be called twice etc?
Thanks again
Richard
Mar 3 '08 #3

100+
P: 229
Dear Db, A bit of perseverance and I got there. I missed that the second instance wasnt in a javascript function so needed the "" instead of    so I just wrote the function again with a unique name as it was originally and it solved the problem.
Thanks for your help
Richard
Mar 3 '08 #4

markrawlingson
Expert 100+
P: 346
Just some general input:

I have a function I use for this.

Expand|Select|Wrap|Line Numbers
  1. Function Quote( sTemp )
  2.    Quote = Chr( 34 ) & sTemp & Chr( 34 )
  3. End Function
  4. 'And called like so...
  5.  
  6. sSomeString = "<input type=" & Quote( "text" ) & ">"
  7.  
Makes it nice and simple :)


Dear Db, A bit of perseverance and I got there. I missed that the second instance wasnt in a javascript function so needed the "" instead of &nbsp;&nbsp; so I just wrote the function again with a unique name as it was originally and it solved the problem.
Thanks for your help
Richard
Mar 4 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.