Jump to content

Using variables instead of hard coding text...


enpiccoli

Recommended Posts

Would someone please help. I kept my code very simple as I am new at HTML. The below code works and all I want to do is replace the hard coded value "Heading" in "<h1>Heading</h1" by using the value in the text variable "var HeadingText" which is "Auto Manufacturing Company". Also, do the same, replace the hard coded value "Description" in "<p>Description"</p>" by using the value in the text variable "var CollapsibleText" which is "Ford". In other words, instead of using hard coded values, use text associated with a variable as follows "<h1>use value associated with var HeadingText </h1>" giving "<h1>Auto Manufacturing Company</h1>. Thank you.

Edward

enpiccoli@msn.com

myapp.Main.CurrentEvents_selectedItem_postRender = function (element, contentItem) {var HeadingText = "Auto Manufacturing Company"var CollapsibleText = "Ford"var helpText = $("<div data-role='collapsible' data-theme='a' data-content-theme='a'>" + "<h1>Heading</h1>" +"<p>Description</p>" +" </div>");helpText.prependTo($(element));};

Link to comment
Share on other sites

Is this supposed to make sense? Maybe...

myapp.Main.CurrentEvents_selectedItem_postRender = function (element, HeadingText, CollapsibleText ) {var helpText = "<div data-role='collapsible' data-theme='a' data-content-theme='a'><h1>"+HeadingText+"</h1><p>"+CollapsibleText+"</p></div>";element.innerHTML = helpText;};
Link to comment
Share on other sites

Would someone please help. I kept my code very simple as I am new at HTML. The below code works and all I want to do is replace the hard coded value "Heading" in "<h1>Heading</h1" by using the value in the text variable "var HeadingText" which is "Auto Manufacturing Company". Also, do the same, replace the hard coded value "Description" in "<p>Description"</p>" by using the value in the text variable "var CollapsibleText" which is "Ford". In other words, instead of using hard coded values, use text associated with a variable as follows "<h1>use value associated with var HeadingText </h1>" giving "<h1>Auto Manufacturing Company</h1>. Thank you.

Edward

enpiccoli@msn.com

myapp.Main.CurrentEvents_selectedItem_postRender = function (element, contentItem) {var HeadingText = "Auto Manufacturing Company"var CollapsibleText = "Ford"var helpText = $("<div data-role='collapsible' data-theme='a' data-content-theme='a'>" + "<h1>Heading</h1>" +"<p>Description</p>" +" </div>");helpText.prependTo($(element));};

What language are you used to coding in? It sure is not HTML

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...