how to get php variable value in javascript?

File name : index.php

<?php $num = 10; ?>
<script>
function myFunction()
{
var jsval = "<?php echo $num; ?>";
if(jsval < 1)
{
alert("Your number is lessthan 1.");
}
else
{
window.location="http://itechtuto.com/";
}

}
</script>

How to disable and enable button in javascript.

Submit button is disable first . when you click on any text or div then enable submit button.

File name : index.php

<script>
function myFunction()
{
document.getElementById("sub").disabled = false;
}

function myalert()
{
alert("You click on the submit button.");
}


</script>


<button id="sub" type="submit" onclick="myalert()" disabled>Submit</button>

<p id="pid" onclick="myFunction()">Click on me then enable the submit button.</p>


how to get html tagname value in javascript ?

when you click on the paragraph text tenn it gets text of html tags.

File name : index.php

<html>

<head>

<script type="text/javascript">

function myfunction(li) {
var TextInsideLi = li.getElementsByTagName('p')[0].innerHTML;
alert(TextInsideLi);
}
</script>

</head>
<body>
<ul>
<ul>
<li onclick="myfunction(this)">
<span></span>
<p>This Text</p>
</li>



</ul>
</body>

</html>









Previous Next


Trending Tutorials




Review & Rating

0.0 / 5

0 Review

5
(0)

4
(0)

3
(0)

2
(0)

1
(0)

Write Review Here