Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    May 2006
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Passing a string to a function with web method.... :(

    Hello!

    Can you help me?

    I've this situation:

    I use a web service through ajax. The service is "TreStringheService" and the web method is "GetTreStringhe", and that method accept one string parameter (in this case is 0100012).

    Code:
    <script language="javascript" type="text/javascript">
        
     function CallWebMethod()
        {            
             TreStringheService.GetTreStringhe("0100012",Fill,ErrorHandler,TimeOutHandler);
         }
      
        function TimeOutHandler(result)
        {
            alert("Timeout :" + result);
        }
    
        function ErrorHandler(result)
        {
            var msg=result.get_exceptionType() + "\r\n";
            msg += result.get_message() + "\r\n";
            msg += result.get_stackTrace();
            alert(msg);
        }
      
       function Fill(result)
        {
            var lblMsg=document.getElementById("lblMsg");
            lblMsg.innerHTML = "TEST";
        }
       </script>
      
       <input type="button" onclick="CallWebMethod()" title="CLICCAMI" />
         <span id="lblMsg" style="font-weight: bold; color: red;"></span>


    Now, what i'll want is to passing to the Fill function a string parameter that is the element id, so i can say to the function the right element to use, for example:

    Code:
    <input type="button" onclick="CallWebMethod('lblMsg')" title="CLICCAMI"/> 
    
      function CallWebMethod(elementID)
        {            
    
    // but here? what i must write for passing the elementID string to the Fill function?
             TreStringheService.GetTreStringhe("0100012",Fill,ErrorHandler,TimeOutHandler);
         }
    // if i can passing a string to the Fill function i can do that

    Code:
      function Fill(?????)
        {
            var lblMsg=document.getElementById(elementID);
            lblMsg.innerHTML = "TEST";
        }


    Pleeeeease help me! Thank u!!

  • #2
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    Code:
    function CallWebMethod(elementID)
        {            
    TreStringheService.GetTreStringhe(elementID,Fill,ErrorHandler,TimeOutHandler);
         }
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •