Loading ...
Sorry, an error occurred while loading the content.

Cannot get setForm() to work in Connection Manager

Expand Messages
  • than505
    Hi, My first (simple) attempt at using connection manager worked, so I know all urls etc are correct. However, when I tried to use the setForm() method my
    Message 1 of 3 , Apr 30, 2006
    • 0 Attachment
      Hi,
      My first (simple) attempt at using connection manager worked, so I
      know all urls etc are correct. However, when I tried to use the
      setForm() method my program would not work. It is just a simplificaion
      of some stuff from this forum and the Yahoo example. Here it is:

      file: form_example.php

      <?php
      if ($_POST) {
      echo 'got posted';
      exit;
      }
      ?>
      <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
      "http://www.w3.org/TR/html4/strict.dtd">
      <html lang = "en">
      <head>
      <title>Test</title>
      <script type="text/javascript"
      src="http://www.permaserve.com/dev/ajax/connection_manager/js/YAHOO.js"></script>
      <script type="text/javascript"
      src="http://www.permaserve.com/dev/ajax/connection_manager/js/connection.js"></script>


      <script type="text/javascript">
      <!--
      function sendRequest() {
      var callback = {
      success: submit_success,
      failure: null,
      argument: null
      }

      var oForm = document.getElementById('testform');
      YAHOO.util.Connect.setForm(oForm);
      YAHOO.util.Connect.asyncRequest('POST', 'form_example.php',
      callback, null);
      }

      function submit_success(ret) {
      alert(ret.responseText);
      }


      // -->
      </script>
      </head>

      <body>

      <form name="testform" id="testform" action="form_example.php"
      method="POST">

      <input name="test" id="test" value="name">
      <input id="test2" value="no name">
      <input type="button" name="submit" value="Submit Form"
      onclick="sendRequest();">

      </form>
      </body>

      Does anyone see anything wrong with this? When I click the button,
      nothing happens.

      Thanks.
    • Ron Lancaster
      It looks like you re passing a form rather than the form s name. Try YAHOO.util.Connect.setForm(oForm.name); ... ...
      Message 2 of 3 , Apr 30, 2006
      • 0 Attachment
        It looks like you're passing a form rather than the form's name. Try
        YAHOO.util.Connect.setForm(oForm.name);

        On Apr 30, 2006, at 12:52 PM, than505 wrote:

        > Hi,
        > My first (simple) attempt at using connection manager worked, so I
        > know all urls etc are correct. However, when I tried to use the
        > setForm() method my program would not work. It is just a simplificaion
        > of some stuff from this forum and the Yahoo example. Here it is:

        <snip>
        >
        > <script type="text/javascript">
        > <!--
        > function sendRequest() {
        > var callback = {
        > success: submit_success,
        > failure: null,
        > argument: null
        > }
        >
        > var oForm = document.getElementById('testform');
        > YAHOO.util.Connect.setForm(oForm);
        > YAHOO.util.Connect.asyncRequest('POST', 'form_example.php',
        > callback, null);
        > }
        >
        <snip>
        > Does anyone see anything wrong with this? When I click the button,
        > nothing happens.
        >
        > Thanks.
      • than505
        Thank you, that worked.
        Message 3 of 3 , Apr 30, 2006
        • 0 Attachment
          Thank you, that worked.

          --- In ydn-javascript@yahoogroups.com, Ron Lancaster <doc@...> wrote:
          >
          > It looks like you're passing a form rather than the form's name. Try
          > YAHOO.util.Connect.setForm(oForm.name);
          >
          > On Apr 30, 2006, at 12:52 PM, than505 wrote:
          >
          > > Hi,
          > > My first (simple) attempt at using connection manager worked, so I
          > > know all urls etc are correct. However, when I tried to use the
          > > setForm() method my program would not work. It is just a simplificaion
          > > of some stuff from this forum and the Yahoo example. Here it is:
          >
          > <snip>
          > >
          > > <script type="text/javascript">
          > > <!--
          > > function sendRequest() {
          > > var callback = {
          > > success: submit_success,
          > > failure: null,
          > > argument: null
          > > }
          > >
          > > var oForm = document.getElementById('testform');
          > > YAHOO.util.Connect.setForm(oForm);
          > > YAHOO.util.Connect.asyncRequest('POST', 'form_example.php',
          > > callback, null);
          > > }
          > >
          > <snip>
          > > Does anyone see anything wrong with this? When I click the button,
          > > nothing happens.
          > >
          > > Thanks.
          >
        Your message has been successfully submitted and would be delivered to recipients shortly.