...

View Full Version : on click event in javascript



sridivyadeepu
09-10-2011, 09:28 AM
Hai all,

iam trying to use java script code in my jsp page.

i used a onclick event.while clicking on the button that wil goes to the javascript function(deleteRecord(name,subject)).
this deleterecord() wil post the url request.


my code is like this
-----------------

function deleteRecord(name,subject){

document.write("name received is:"+name);
f.method="post";
var url="http://localhost/myproject/DeleteRecord?";
var url1= "name="+name;
var url2="subject="+subject;
var URL=url+url1+url2;
f.action(URL);
f.submit();
}


my onclickevent code is'
<td width="20%" height="25" align="left" valign="middle"><input type="submit" name="delete" value="Delete" style="background-color:#ff0000;font-weight:bold;color:#ffffff;" onclick="deleteRecord(<%=rs.getString("name")%>,<%=rs.getString("subject")%>);" /></td>

---------------------------------------------
wil iam running my jsp page internet explorer is giving in variable subject (error:'divi' is invalid).divi is the value of the parameter name which iam passing to the function .
and mozilla firefox my script is not working
there is some syntax issues as wel as browser issues...and with url syntax
can any one help me...
Regards,
Divya

Old Pedant
09-10-2011, 08:22 PM
You don't show where you assign your <form> to your variable f

Did you forget that? Or did you just not show it?

In any case, the line

f.action(URL);

should be

f.action = URL;


I really think, though, that there is a simpler way to do this.

Old Pedant
09-10-2011, 08:24 PM
Oh, and you forgot the & between the first and second parameters in the URL.

var URL=url+url1+"&" + url2;



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum