SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member GameOne's Avatar
    Join Date
    Mar 2006
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Hyphens in a string create error

    Hi,
    I am trying to pass a string as a parameter to a function which contains hyphens, numbers and alphabet characters.... Here is the code:
    Code:
    function appendRequestId(requestId){
     		return "<a href=# onclick='getMe("+requestId+");' >"+requestId+"</a>";
     	}
     
     function getMe(requestId){
     		croteManager.filterByRequestId(requestId, populateFilterResults);
     	}
    If, requestId is supposed to be 241f93a2-56eb-4a74-90d7-4fd199530001 , the script gives an error saying ')' expected (for the appendRequestId method). and if I try to put some dummy values (for the appendRequestId method) with all characters and no numbers in the requestId it works.... I have tried requestId.toString() but it did not work... any pointers as what can be done to solve this?

  2. #2
    CSS & JS/DOM Adept bronze trophy
    Join Date
    Mar 2005
    Location
    USA
    Posts
    5,482
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You need to put quotes around the value.

    Code:
    function appendRequestId(requestId){
    		return "<a href=# onclick='getMe(\""+requestId+"\");' >"+requestId+"</a>";
    	}
    We miss you, Dan Schulz.
    Learn CSS. | X/HTML Validator | CSS validator
    Dynamic Site Solutions
    Code for Firefox, Chrome, Safari, & Opera, then add fixes for IE, not vice versa.


Bookmarks

Posting Permissions

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