Click here to Skip to main content
15,905,875 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have to show muptiple result of server textbox txtQty and txtPrice on txtValue
when click on txtQty or txtPrice
I have created the following javascript function

function CalculateValue() {

var strQty = $("[id$='txtQty']").val();
var strPrice = $("[id$='txtPrice']").val();
var strValue = (parseFloat(strQty) * parseFloat(strPrice));

$("[id$='txtValue']").text = strValue;
return false;
My requirement is to show the result in textbox txtValue when I click textbox txtPrice
Posted
Comments
Solai Raja 20-Feb-15 1:32am    
Try this $("#txtValue").val(strValue)

You can use like:
JavaScript
$('[id$=txtPrice]').click(function(){
    CalculateValue()
});
 
Share this answer
 
Comments
Sumon562 20-Feb-15 1:44am    
Thank you Mr. Abhinaw Kuma. Where I use thi code.Please help me
[no name] 20-Feb-15 1:48am    
You can use it in your javascript block or file.
Try This code...
$("[id$=txtPrice]").click(function(){
    $("[id$='txtValue']").val(
      parseFloat($("[id$='txtQty']").val() 
* parseFloat($("[id$='txtPrice']").val())
)});
 
Share this answer
 
v2
Comments
Sumon562 20-Feb-15 3:20am    
use this code in my function CalculateValue()? Please help
manak chand 20-Feb-15 3:31am    
$("[id$=txtPrice]").click(function(){
CalculateValue();
)});

function CalculateValue()
{
$("[id$='txtValue']").val(
parseFloat($("[id$='txtQty']").val()
* parseFloat($("[id$='txtPrice']").val())

}
In your code below line is wrong
JavaScript
$("[id$='txtValue']").text = strValue;


use it like below

JavaScript
$("[id$='txtValue']").text(strValue);


Reference :
http://api.jquery.com/text/[^]

http://www.w3schools.com/jquery/tryit.asp?filename=tryjquery_html_text_set[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900