RA Jones wrote:

> OK, I tried the following in the <head> section of my template:
> <script type="text/javascript" src="/jquery.js"></script>
> <script type="text/javascript">
> <!--
> function validate_nhsno(myInput) {
>   $('#nhs_no').load(
>     'check_nhsno.cgi',
>   {
>     rm : 'validate_nhsno',
>     itemToValidate : myInput
>   });
> }
> // -->
> </script>
> 
> HTML form contains:
> <p>NHS No: <input type="text" name="nhs_no" id="nhs_no"
> onblur="validate_nhsno('nhs_no'); return true;" />

I don't know JQuery, but I'm pretty sure the element you're calling load() on
(id='nhs_no') is the element you want the contents replaced. Not the element
you're validating.

Not to add too much to your plate, but you'll also need to use a browser that
has decent debugging tools. I prefer firefox, but some people pay for visual
studio and use IE.

With Firefox, my Ajax debugging goes something like this:
If it's not doing anything, then open up the Tools -> Javascript Console, clear
it out, refresh my page and see what JS or CSS errors my page has. If that
doesn't show anything, then open up the LiveHTTPHeaders FF plugin, try the
action that will use Ajax and watch the headers go back and forth to the server
to see what is getting passed.

> Result: nothing! Is the above a correct interpretation of your example?
> It might even be working, but I cannot see anywhere for the result of
> the AJAX request to go.

I'll preface this by saying I don't use JQuery, but I would think your code
needs to be something like this:

  <script type="text/javascript" src="/jquery.js"></script>
  <script type="text/javascript">
  <!--
  function validate_nhsno(myInput) {
    $('#nhs_no_msg').load(
      'check_nhsno.cgi',
    {
      rm : 'validate_nhsno',
      itemToValidate : myInput.value
    });
  }
  // -->
  </script>

  HTML form contains:
  NHS No: <input type="text" name="nhs_no" id="nhs_no"
  onblur="validate_nhsno(this); return true;" />
  <span id="nhs_no_msg"></span>

-- 
Michael Peters
Developer
Plus Three, LP


---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/[email protected]/
              http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to