Kate
Kate

Reputation: 1

On HTML script load how to assign a value

I have an HTML page that when a page is loaded it calls an API method as follows:

var script = string.Format("API.methods.createUser({0},function (new) {{$('#RegistrationForm').hide();$('#number').html(new.Number)}});",
                            Webservice.GetJavascriptObject(list, new Dictionary<string, object>() { { "first name ", name }));

On the $('#number') it gets me the users account number when the script runs.

I want to assign this account number to the list object so I tried

List.Number ="$('#number').html(new.Number);"

But literally just assigns what I have in the on the right of the equal sign and not the actual account number.

How can I achieve this?

Upvotes: 0

Views: 54

Answers (1)

charliefortune
charliefortune

Reputation: 3200

Take the quote marks off that are wrapping the assignment value

Change it to this

List.Number =$('#number').html();

By wrapping it in quote marks, you were assigning it as a string.

Upvotes: 2

Related Questions