Reputation: 1297
I am facing an issue , my inline javascript code is not added in page(Created By wordpress).
code
function check()
{
alert("in check");
var mname=document.getElementByID("name").value;
var memail=document.getElementByID("email").value;
var mresponse=document.getElementByID("response").value
alert("name"+mname +"length" +mname.length+"email"+memail+"length"+memail.length+"response"+mresponse+"length"+mresponse.length);
}
</script>
<table style="border: 0px;">
<tbody>
<tr>
<td style="border: 0px;">Name <span style="color: red;">*</span></td>
<td style="border: 0px;"><input id="name" type="text" name="name" /></td>
</tr>
<tr>
<td style="border: 0px;">Email-Id <span style="color: red;">*</span></td>
<td style="border: 0px;"><input id="emailid" type="text" name="emailid" /></td>
</tr>
<tr>
<td style="border: 0px;">Your Response <span style="color: red;">*</span></td>
<td style="border: 0px;"><textarea id="response" cols="40" maxlength="50" name="response" rows="4"></textarea></td>
</tr>
</tbody>
</table>
<input onclick="check();" type="button" value="click" />
Do i need to install any plugin for allowing java script.
P.S i am not using wordpress.com ..i am developing locally
**********Updated*****************
i just try alert box
var mname=document.getElementById("name");
alert("in check"+mname);
and checked in firebug got following error
SyntaxError: syntax error
alert("in check"+mname);</p>
error pointing towards that 'p'. But i did not write that code. i don`t know why this is appended in generated code?
Upvotes: 2
Views: 8959
Reputation: 1297
i tried inline javascript plugin and it works for me. You have to just add follwing tags between your js code
[inline]
your js code
[/inline]
Upvotes: 1
Reputation: 4395
Use this
getElementById instead of getElementByID
use ';' after
var mresponse=document.getElementById("response").value; //forgot ';'
and use
var memail=document.getElementById("emailid").value; //use correct id
In my system is working now.
Upvotes: 1
Reputation: 2030
Check this video tutorial:
https://www.youtube.com/watch?v=zjNVryaNz0E
Updated
Add JS like this on your any WP Page or Post It works:
<script type="text/javascript">
var a = 5;
alert("hello world. The value of a is: " + a);
</script>
FYI :it does not required any plugin for add js into WordPress page /post
I hope this helps you!!
Upvotes: 0