I have table rows which I need to generate based on template. There should be some variables. For example persons[0].lastName should be persons[1].lastName for next row and so on. I want to store template in html file. I use angular-ui/ui-router. How to make this work?
Example:
<tr>
<td>
<div class="form-group first-name">
<label>First name</label>
<input type="text" ng-class="{'input-valid': isValidField('FirstName', persons[0].firstName)}" name="firstName" class="form-control input-name" ng-model="persons[0].firstName" ng-focus="focused('inputFirstName', 0)" placeholder="-">
</div>
</td>
<td>
<div class="form-group last-name">
<label>Last name</label>
<input type="text" ng-class="{'input-valid': isValidField('LastName', persons[0].lastName)}" name="lastName" class="form-control input-name" ng-model="persons[0].lastName" ng-focus="focused('inputLastName', 0)" placeholder="-">
</div>
</td>
</tr>
UPDATE
I find that ui router supports resolution of dependent objects and it's injection into controller. I successfully got html at string using resolve and $http inside of it. Now I need to replace 1 to relevant digit for each iteration. What is the best practice to do it?
UPDATE 2
I am not sure if ngRepeat is relevant here because I don't have list of objects to iterate. For example in imperative languages ngRepeat would equal foreach but I need just for loop where I can specify number of elements i need
UPDATE 3
I added all rows to array tableRowsHTML. Now I have troubles to render it in view as raw HTML. This simply does not work:
<table>
<tr> static stuff here </tr>
<tr ng-repeat="el in tableRowsHTML track by $index">
{{el}}
</tr>
</table>
How to fix it?
Use something like this
<tr>
<td>
<div class="form-group first-name" ng-repeat="name in firstNames track by $index">
<label>First name</label>
<input type="text" ng-class="{'input-valid': isValidField('FirstName', persons[$index].firstName)}"
name="firstName" class="form-control input-name" ng-model="persons[$index].firstName"
ng-focus="focused('inputFirstName', 0)" placeholder="-">
</div>
</td>
<td>
<div class="form-group last-name" ng-repeat="name in lastNames track by $index">
<label>Last name</label>
<input type="text" ng-class="{'input-valid': isValidField('LastName', persons[$index].lastName)}"
name="lastName" class="form-control input-name" ng-model="persons[$index].lastName"
ng-focus="focused('inputLastName', 0)" placeholder="-">
</div>
</td>
here firstNames, and lastNames are the list of names.
Related
I'm typing to disable/avoid the autosuggest on specific field.
The html snippet is this:
<div class="form-group">
<h4 class="whitish" for="name-of-car-id">Name of car (max length 30 chars)</h4>
<input type="input" class="form-control" placeholder="" id="name-of-car-id" autocomplete="off">
<span id='remainingC'></span>
<small class="form-text text-muted">You will identify your group of IDs by this name</small>
<div id='name-of-car-error' style='color:red; font-size: 18px;'></div>
</div>
note that I added the autocomplete='off' and yet, the browser still provide a suggestion.
Try to replace input type="input" with type="text"
I'm trying to get a form to output a number value based on the outcome of two fields. A value input and a radio selection but I can't seem to get it to work.
<form oninput="retVal.value=parseInt(pavVal.value)-(parseInt(pavVal.value)*parseInt(pavCAT.value))">
<table>
<tr>
<td>
<label for="pavVal"><b>PAV:</b></label>
</td>
<td>
<input type="number" id="pavVal">
</td>
</tr>
<tr>
<td>
<label for="pavCAT" ><b>CAT:</b></label>
<td>
<input type="checkbox" name="pavCAT" id="pavCAT" value="0.3">
<label for="0.3" > N (30%)</label>
<input type="checkbox" name="pavCAT" id="pavCAT" value="0.2">
<label for="0.2" > S (20%)</label>
<input type="checkbox" name="pavCAT" id="pavCAT" value="0.1">
<label for="0.1"> B (10%)</label>
</td>
</tr>
<tr>
<td>
<label for="retVal"><b>Retention Value:</b></label>
</td>
<td>
<output name="retVal" for="pavVal pavCAT"></output>
</td>
</tr>
</table>
</form>
Anyone able to tell me where I'm going wrong>
Ids must be unique -- there were three #pavCAT. When the browser is told to do anything with #pavCAT, it will find the first #pavCAT do whatever it was supposed to do then quit, leaving the other 2 #pavCATs untouched as if they never existed. The easiest solution is to suffix each id with a number.
The rest of the code should work since in this case the id #pavCAT is just as accessible as the name [name="pavCAT"].
Also, the HTML had checkmarks not radios.
The inline event handler is now streamlined:
oninput = "retVal.value = pavVal.value - (pavVal.value * pavCAT.value)"
Note that parseInt() isn't used to convert the string values into numbers. That's because the strings are being coerced into numbers by the use of these operators: - and *.
<form id='calc' oninput = "retVal.value = pavVal.value - (pavVal.value * pavCAT.value)">
<table>
<tr>
<td>
<label for="pavVal"><b>PAV:</b></label>
</td>
<td>
<input id="pavVal" type="number">
</td>
</tr>
<tr>
<td>
<label for="pavCAT"><b>CAT:</b></label>
</td>
<td>
<input id="pavCAT3" name="pavCAT" type="radio" value="0.3">
<label for="pavCAT3"> N (30%)</label>
<input id="pavCAT2" name="pavCAT" type="radio" value="0.2">
<label for="pavCAT2"> S (20%)</label>
<input id="pavCAT1" name="pavCAT" type="radio" value="0.1">
<label for="pavCAT1"> B (10%)</label>
</td>
</tr>
<tr>
<td>
<label for="retVal"><b>Retention Value:</b></label>
</td>
<td>
<output name="retVal" for="pavVal pavCAT"></output>
</td>
</tr>
</table>
</form>
Your formula is working, but you assigned the same ID for the pavCat checkbox elements, thus returning NaN and not the correctly assigned value - try it yourself with removing/commenting out two ot the pavCAT elements.
imho is a checkbox the wrong UI element - go for a single select dropdown or even better a radio input.
Also parseInt should be parseFloat instead for pavCat. Anyways it's a little bit over the top in this situation and you could totally remove it in this simple example - maybe you have more context to justify parsing it.
<input type="radio" id="pavCat1" name="pavCAT" value="0.3">
<label for="0.3" > N (30%)</label>
<input type="radio" id="pavCat2" name="pavCAT" value="0.2">
<label for="0.2" > S (20%)</label>
<input type="radio" id="pavCat3" name="pavCAT" value="0.1">
<label for="0.1"> B (10%)</label>
https://jsfiddle.net/p9v1f53w/16/
I have a input field that has data pulling form the database, however when the data base is empty the input field displays the disabled that is used to disable the field when not editable.
For example in my html:
<label for="fname">CompanyCode:</label>
<input type="text" id="fname" name="fname" value={{$id->CompanyCode}} disabled>
This above pulls data however if there is now data to pull it uses the "disabled" word as the value and then the field doesn't become disabled.
Can I use a condition to overcome this using something like:
<label for="fname">CompanyCode:</label>
<input type="text" id="fname" name="fname"
value= #if($id->CompanyCode) count() == 0)
<td colspan="5" class="text-center"> Nothing Found </td>
#endif
disabled>
I was able to get the answer :
<label for="fname">CompanyCode:</label
<input type="text" id="fname" name="fname" value="{{ $id->CompanyCode}}" {{$id->companyCode ? '' : 'disabled' }}>
I could have also added Quotations for the desired result aswell :
<label for="fname">CompanyCode:</label
<input type="text" id="fname" name="fname" value="{{ $id->CompanyCode }}" disabled>
here is the image If click on Add symbol each row will be added so index should increment automatically
Please someone explain me?
<div class="form-row">
<div
class="form-row"
*ngFor="let temp of logger.temperature; let i = index"
>
<div class="form-group col-md-2">
<input
name="tempindex+{{ i }}"
[(ngModel)]="temp.index"
type="number"
class="form-control"
placeholder="Index"
required
/>
</div>
If click on Add symbol each row will be added so index should increment automatically
Please someone explain me?
When you dynamically add rows, its better you to use reactive form. YOu just need to add
<tbody formArrayName="gaugeTitles"
*ngFor="let item of gaugeTitleForm.get('gaugeTitles').controls; let i = index;">
<tr [formGroupName]="i">
<td><input type="text" [value]="i+1"></td>
<td><input type="text" formControlName="name"></td>
<!-- Other fields -->
</tr>
</tbody>
Working Stackblitz
I would like to extract from a webpage some data with VBA.
This is an invoicing program and I am trying to access the first line of data which is the product description
I am not an expert is these matters, but I looked into the html code being one of the fields of data and it looks like this:
<td class="">
<div class="UITextbox length length_maximum-255" data-tag="product_code" data-ui-widget="UITextbox"><span class="field"><input autocomplete="off" id="sales_invoice_line_items_attributes_0_product_code" name="sales_invoice[line_items_attributes][0][product_code]" readonly="readonly" size="30" type="text" /></span></div>
</td>
<td class="">
<div class="UITextbox presence length length_maximum-200" data-tag="description" data-ui-widget="UITextbox"><span class="field"><input autocomplete="off" id="sales_invoice_line_items_attributes_0_description" name="sales_invoice[line_items_attributes][0][description]" size="30" type="text" /></span></div>
</td>
<td class="hidden numeric">
<div class="UIHiddenField" data-tag="item_id" data-ui-widget="UIHiddenField"><input autocomplete="off" id="sales_invoice_line_items_attributes_0_item_id" label="false" name="sales_invoice[line_items_attributes][0][item_id]" type="hidden" /></div>
</td>
<td class="numeric">
<div class="UIDecimal presence numericality numericality_greater_than_or_equal_to-0 ensurenotgreaterthanmaxnumber ensurenotgreaterthanmaxnumber_maximum-99999999" data-tag="quantity" data-ui-widget="UIDecimal"><span class="field"><input class="hidden" name="sales_invoice[line_items_attributes][0][quantity]" type="hidden" value="0.00" /><input autocomplete="off" class="visible" data-scale="2" id="sales_invoice_line_items_attributes_0_quantity" name="" size="30" type="text" value="0,00" /></span></div>
</td>
<td class="">
<div class="UIDropdown" data-tag="unit_type" data-ui-widget="UIDropdown">
<span class="field"><select autocomplete="off" id="sales_invoice_line_items_attributes_0_unit_type" name="sales_invoice[line_items_attributes][0][unit_type]">
I tried this so far with no results:
Dim desc as string
desc = ie.Document.getElementsByClassName("UITextbox presence length length_maximum-200")(0).innerText
The following code has no errors, but no value either.
There isnt any Text in the Div you are looking at:
<div class="UITextbox presence length length_maximum-200" data-tag="description" data-ui-widget="UITextbox">
<span class="field">
<input autocomplete="off" id="sales_invoice_line_items_attributes_0_description" name="sales_invoice[line_items_attributes][0][description]" size="30" type="text" />
</span>
</div>
But the Input has an ID that you can use to get the value from
desc = ie.Document.getElementByID("sales_invoice_line_items_attributes_0_description").value
Perhaps this is not the most eficient way, but I couldnt find any other way, so I just used sendkeys to simulate the keypress that adds a new record, since I could not have the fire event to work.
Thanks for your help Ricardo
IE.Document.getElementById("sales_invoice_line_items_attributes _0_description").Value ="LINE 1 DESCRIPTION"
SendKeys "-"
SendKeys "{ENTER}"
IE.Document.getElementById("sales_invoice_line_items_attributes_1_description").Value ="LINE 2 DESCRIPTION"