Passing an alphanumeric string value to a javascript function in js file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • shalabh6
    New Member
    • Aug 2009
    • 2

    Passing an alphanumeric string value to a javascript function in js file

    Hi,

    A js file containing a function which is passing an alphanumeric string to another function in the same file, the second funtion requires 4 parameters to pass from the first function.
    The first three are the number and the last one is the alphanumeric string , but when I apply the fourth parameter , it throws out an error Expected';'

    The value in the varval parameter are like '2 xyz', '4 abc'

    The calling fucntion is being called link this
    Code:
    func1 {
    .......
    document.getElementById('inlineEdit_'+recid).innerHTML += '<a onClick="[B]cancelEdit[/B]('+recid+','+ count_sqlChangeSet+','+currpage+',[B]'+varval+'[/B])" class="revertEditing" title="Cancel" id="revert"><img src="http://bytes.com/images/cancel.gif" border="0" /></a>'
    ...... }
    Under is the called function

    Code:
    function cancelEdit(recid,count_sqlChangeSet,currpage,changeSetNo)
    { //changeSetNo = '2 xyz';
    		alert(changeSetNo);
    
    	document.getElementById('inlineEdit_'+recid).innerHTML = '<a onclick="inlineedit('+recid+','+ count_sqlChangeSet+','+currpage+')" >Inline Edit</a>'
    	document.getElementById('changeSetNo_'+recid).innerText = changeSetNo;
    }
    Please help..

    Shalabh
    Last edited by gits; Aug 28 '09, 02:03 PM. Reason: added code tags
  • gits
    Recognized Expert Moderator Expert
    • May 2007
    • 5390

    #2
    you need to concat the corresponding qoutes to the link where you build the call ... since the params needs to be passed as strings ...

    kind regards

    Comment

    Working...