I just want to know how can I display a javascript variable into html?
Below is my php code:
var duration = <? echo $postduration; ?>;
(The variable above uses php to retrieve a php variable)
Thank you
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Make your code more concise with jQuery:
(1) Add this in your
<head>:(2) Create an element where you want the variable to be displayed, and give it an ID, e.g.:
(3) Add this in your JavaScript:
For your PHP, try the following two options:
or…