Web Analytics Made Easy -
StatCounter on click event in javascript - CodingForum

Announcement

Collapse
No announcement yet.

on click event in javascript

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • on click event in javascript

    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

  • #2
    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
    Code:
    f.action(URL);
    should be
    Code:
    f.action = URL;
    I really think, though, that there is a simpler way to do this.
    Be yourself. No one else is as qualified.

    Comment


    • #3
      Oh, and you forgot the & between the first and second parameters in the URL.

      var URL=url+url1+"&" + url2;
      Be yourself. No one else is as qualified.

      Comment

      Working...
      X
      😀
      🥰
      🤢
      😎
      😡
      👍
      👎