PDA

View Full Version : Passing a string to a function with web method...



tranky
10-23-2007, 11:59 PM
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).




<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" önclick="CallWebMethod()" title="CLICCAMI" />




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:




<input type="button" önclick="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



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



Pleeeeease help me! Thank u!!

Twey
10-24-2007, 12:14 AM
... OK... and the problem is?