Hi,
I am facing problem to call an ajax script on onchange event of a textbox.
I have to show a list of quotations in my view and each quotation is having Supplier, Quantity,Price etc. fields. I want to keep the Quantity and price fields as editable.And after editing it should be saved back into db.ie, I have to call a function onblur or onchange event or the textbox.I have written a script and it is no getting invoked.Any help?
I am adding my view code and script below:
following is the code in view to show the required entries in table. I want to update database onblur or onchange evevnt of textboxes with id
itemPrice and itemQuantity. And the ajax script I have written is shown below this code.
itemPrice and itemQuantity. And the ajax script I have written is shown below this code.
@foreach (var item in Model)
{
bool aprv = Convert.ToBoolean(item.Approved);
if (aprv)
{
var totp = item.Quantity * Convert.ToInt32(item.Price);
@Html.DisplayFor(modelItem => item.SKUMaster.Name)
@Html.DisplayFor(modelItem => item.SKUMaster.PackagingType)
@Html.DisplayFor(modelItem => item.SKUMaster.Manufacturer)
@Html.TextBoxFor(modelItem => item.Price, new { @id = "itemPrice"})
@Html.TextBoxFor(modelItem => item.Quantity, new { @id = "itemQuantity"})
@Html.DisplayFor(modelItem => item.SupplierMaster.SupplierName)

{
bool aprv = Convert.ToBoolean(item.Approved);
if (aprv)
{
var totp = item.Quantity * Convert.ToInt32(item.Price);
@Html.DisplayFor(modelItem => item.SKUMaster.Name)
@Html.DisplayFor(modelItem => item.SKUMaster.PackagingType)
@Html.DisplayFor(modelItem => item.SKUMaster.Manufacturer)
@Html.TextBoxFor(modelItem => item.Price, new { @id = "itemPrice"})
@Html.TextBoxFor(modelItem => item.Quantity, new { @id = "itemQuantity"})
@Html.DisplayFor(modelItem => item.SupplierMaster.SupplierName)
}
}
}
The jquery to send changed value of itemPrice textbox to controller is given below:
It is not working. Any help will be appreciated.
Thanks in advance.
Thanks in advance.
Replies
Know the answer? Post it — somebody with the same question will find it here.