www.webdeveloper.com
Results 1 to 3 of 3

Thread: String concatenation - calling a function from a string using variables as parameters

Hybrid View

  1. #1
    Join Date
    Mar 2013
    Posts
    3

    String concatenation - calling a function from a string using variables as parameters

    Hi.

    Id like to know...

    How could I call a function with variables as arguments from a string?

    Im trying this way:

    blogHTML = "<h2><a href='javascript:void(0)' onclick='Blog.getPost("+this.id,Blog._currentBlog+");'>"+this.header+"</a></h2>";

    Not working...

    Thanks.

  2. #2
    Join Date
    Jul 2008
    Location
    urbana, il
    Posts
    2,787
    use \" to quote parameter values within attribs, because unless this.id and Blog._currentBlog are numbers, they need to be quoted strings.

    you can also use a template function to make it easier to code, but the nested quotes will be the same on both final outputs.
    Last edited by rnd me; 03-02-2013 at 07:31 PM.

  3. #3
    Join Date
    Mar 2013
    Posts
    3
    Quote Originally Posted by rnd me View Post
    use \" to quote parameter values within attribs, because unless this.id and Blog._currentBlog are numbers, they need to be quoted strings.

    you can also use a template function to make it easier to code, but the nested quotes will be the same on both final outputs.
    Hi.

    How could I quote the gray code?

    <a href='javascript:void(0)' onclick='Blog.getPost("+this.id+","+ Blog._currentBlog+");return false;' style='text-decoration:none;' title='Post-header-"+this.id+"'>"+this.header+"</a>

    Thanks.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles