Not able to change textbox value on blur - laravel

Good Afternoon...
I am trying to do the addition of textbox value and show in another textbox using onBlur but not able to do the same. Textbox are genrated using foreach loop as per ID. ( Ref. Attached Image)
For first textbox, the function gives the value but for next textboxes, not able to get the same.
My Modal Table Code.
<tbody>
#foreach ($buffalodata as $item )
<tr>
<td>{{$item->buffaloID}}</td>
<td><input type="number" id="eachmorningmilk" name="eachmorningmilk" value="00"></td>
<td><input type="number" id="eacheveningmilk" name="eacheveningmilk" value="00"></td>
<td><input type="text" id="eachtotalmilk" name="eachtotalmilk" value="00" readonly></td>
</tr>
#endforeach
</tbody>
Code for Function to run onblur
$("#eachmorningmilk").blur(function(){
eachbmorning = parseInt($("#addmilkbuffalo #eachmorningmilk").val());
eachbevening = parseInt($("#addmilkbuffalo #eacheveningmilk").val());
var eachbuffalototalmilk = eachbmorning + eachbevening;
document.getElementById('eachtotalmilk').value=eachbuffalototalmilk;
})
Thanks in Advance.

$("#eachmorningmilk").blur(function(){...in this statement you specify the id (eachmorningmilk) ..
right?
So what about the next two textbox id .. if you want the same effact on next two textboxs then you need to specify the function in textbox element like ..
$("#eacheveningmilk").blur(function(){
eachbmorning = parseInt($("#addmilkbuffalo #eachmorningmilk").val());
eachbevening = parseInt($("#addmilkbuffalo #eacheveningmilk").val());
var eachbuffalototalmilk = eachbmorning + eachbevening;
document.getElementById('eachtotalmilk').value=eachbuffalototalmilk;
})
And for the another one ..
This is the problem of your code in my point of view
Welcome.🙂

Related

Update smart table after content changed

I have an array of objects, which I display using st-table directive.
I filter the table by a value of a certain field in the objects.
The problem is, once a value of a field in these objects has been changed, the filtering is not performed.
I believe the reason for it is that smart-table watches the array's length, but doesn't perform deep comparison to see whether or not the values inside any of the objects changed.
What can I do to solve this?
edit: added code:
angular.module('myApp', ['smart-table'])
.controller('mainCtrl', ['$scope', '$timeout',
function ($scope, $timeout) {
$scope.rowCollection = [
{
name: "sth odd",
number: 1
},
{
name: "sth even",
number: 1
}
];
$scope.displayedCollection = [].concat($scope.rowCollection);
function changeNumber(){
$timeout(function(){
$scope.rowCollection[1].number = $scope.rowCollection[1].number === 1 ? 2 : 1;
changeNumber();
}, 1000);
}
changeNumber();
}
]);
http://plnkr.co/edit/IVYy5WrsiEJSRXZCqY9z?p=preview
Notice how when you search e.g number "2", the view isn't updated even though the property of the second item sometimes is "2" and sometimes not.
Found a solution for you, instead of using st-search use a plain ng-model and then filter by the ng-model value. then in the ng-repeat filter by that value
so instead of this
<input st-search="number" placeholder="search for number" class="input-sm form-control" type="search"/>
...
<tr ng-repeat="row in displayedCollection">
<td>{{row.name}}</td>
<td>{{row.number}}</td>
</tr>
do this
<input ng-model="searchMe" placeholder="search for number" class="input-sm form-control" type="search"/>
....
<tr ng-repeat="row in filterd = (displayedCollection | filter: searchMe)">
<td>{{row.name}}</td>
<td>{{row.number}}</td>
</tr>
here's a plunker, enter 2 and see how it redos the filtering each time
To refresh the smart-table you can add or remove items as you know or use a new array.. so just recreate the array.
$scope.rowCollection = [].concat($scope.rowCollection);

Identifying an WebTable/WebGrid Object in QTP

I have the below code in html for a WebTable(Web Grid).
<table width="90%">
<div class="greybox" style="margin-top:2%;">
<table class="datagrid" width ="100%">....<table>
</div>
</table>
I tried providing exactly the same(all) properties in my descriptive programming but the Web Element(DIV) is not being identified by QTP. Is there a unique way to identify this?
Note: The Web page is developed a single page application
Edit:
So I think I have resolved the issue with the below code. There were two Objects being identified without the "Unique Text" if clause. First Object was parent of the DIV object so had to use a "Unique text" from the first object which wouldn't be part of any other object. I am currently trying with different data to see if it's working fine
Browsername = Browser("micClass:=Browser").GetROProperty("name")
Pagename = Browser("micClass:=Browser").Page("micClass:=Page").GetROProperty("name")
Set desc = Description.Create()
desc("micclass").Value = "Webelement"
Set ChildObject=Browser("name:="&BrowserName).Page("name:="&PageName).ChildObjects(desc)
Set Child_Table_Value = nothing
For i=0 to ChildObject.Count-1
innerhtmlvalue = ChildObject(i).GetRoproperty("innerhtml")
htmltag = ChildObject(i).GetRoproperty("micclass")
if(Instr(innerhtmlvalue, "MARGIN-TOP: 2%")<>0) then
if(Instr(innerhtmlvalue, "UniqueText")=0) then
if(Instr(htmltag, "WebElement")<>0) then
Set Child_Table_Value = ChildObject(i)
End If
End If
End IF
Next
Set Table_Value = Child_Table_Value.WebTable("html tag:=Table")
Ok, so assuming you have an HTML structure something like this:
<table width="90%">
<tr>
<td>
<div class="greybox" style="margin-top:2%;">
<table class="datagrid" width="100%">
<tr>
<td>UniqueText</td>
</tr>
</table>
</div>
</td>
</tr>
</table>
...and as per your current solution you can rely on "UniqueText" being present, then you could try the following XPath statement:
(//table[contains(., 'UniqueText')])[last()]
So in QTP/UFT you'd be doing:
Browser("micClass:=Browser").Page("micClass:=Page").WebTable("xpath:=(//table[contains(., 'UniqueText')])[last()]")
Try to use like below.(Try to identify the div block using the "class")
Browser("micClass:=Browser").Page("micClass:=Page").Webelement("class:=greybox").Webtable("class:=datagrid")
Please let me know

How to add an HTML5 data-something attribute in Razor

I am trying to generate a table like this
#foreach (var item in #Model.Where(o => o.Status == "Submitted")){
<tr class="row" data_orderid="#item.Id">
<td class="description">
#item.Customer
</td>
<td class="description">
#item.OrderDescription
</td>
...etc...etc
so that I can handle the click event of each tr, and display some info based on the data-orderid attribute value of the tr that was clicked.
In Visual Studio I get a validation message saying "data_orderid is not a valid attribute of tr" and when it renders the HTML tr has no attributes, Not event the class.
How should I be adding attributes like this?
The format of HTML 5 data attribute is like this
data-AttributeName=AttributeValue
Example :
data-name="John Resig"
Change underscore to a hiphen and it will be rendered correctly.
<tr class="row" data-orderid="#item.Id">
First of all it is more likely that you should be using "data-xxx" (rather than "data_xxx") attributes.
Secondly, It is unlikely (if not imposible) for visual studio to omit class and your "data_orderid" attributes.
Make sure that for loop gets any elements from your condition #Model.Where(o => o.Status == "Submitted"
Additionally, as a note, Razor is smart enough to interpret 'html attributes' passed to elements, like here:
#Html.TextBoxFor(m => m.Name, new { #data_orderid = item.id, #class="input-xxlarge" }))

Not able to get multiple values from checkbox

I am trying to access multiple checkbox values from the jsp page.. But i am ending up with wrong bindings..
jsp page:
<c:forEach items="${employees}" var="employee">
<tr>
<td><spring:checkbox path="selectedMails" value="<c:out value='${employee.emailid}'/>"/> </td>
<td><spring:label path="employeeId">${employee.employeeId}</spring:label></td>
<td><spring:label path="employeeName">${employee.employeeName}</spring:label></td>
<td><spring:label path="emailid" >${employee.emailid}</spring:label></td>
<td><spring:label path="reportmanager">${employee.reportmanager}</spring:label></td>
</tr>
</c:forEach>
dto page
//Invitation Beans
private String [] selectedMails;
public String [] getSelectedMails() {
return selectedMails;
}
public void setSelectedMails(String [] selectedMails) {
this.selectedMails = selectedMails;
}
i am able to print ${employee.emailid} on jsp page.. but i am not able to getting back, and i need more than one values to be saved.. Please help me out
You should give the arrayindex in the path attribute for each checkbox you create.
Following changes you need to do in your jsp code.
<c:forEach items="${employees}" var="employee" varStatus="cnt">
<tr>
<td><spring:checkbox path="selectedMails[${cnt.index}]" value="<c:out value='${employee.emailid}'/>"/> </td>
<td><spring:label path="employeeId">${employee.employeeId}</spring:label></td>
<td><spring:label path="employeeName">${employee.employeeName}</spring:label></td>
<td><spring:label path="emailid" >${employee.emailid}</spring:label></td>
<td><spring:label path="reportmanager">${employee.reportmanager}</spring:label></td>
</tr>
</c:forEach>
I think this should work for you.
Hope this helps you.
Cheers.
To get more than one value you should have more than one checkbox with same name. In that case it will be putted in request as an array and you can get this values as array.
If you have single checkbox - you will get single value. Or no value at all if checkbox not checked. It not put any value to request in case if checkbox is not checked.

Combo-Box value not passing in AJAX

Want to pass 4 values in AJAX parameter.First three are passing properly but the fourth one giving problem.i came to know after displaying alert in AJAX
<tr align="left">
<td style="background-color:#1569C7;color:white;font-weight:bold;font-size:110%;border-style:outset;"><center><b>Test Conducted</b></center></td>
<td><select onchange="javascript:type123(document.getElementById('fodate').value,document.getElementById('todate').value,document.getElementById('product').value);" id="testcond" name="testcond">
<option>--Select--</option>
</select></td>
</tr>
AJAX CODE:
<script language="javascript">
var xmlHttp1=null;
function type123(obj,obj1,obj2)
{
//alert(this.value);
var type_value=document.getElementById('testcond').options.selectedIndex.value;
var val1=obj;
var val2=obj1;
var val3=obj2;
// var val4=obj3;
alert(val1);
alert(val2);
alert(val3);
alert(type_value);
Instend of
var type_value=document.getElementById('testcond').options.selectedIndex.value;
You can try this one to get selected value of Combo-Box
var type_value=document.getElementById('testcond').value;<br/>alert(type_value);

Resources