HTML text field not displaying decimal places of SQL money value - sql

I have a text field who's value is populated from a SQL recordset (below).
<input name="txtAmount" id="txtAmount" type="text" size="10" maxlength="10" value="<%=RS("Amount")%>">
In the SQL table, the Amount field (which is a money data type) is inserted correctly, as 5.00 However, in the web page, it displays only as 5 (i.e. the decimal places are missing). Anyone know why this might be and how I can get the decimal places to display in the field? Thanks!

If you don't want the dollar sign, use
value="<%=FormatNumber(RS("Amount"),2)%>"

Applying formating will do the trick:
<input name="txtAmount" id="txtAmount" type="text" size="10" maxlength="10"
value="<%=FormatCurrency(RS("Amount"), 2)%>">

If your code is in .NET, you can use
<%= String.Format("{0:0.00}", RS("Amount")) %>

Related

How to use scriptAll to grab all values when the intended value is not text type

I have a page with multiple textboxes and dropdowns with values that I am trying to validate. The values in them will be dynamic in each run.
The HTML looks something like:
<input readonly="readonly" class="form-control valid" data-val="true" data="ABC" aria-invalid="false" xpath="1">
What I want to do is grab the value of "data" for each textbox. I have used scriptAll before in such a case when I was grabbing text by using innerText. However, that won't work with a regular value such as in the HTML above.
I did try one solution that worked:
driver.value(//input[#data])
However, that just grabs the first textbox value, is there a way I can combine scriptAll with driver.value? OR would I be better off doing some JS here?
Thank you in advance!
Yes, refer the docs for scriptAll(): https://github.com/karatelabs/karate/tree/master/karate-core#scriptall
Use whatever JS works to get an attribute value. Haven't tried, but this should work, you get the idea:
* def list = scriptAll('input', "_.getAttribute('data')")

Get selected content in a number input when click

I guess is not too much difficult but your help will be useful as always.
I had before a text input where the user if click in it select all the content from this input to be able to replace faster his content like in the next example:
<input type="text" value="whatever" onclick="this.setSelectionRange(0, this.value.length)">
So, my question will be, how can I do the same behaviour in a numeric input like the next one?
<input type="number" value="1111">
I tried to add obviously this onclick="this.setSelectionRange(0, this.value.length)" but seems only to work on the text inputs.
Actually, was easy.
I found this solution that works good.
<input type="number" value="111" onclick="this.select();">

Full Text search using oracle regex

I am trying to use regexp_like() in oracle 11g to achieve text search.
for example I have a table called posts where in title column if I have values
'How to create a new post with pictures and videos'
'How to create a new post enter code here'
and if I write a query
select * from posts where regexp_like(title, '.*pictures.*|.*how.*|.*post.*', 'i')
It returns records having both titles where the second value does not have word pictures in it. I know its because I user '|' in the expression.
What I want to achieve is It should return records only if all the words are present in the column in any order. Help me with the regex please
Hope this will help you.
I wrote a plunker in AngularJS. It is just to demonstrate how the regular expression works.
http://plnkr.co/edit/6WrCCAfNwidVxKkRFH9l?p=preview
The regular expression you can use is
/^(?=.(pictures))(?=.(post))(?=.*(how))[a-zA-Z ]{1,100}$/
This means pictures, post, how should be there in the given paragraph.
You can adjust the length of the paragrah as per your requirement.
<form role="form" name="myform">
<div>
<div class="col-sm-8">
<input type="text" ng-model="user" name="inputfield" required="true" ng-pattern="/^(?=.*(pictures))(?=.*(post))(?=.*(how))[a-zA-Z ]{1,100}$/">
<span ng-show="myform.inputfield.$dirty && !myform.inputfield.$error.required && myform.inputfield.$error.pattern">
<small class="text-danger">
Not Matching
</small>
</span>
</div>
</div>
</form>

Change maxlength based on name="..." Possible?

I'll admit, I'm new to this world. Im working on my first site, which has a template file setup. In the template I have a code thats similar to
<input type="text" name="option[**]"/>
Where Option[**] is pulled from somewhere else, heres my issue;
Is there something I can do to limit the text input length based on the option number pulled? I did a
<input maxlength=10 type="text" name="option[**]"/>
and that worked to limit all my text input boxes there to 10, however I have say Option[1] and option[2]; I want 1 limited to 10 and 2 limited to 15. is this possible? remember, Im new to all this :)

Setting Date text object with correct formatting string

I can not figure out the secret format string to get my time displayed into a time text box. The time is stored in the database in this format '10:30 AM' DeliveryTime is defined as a string in the database. I have tried various versions similar to this below to no avail. Please help.
<input type="time" id="DeliveryTime" name="DeliveryTime" class="form-control" value="#Model.DeliveryTime.ToString("hh:mm tt")">
Looking at the format of the value in the database (10:30 AM) and the format you are trying to use: hh:mm tt, they are the same.. so all you need to do is display it directly:
<input type="time" id="DeliveryTime" name="DeliveryTime" class="form-control" value="#Model.DeliveryTime">
Or am I missing something here?