Help me to submit my form with javascript please

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Justin09
    New Member
    • Apr 2009
    • 3

    Help me to submit my form with javascript please

    Hello.

    I have a frames page that has a header, body and a footer. The header frame has an ajax autocomplete that returns a number and a string from a database.

    Here is what happens. The user looks up a client in the autocomplete textbox. The ajax autocomplete give the user choices. the user selects the one he wants with either his mouse or the arrow keys and then presses ENT. THERE IS NO SUBMIT BUTTON.

    The value that was returned by ajax needs to go to a php script where it will do a lookup by the customer number. The value returned by ajax is the customer's number.

    This returned value is what I need help with. I need to get the returned ajax value into my query sting (GET) so I can populate the body frame with the correct info. I am having a really hard time with this and can't make any headway.

    I know no javascript at all so please spell things out for me.

    Here is the relavent code.

    Code:
    <form method="post" class="hdrForm" id="search" action="../../index.php?ds=2" target="_top">
    <input type="text" name="string" class="hdrInput" id="string" value=""><div id="acDiv"></div>
    </form>
    Code:
    var AC = new Suggest('string','acDiv');
    AC.ajaxTarget = '../../lib/inc/suggest.php';
    AC.chooseFunc = function(id,label)
    {
      document.forms.search.submit();
    }
    Thanks for any help you can provide.
  • Justin09
    New Member
    • Apr 2009
    • 3

    #2
    I have actually figured out most of this already but I am still having a problem.

    Here are two functions. I need to use the "id" variable in the SubmitForm() function as well. Can someone please tell me how to do this? This is how new I am to js. :)

    Thanks for the help.
    Code:
      AC.chooseFunc = function(id,label)
      {
        document.qSearch.action = ".index.php?dc=2&id="+ id;
        //document.qSearch.action = "index.php?dc=2";
        document.qSearch.submit();
      }
    
      *** This one fails.
      function SubmitForm(id)
      {
        document.qSearch.action = "index.php?dc=2&id="+ id;
        document.qSearch.submit()
      }
    What I need is the "id" var appended to the query string in the SubmitForm Function. Can someone tell me how to do this please? Thanks for the help!

    Comment

    • Justin09
      New Member
      • Apr 2009
      • 3

      #3
      Solved! Thanks for the help

      Comment

      Working...