How to fill form by selecting clickable table values using java script

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ghjk
    Contributor
    • Jan 2008
    • 250

    How to fill form by selecting clickable table values using java script

    I have table which is clickable.When user click one record I want to call java script function and fill the form using selected values. This is my code and I can't understand what is going wrong.Please help me..

    Code:
    <script language="javascript">
    function fillForm(){
       document.getElementById('fullname').value=searchlist.getFullName();
    }
    </script>
    ....
    <input type="text" name="fullname">
    ....
     out.println("<tr><td><a href='#' onclick='fillForm();'>" + searchlist.getFullName() + "</a></td>");
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    that’s not much to build upon … what is searchlist.getF ullName()? is it defined? anything in the Error Console?

    Comment

    • ghjk
      Contributor
      • Jan 2008
      • 250

      #3
      Originally posted by ghjk
      I have table which is clickable.When user click one record I want to call java script function and fill the form using selected values. This is my code and I can't understand what is going wrong.Please help me..

      Code:
      <script language="javascript">
      function fillForm(){
         document.getElementById('fullname').value=searchlist.getFullName();
      }
      </script>
      ....
      <input type="text" name="fullname">
      ....
       out.println("<tr><td><a href='#' onclick='fillForm();'>" + searchlist.getFullName() + "</a></td>");
      It is use to get database values. I didn't get any error when I click a record.
      Code:
      int i = 0;
      ArrayList searchList = (ArrayList) session.getAttribute("SearchList");
      if (searchList != null) {
        ListIterator list = searchList.listIterator();
        while (list.hasNext()) {
          data.UserAccount searchlist = (data.UserAccount) list.next();
          out.println("<tr><td><a href='#' onclick='fillForm();'>" + searchlist.getFullName() + "</a></td>");
      Last edited by Dormilich; May 26 '10, 06:32 AM. Reason: fixed [code] tags

      Comment

      • RamananKalirajan
        Contributor
        • Mar 2008
        • 608

        #4
        Have a look over this

        Thanks and Regards
        Ramanan Kalirajan

        Comment

        • Dormilich
          Recognized Expert Expert
          • Aug 2008
          • 8694

          #5
          from what I can see you try to intertwine 2 programming languages. are you sure you have called each one correctly?

          Comment

          • ghjk
            Contributor
            • Jan 2008
            • 250

            #6
            Originally posted by RamananKaliraja n
            Have a look over this

            Thanks and Regards
            Ramanan Kalirajan
            RamananKaliraja n
            Exactly I want to do this? Please help me..

            Comment

            • RamananKalirajan
              Contributor
              • Mar 2008
              • 608

              #7
              You can have the code for that in this link. But this one is a static one i developed. Use this as a sample and try it out. we will help you out, if you are struck up.

              Thanks and Regards
              Ramanan Kalirajan

              Comment

              • ghjk
                Contributor
                • Jan 2008
                • 250

                #8
                Originally posted by ghjk
                RamananKaliraja n
                Exactly I want to do this? Please help me..
                You have to pass the values like this and. get them from java script
                Code:
                out.println("<tr><td><a href='#' onclick=\"javascript:editForm(\'"+full_name+"\',\'"+user_type+"\');return 0;\"></a></td>");
                Code:
                function editForm(fullname,usertype){
                ......
                .......

                Comment

                Working...