writing " in asp instead of ""

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • fran7
    New Member
    • Jul 2006
    • 229

    writing " in asp instead of ""

    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.

    Code:
    if CurrentRatio > TargetRatio then ' We'll scale height
    strResize = "width=""" & intDesiredWidth & """"
    else
    strResize = "height=""" & intDesiredHeight & """" ' We'll scale width
    end if
    else
    strResize = ""
    end if
    
    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.

    Code:
    strResize = "height= " """ & intDesiredHeight & """"" ' We'll scale width
    end if
    else
    strResize = ""
    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
  • DrBunchman
    Recognized Expert Contributor
    • Jan 2008
    • 979

    #2
    Hi Richard,

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

    Code:
     
    if CurrentRatio > TargetRatio then ' We'll scale height
    strResize = "width=&qt" & intDesiredWidth & "&qt"
    else 
    strResize = "height=&qt" & intDesiredHeight & "&qt" ' We'll scale width
    end if
    else
    strResize = ""
    end if
     
    ImageResize = strResize
    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

    Comment

    • fran7
      New Member
      • Jul 2006
      • 229

      #3
      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

      Comment

      • fran7
        New Member
        • Jul 2006
        • 229

        #4
        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

        Comment

        • markrawlingson
          Recognized Expert Contributor
          • Aug 2007
          • 346

          #5
          Just some general input:

          I have a function I use for this.

          [code=asp]
          Function Quote( sTemp )
          Quote = Chr( 34 ) & sTemp & Chr( 34 )
          End Function
          'And called like so...

          sSomeString = "<input type=" & Quote( "text" ) & ">"
          [/code]

          Makes it nice and simple :)


          Originally posted by fran7
          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

          Comment

          Working...