Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Jul 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Passing Javascript Replace function as an argument of user defined function

    Hi,

    I am facing a problem in passing replace() function as an argument in user defined java function, can any one help me how to resolve it?

    intention is to pass a file path to my user defined function, but before passing the path i want to replace the character '\' to '\\'

    I am posting my javascript function here:

    <a href="#" onclick="OpenDocPreview('<%# Eval("PATH")%>'.replace(/\\/g,"\\\\"), '<%# Eval("Filename")%>')"><%# Eval("DocTitle") %></a>


    function OpenDocPreview(url, docname) {
    alert('message from search base : ' + url + ' ' + docname);
    }

    thank you,

  • #2
    Regular Coder
    Join Date
    May 2010
    Location
    Bathurst, Australia
    Posts
    180
    Thanks
    1
    Thanked 22 Times in 22 Posts
    You need to look at attaching event handlers rather than relying on "onclick".
    Disclaimer: I'm hungover 70% of the time i'm on here, any information given may not be correct, or even legible.

  • #3
    New to the CF scene
    Join Date
    Jul 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thank you for your suggestion, but i am getting a syntax error. i think the argument i am passing have some error.

  • #4
    Regular Coder
    Join Date
    May 2010
    Location
    Bathurst, Australia
    Posts
    180
    Thanks
    1
    Thanked 22 Times in 22 Posts
    I meant you have to use those to solve this problem. replace(/\\/g,"\\\\") isn't going to do anything. The first parameter expects a string or regex pattern as a variable. You've given it /\\/g, which is, as far as the function is concerned, gibberish.

    Edit, also, it probably needs to look more like /\\\\/g anyway. I'm not sure, I hate regular expressions, but your backslashes probably need to be escaped.
    Last edited by BulletTimeBill; 07-12-2011 at 09:50 AM.
    Disclaimer: I'm hungover 70% of the time i'm on here, any information given may not be correct, or even legible.

  • #5
    New to the CF scene
    Join Date
    Jul 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    yes i got your point. Can you provide some sample code to solve this issue by using event handler, as you mentioned.

    thank you,


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •