-
Hello,
I would like to know how I can pass a TextBox.Text to a javascript function. This function formats a number as "currency"
I try with this: txtBelopp.Attributes.Add("OnBlur","javascript:formatCurrency('txtBelopp').Text");
But doesn't work.
-
Hi,
You would use this.value
so, javascript:formatCurrency(this.value);
Regards
Si
-
Yes, it seems work but cannot verufy that because I cannot receive the "return" value.
I try with this:
jscript.Append("document.getElementById('txtBelopp').value =(((sign)?'':'-') + '$' + num + '.' + cents);\n");
But it says:
document.getElementById() is NULL OR NOT an OBJECT !!!
-
Hi,
The getElementById won't work for the textbox like that because the ID gets changed by the asp.net output.
Use something like document.getElementById('<%# txtBelopp.clientid %>');
regards
Si
-
Si, thank you for your answers but it isnot working.
I got the same error message: NULL or not an Object
Here is the function if you have more time to spend with this:
jscript.Append("\n");
Page.ClientScript.RegisterStartupScript(this.GetType(), "AleformatScript", jscript.ToString());
-
Hi,
Sorry, i thought the script was in the aspx page. Replace the getElementByIDs for this one
jscript.Append("document.getElementById('" & txtBelopp.clientid & "').value =(((sign)?'':'-') + '$' + num + '.' + cents);\n");
HTH
Si
-
THANK YOU!!!! It works now.
I only changed ('" & txtBelopp.clientid & "') by ('" **+** txtBelopp.Client**ID** **+** "')
once again Thank you!
Regards
Ale
-
Sorry,
my bad, didnt notice it was C# you were using.
Glad you have got it sorted.
Si
Enter your message below
Sign in or Join us (it's free).