By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,092 Members | 1,546 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,092 IT Pros & Developers. It's quick & easy.

Help with Ajax script concering parmaters in ajax.requestFile

P: 40
Hi all

Hope someone can help with the problem I am having as it is driving me nuts!

I have the below script on my site the problem lies with passing through a url parameter in the below line getCourseName

"ajax.requestFile = 'getCourse.php?coursename='+getCourseName;"

if I change the above line to (Brackenwood being a value in my database all wors fine.

ajax.requestFile = 'getCourse.php?coursename=Brackenwood';

Can anyone see any problems in the below code?

My input box that I get the value from in the form has an id and name of coursename.

The script is a client lookup at dhtml goodies.

any help would be most appriciated thank you.

Tom

Expand|Select|Wrap|Line Numbers
  1.  
  2. var ajax = new sack();
  3.     var currentcoursename=false;
  4.     function getClientData()
  5.     {
  6.         var getCourseName = document.getElementById('coursename');
  7.         if(getCourseName!=currentcoursename){
  8.             currentcoursename = getCourseName
  9.             ajax.requestFile = 'getCourse.php?coursename='+getCourseName;    // Specifying which file to get
  10.             ajax.onCompletion = showClientData;    // Specify function that will be executed after file has been found
  11.             ajax.runAJAX();        // Execute AJAX function            
  12.         }
  13.  
  14.     }
  15.  
  16.     function showClientData()
  17.     {
  18.         var formObj = document.forms['calc'];    
  19.         eval(ajax.response);
  20.     }
  21.  
  22.  
  23.     function initFormEvents()
  24.     {
  25.         document.getElementById('coursename').onblur = getClientData;
  26.         document.getElementById('coursename').focus();
  27.     }
  28.  
  29.  
  30.     window.onload = initFormEvents;
  31.  
May 24 '07 #1
Share this Question
Share on Google+
7 Replies


acoder
Expert Mod 15k+
P: 16,027
You need
Expand|Select|Wrap|Line Numbers
  1. getCoursename.value
getCoursename is the object - you need its value.
May 25 '07 #2

P: 40
You need
Expand|Select|Wrap|Line Numbers
  1. getCoursename.value
getCoursename is the object - you need its value.
Thank you for your reply I will give it ago asap, am I right in thinking where I have references to "getCoursename =" it should be getCoursename.value =

I'm new to Ajax and have only ever used Javascript very briefly.

Thanks for your help.

Tom
May 26 '07 #3

acoder
Expert Mod 15k+
P: 16,027
Thank you for your reply I will give it ago asap, am I right in thinking where I have references to "getCoursename =" it should be getCoursename.value =
Yes, that's correct.
May 26 '07 #4

P: 40
Yes, that's correct.
Hi thank you for all your help I have amended all references to include the .value but still nothing works.

here is the original code from dhtml goodies

Expand|Select|Wrap|Line Numbers
  1. var ajax = new sack();
  2.     var currentClientID=false;
  3.     function getClientData()
  4.     {
  5.         var clientId = document.getElementById('clientID').value.replace(/[^0-9]/g,'');
  6.         if(clientId.length==4 && clientId!=currentClientID){
  7.             currentClientID = clientId
  8.             ajax.requestFile = 'getClient.php?getClientId='+clientId;    // Specifying which file to get
  9.             ajax.onCompletion = showClientData;    // Specify function that will be executed after file has been found
  10.             ajax.runAJAX();        // Execute AJAX function            
  11.         }
  12.  
  13.     }
  14.  
  15.     function showClientData()
  16.     {
  17.         var formObj = document.forms['clientForm'];    
  18.         eval(ajax.response);
  19.     }
  20.  
  21.  
  22.     function initFormEvents()
  23.     {
  24.         document.getElementById('clientID').onblur = getClientData;
  25.         document.getElementById('clientID').focus();
  26.     }
  27.  
  28.  
  29.     window.onload = initFormEvents;
  30.  
  31.  
I amended the following line:

Expand|Select|Wrap|Line Numbers
  1. var clientId = document.getElementById('clientID').value.replace(/[^0-9]/g,'');
so that I can use values that are not only numerical, I have also placed the .value at the end of document.getElementById('coursename') but still no joy.

Thank you for your help

Regards
Tom
May 29 '07 #5

acoder
Expert Mod 15k+
P: 16,027
Can you post your form HTML markup.
May 29 '07 #6

P: 40
Can you post your form HTML markup.
Hi sorry to have bothered you I made a typo when adding the .value to the end of the ID element.

The script works now sorry for wasting your time, I have very little knowledge of JavaScript and AJAX.

Thank you for your help.
May 30 '07 #7

acoder
Expert Mod 15k+
P: 16,027
Hi sorry to have bothered you I made a typo when adding the .value to the end of the ID element.

The script works now sorry for wasting your time, I have very little knowledge of JavaScript and AJAX.

Thank you for your help.
No problem at all. Glad you got it working in the end.
May 30 '07 #8

Post your reply

Sign in to post your reply or Sign up for a free account.