I am working with the autosuggest attribute of cfinput.
But I am not 100% satisfied with how it works.
Here's a little bit of the code :
<cfinput id=""town" name="town" type="text" class="form-control" autosuggest="cfc:bind.gettown({cfautosuggestvalue})" showautosuggestloadingicon="false>
This control suggests all of the towns with the cfautosuggestvalue in it.
Ex: if it contains "lu", it should show all the cities containing this string, like: Luxembourg or Saint Jean-de-Luz
But it is only showing Luxembourg ...
I checked my request bind.gettown and it gives me those 2 cities, but I guess that the ColdFusion's autosuggest filters my initial request by removing all the string not starting by 'lu' ... and as you can guess this is a problem.
So my point is to show all the cities containing 'lu' ...
Can you help me?
Related
I am working on an Angular app that displays selected Country codes in a text field. This input displays Country codes because of space constraints:
<input type="button" #countryListTrigger matInput readonly i18n-placeholder placeholder="COUNTRIES" [ngModel]="selectedCountries" />
Here's what the control looks like with Country codes displayed:
Countries Widget
Right now, screen readers would read the AU like the letter "o" and AT like "#". I know about the tag, but is there a way to achieve the same result on an input value? Otherwise, I could add another (hidden) control that is read instead perhaps?
It starts getting messy if you try to force a screen reader to announce things phonetically. If you add an aria-label that has aria-label="A U" or aria-label="A T", then braille users will be out of luck because they'll read "A space U".
It's unfortunate there isn't really a good solution for this. The screen reader user can read the input value one character at a time so if it sounds weird to them, they have a work around. It's not a great user experience but having screen readers mispronounce stuff has been a problem for a long time.
I have been working on a small simple project on localhost for a client, it's a comment system with a filter.
But whenever I try to add the filter, it seems to get stuck on it's first word. I've been trying to search the answer on Google for almost 8 hours now, before posting here.
It's a simple query, no complex things. But anyone got any suggestions? I tried the # and cfloop, cfoutput, cfquery, etc. but nothing seems to work.
<cfquery name = "communityFilter" datasource = "#DSN#">
SELECT *
FROM cms_filter
</cfquery>
<!-- Query van de filter -->
<cfif form.comment CONTAINS communityFilter.word>
Word gevonden!
<cfelseif NOT form.comment CONTAINS communityFilter.word>
Geen word gevonden, system werkt =)
</cfif>
The system needs to take the word that is not allowed out of the database, but it keeps saying Word found while it's not found.
When you refer to a query result, you should specify the row number like this:
queryname.fieldname[rownumber]
If you don't you get the value from the first row. That's what is happening to you. While the comment might contain a bad word, you are not looking at all the available bad words. I suggest something like this.
commentHasBadWord = false;
for (badWord in ValueList(cms_filter.word)) {
if (commentHasBadWord == false && form.comment contains badWord)
commentHasBadWord = true;
else
break;
}
if commentHasBadWord == true;
//code for bad comment
else
// code for good comment
I have posted my HTML below. In which I want to get the name value from within my textbox area. I've tried several processes and I'm still not getting any valid solution. Please check my HTML and code snippet, and show me a possible solution.
The name prefix will always stay the same when I refresh the page. However, the last name within the "name" area will change, but will always contain the literal "mr." as the first 3 digits. regex as ([mM]r.\ ) - Four digits if you consider the literal space. Below is my table example.
<table>
<tr><td><b>Your Name is </b> mr. kamrul</td></tr>
<tr><td><b>your age </b> 12</td></tr>
<tr><td><b>Email:</b>kennethdasma30#gmail.com</td></tr>
<tr><td><b>job title</b> sales man</td></tr>
</table>
As shown below I am trying this process using listbox but I am not receiving anything.
HtmlElementCollection bColl =
webBrowser1.Document.GetElementsByTagName("table");
foreach (HtmlElement bEl in bColl)
{
if (bEl.GetAttribute("table") != null)
{
listBox1.Items.Add(bEl.GetAttribute("table"));
}
}
If anyone ca give me an idea of how I am able to receive all in the browser window as ("mr. " + text) within my list box I would appreciate it. Also, if you can explain the answer verbosely and with good comments I would appreciate it, as I'd like to understand the answer in greater detail as well.
Here is one simple way using Regex, assuming that the format of your html page doesn't change.
Regex re = new Regex(#"(?<=<tr><td><b>Your\sName\sis\s?</b>\s?)[mM]r\.\s.+?(?=</td></tr>)", RegexOptions.Singleline);
foreach (Match match in re.Matches(webBrowser1.DocumentText))
{
listBox1.Items.Add(match.Value);
}
I have multiple input fields with one id specification, but they have different attributes. I can find them just fine, but am having trouble figuring out how to use the fill_in with the find appropriately. Currently I have:
find('//input[#id="specification"][#data-number="1"]').fill_in with: "This first sleeping bag should be 0 degrees F"
Error-- Capybara::Webkit::InvalidResponseError:SYNTAX_ERR: DOM Exception 12
Thanks!
The first is that fill_in will look for a text field within the element returned by find. Basically you are asking Capybara to find something like:
<input id="specification" data-number="1">
<input type="text">
</input>
This is unlikely to exist.
Given that you have already found the text field using find, you want to use the set method to input it:
find('//input[#id="specification"][#data-number="1"]').set("This first sleeping bag should be 0 degrees F")
Assuming you have not changed the default_selector to :xpath, the above will still fail due to the expression not being a valid CSS-selector. You need to also tell Capybara that an :xpath locator is being used:
find(:xpath, '//input[#id="specification"][#data-number="1"]').set("This first sleeping bag should be 0 degrees F")
It's not valid HTML to have multiple elements with the same id. You should start by changing that.
Given the following HTML:
<p><span class="xn-location">OAK RIDGE, N.J.</span>, <span class="xn-chron">March 16, 2011</span> /PRNewswire/ -- Lakeland Bancorp, Inc. (Nasdaq: <a href='http://studio-5.financialcontent.com/prnews?Page=Quote&Ticker=LBAI' target='_blank' title='LBAI'> LBAI</a>), the holding company for Lakeland Bank, today announced that it redeemed <span class="xn-money">$20 million</span> of the Company's outstanding <span class="xn-money">$39 million</span> in Fixed Rate Cumulative Perpetual Preferred Stock, Series A that was issued to the U.S. Department of the Treasury under the Capital Purchase Program on <span class="xn-chron">February 6, 2009</span>, thereby reducing Treasury's investment in the Preferred Stock to <span class="xn-money">$19 million</span>. The Company paid approximately <span class="xn-money">$20.1 million</span> to the Treasury to repurchase the Preferred Stock, which included payment for accrued and unpaid dividends for the shares. This second repayment, or redemption, of Preferred Stock will result in annualized savings of <span class="xn-money">$1.2 million</span> due to the elimination of the associated preferred dividends and related discount accretion. A one-time, non-cash charge of <span class="xn-money">$745 thousand</span> will be incurred in the first quarter of 2011 due to the acceleration of the Preferred Stock discount accretion. The warrant previously issued to the Treasury to purchase 997,049 shares of common stock at an exercise price of <span class="xn-money">$8.88</span>, adjusted for stock dividends and subject to further anti-dilution adjustments, will remain outstanding.</p>
I'd like to get the values inside the <span> elements. I'd also like to get the value of the class attribute on the <span> elements.
Ideally I could just run some HTML through a function and get back a dictionary of extracted entities (based on the <span> parsing defined above).
The above code is a snippet from a larger source HTML file, which fails to pare with an XML parser. So I'm looking for a possible regular expression to help extract the information of interest.
Use this tool (free):
http://www.radsoftware.com.au/regexdesigner/
Use this Regex:
"<span[^>]*>(.*?)</span>"
The values in Group 1 (for each match) will be the text that you need.
In C# it will look like:
Regex regex = new Regex("<span[^>]*>(.*?)</span>");
string toMatch = "<span class=\"ajjsjs\">Some text</span>";
if (regex.IsMatch(toMatch))
{
MatchCollection collection = regex.Matches(toMatch);
foreach (Match m in collection)
{
string val = m.Groups[1].Value;
//Do something with the value
}
}
Ammended to answer comment:
Regex regex = new Regex("<span class=\"(.*?)\">(.*?)</span>");
string toMatch = "<span class=\"ajjsjs\">Some text</span>";
if (regex.IsMatch(toMatch))
{
MatchCollection collection = regex.Matches(toMatch);
foreach (Match m in collection)
{
string class = m.Groups[1].Value;
string val = m.Groups[2].Value;
//Do something with the class and value
}
}
Assuming that you have no nested span tags, the following should work:
/<span(?:[^>]+class=\"(.*?)\"[^>]*)?>(.*?)<\/span>/
I only did some basic testing on it, but it'll match the class of the span tag (if it exists) along with the data until the tag is closed.
I strongly advise you to use a real HTML or XML parser for this instead. You cannot reliably parse HTML or XML with regular expressions--the most you can do is come close, and the closer you get, the more convoluted and time-consuming your regex will be. If you have a large HTML file to parse, it's highly likely to break any simple regex pattern.
Regex like <span[^>]*>(.*?)</span> will work on your example, but there's a LOT of XML-valid code that's difficult or even impossible to parse with regex (for example, <span>foo <span>bar</span></span> will break the above pattern). If you want something that's going to work on other HTML samples, regex isn't the way to go here.
Since your HTML code isn't XML-valid, consider the HTML Agility Pack, which I've heard is very good.