jQuery in Action, 2nd edition*
The moose likes HTML, CSS and JavaScript and the fly likes not able to call javascript function on onlcick Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "not able to call javascript function on onlcick" Watch "not able to call javascript function on onlcick" New topic
Author

not able to call javascript function on onlcick

kavita vala
Ranch Hand

Joined: Jul 22, 2010
Posts: 42
I was make a jsp page in which i am try to call javascript function
on the event of on click button. but not able to do. so please help me
to find error

<html>
<head>
<meta http-equiv="Content-Script-Type" content="text/javascript">
<script>

var checked = false;
function checkAll(){
alert('check')
if (checked == false){
checked = true
}else{
checked = false
}
for (var i = 0; i < document.form.elements.length; i++) {
if(document.form.elements[i].type == "checkbox"){
document.form.elements[i].checked = checked;
}
}
}
function viewprofile1(){
alert('hi')
// document.forms[0].action='viewprofile.jsp';
// document.forms[0].submit;
}
</script>
</head>
<body>
<form name="form" method="post" >
<table >

<tr>
<tr>
<td class="style" >
<table border="0" >
<tr>
<td>
Search Section
</td>
</tr>
</table>
</td>

<td >

<table>
<tr>
<td class="blueheader">Service Provider</td>
<td><input type="button" onclick="viewprofile1()"></td>
<td >Select All</td>
</tr>
</table>
<%ArrayList arraylist = (ArrayList) session.getAttribute("SPlisting");
Servicelistings servicelistings,serlis;
System.out.println("ARRAYlist--1"+arraylist);
int x=0,y=3;
ArrayList arr = new ArrayList();
for(int z=0;z<arraylist.size();z++){
serlis = (Servicelistings)arraylist.get(z);
if(serlis.getServicetype().equalsIgnoreCase("buyer")){
arr.add(serlis);
}
}
Integer length = arr.size();
System.out.println("LENGTH---"+length);
int totalpage = (length/3)+1;
System.out.println("New arraylist---"+arr);
if(request.getParameter("j")==null && request.getParameter("k")==null){
System.out.println("Inside if for j is null");
x=0; y = 3;
}
else{
System.out.println("Inside else for j not null");
x=Integer.parseInt(request.getParameter("j"));
y=Integer.parseInt(request.getParameter("k"));

}

System.out.println("How much page--"+totalpage+"--Y--"+y+"--X--"+x);

for (int i = x; i < arr.size(); i++) {
servicelistings = (Servicelistings) arr.get(i);

%>

<table>
<tr>
<td ><input type="checkbox" id="id_check" value="<%=servicelistings.getListingid()%>" ></td>
<td >-----------------------------------------------------------------------------------------------------------------------</td>
</tr>
</table>
<table border="0">

<tr>
<tr>
<td><table border="0">
<td class="greensmallheader">Posted On:
<span class="smallblackfont"><%=servicelistings.getPostingdate()%></span></td>
</table></tr>
</tr>
<td >
</td>


<td ><table border="0">
<tr><td>
<table border="0">
<td class="greensmallheader" >Listing Title : </td>
<td class="smallblackfont"><%=servicelistings.getListingtitle()%></td>
</table>
</td>
</tr>
<!-- Display Detail view -->
<tr>
<td>
<table>
<tr>
<td class="greensmallheader" >Listing Title : </td>
<td class="smallblackfont"><%=servicelistings.getListingtitle()%></td>
</tr>
<tr>
<td class="greensmallheader" >Listing Purpose : </td>
<td class="smallblackfont"><%=servicelistings.getListingpurpose()%></td>
</tr>
</table>
</td>
</tr>
</table></td>
<td>
<table >

<!-- Give rating button-->
<tr><td >
<object classid="clsid27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="100" height="20">
<param name="BGCOLOR" value="#faebd7">
<param name="movie" value="button8.swf">
<param name="quality" value="high">
<embed src="button8.swf" width="100" height="20" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" bgcolor="#faebd7" ></embed>
</object></td></tr>
</table>
</td>
</tr>
<%}%>
<table><tr><td class="orangeheader">
--------------------------------------------------------------------------------------------------------------------------
</td></tr></table>


</tr>
</table>
</form>
</body>


</html>
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60810
    
  65

Use code tags, and pare the page down to the minimum to show the problem. That's just too much code to wade through.

Also, there should be no JSP code posted in this forum -- show the resulting HTML (but only if it's relevant).


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Eswar Nec
Ranch Hand

Joined: May 02, 2010
Posts: 105
When you post code, use code tags.
Because the forum user not spend more time to understand your code. If use code tag, easy to read your code.

I check your code. Its worked for me.
Even though you try the following way


OtherWise

Refer the following url :
http://www.catswhocode.com/blog/top-10-best-practices-for-front-end-web-developers


Wake up! Don't let your smile be snatched away by anybody!
Regards, Eswar
kavita vala
Ranch Hand

Joined: Jul 22, 2010
Posts: 42
thanks for reply.
I try it but its working for firefox .
Its working in ie.
For that what can i do.

 
Don't get me started about those stupid light bulbs.
 
subject: not able to call javascript function on onlcick
 
Similar Threads
floating image in firefox ? still in trouble ^_^
Ajax, Struts, and a few pesky event based issues
Is it possible to put a button inside autocomplete in jquery ui plugin?
window.print() not working IE
Access Data from Database By Submitting The select Values