Hướng dẫn javascript print variable
What is the best way to echo the variable get_parestotal? Show Nội dung chính
Nội dung chính
Some help please! Thank you
CMS 6943 gold badges9 silver badges31 bronze badges asked Sep 22, 2014 at 12:41 7 You can log variables and so on in the console. e.g.:
You can even concatenate witht he use of + console.log('This is your variable'+get_parestotal) You can even add styling to your log (color, background-color,...):
There are some alternatives to console.log() you could use:
answered Sep 22, 2014 at 12:54 MHXMHX 1,5332 gold badges22 silver badges30 bronze badges 2 You can either do alert(myvar) or console.log(myvar). Caveat: console.log is only supported in certain browsers...see the link. answered Sep 22, 2014 at 13:00 CodexCodex 273 bronze badges if you want a console output than use answered Sep 22, 2014 at 13:06 CMSCMS 6943 gold badges9 silver badges31 bronze badges JavaScript Display PossibilitiesJavaScript can "display" data in different ways:
Using innerHTMLTo access an HTML element, JavaScript can use the The Example
My First Web PageMy First Paragraph
Try it Yourself » Changing the innerHTML property of an HTML element is a common way to display data in HTML. Using document.write()For testing purposes, it is
convenient to use Example
My First Web PageMy first paragraph.
Try it Yourself » Using document.write() after an HTML document is loaded, will delete all existing HTML: Example
My First Web PageMy first paragraph.
Try it Yourself » The document.write() method should only be used for testing. Using window.alert()You can use an alert box to display data: Example
My First Web PageMy first paragraph.
Try it Yourself » You can skip the In JavaScript, the window object is the global scope object, that means that variables, properties, and methods by default belong to the window object. This also means that specifying the Example
My First Web PageMy first paragraph.
Try it Yourself » Using console.log()For debugging purposes, you can call the You will learn more about debugging in a later chapter. Example
Try it Yourself » JavaScript PrintJavaScript does not have any print object or print methods. You cannot access output devices from JavaScript. The only exception is that you can call the Example
Try it Yourself » How do you echo in JavaScript?Although JavaScript doesn't have an echo statement, you can use the document. write() and the Element. appendChild() methods to achieve the same result. How do I display a variable in JavaScript?There are three ways to display JavaScript variable values in HTML pages:. Display the variable using document. write() method.. Display the variable to an HTML element content using innerHTML property.. Display the variable using the window. alert() method.. How do you pass data from JS to HTML?JavaScript can "display" data in different ways:. Writing into an HTML element, using innerHTML .. Writing into the HTML output using document.write() .. Writing into an alert box, using window.alert() .. Writing into the browser console, using console.log() .. How do I pass variables and data from JavaScript to PHP?The way to pass a JavaScript variable to PHP is through a request. This type of URL is only visible if we use the GET action, the POST action hides the information in the URL. Server Side(PHP): On the server side PHP page, we request for the data submitted by the form and display the result. $result = $_GET [ 'data' ]; |