1

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.

0

1 Answer 1

2

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  );
Sign up to request clarification or add additional context in comments.

1 Comment

String.format is not a function

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.