views:

166

answers:

1

Hi All, I have the following javascript code and I am not getting the result I want. I am trying to format a string using String.format(format, args) like c# works. I have

 var claimNum = $("#ctl00_DefaultContent_txtClaimNumber").val();
            var claimant = $("#ctl00_DefaultContent_lblClaimClaimant").text();
            var params = [claimNum, claimant];
            var format = "Claim #:{0}, Claimaint:{1}";

            var data = String.format(format, params);

but it is output to the browser like this

Claim #:c08000131,THOMAS ALBERTSON, Claimaint:

The intended output is of course Claim #:c08000131, Claimaint: THOMAS ALBERTSON

What am I doing wrong? Any help is appreciated.

+1  A: 

Try this:

 var claimNum = $("#ctl00_DefaultContent_txtClaimNumber").val();
        var claimant = $("#ctl00_DefaultContent_lblClaimClaimant").text();
        var format = "Claim #:{0}, Claimaint:{1}";
        var data = String.format(format, claimNum, claimant  );
Paul Creasey
Thanks Paul. That was fine.
Hcabnettek