Where #filter_chemistry is a form text field, and the td's
with the polymerTypel class will contain a list of items similar
to st,ac,bde,va for example.
If I enter "ac" into my text box, all table rows NOT
containing ac in the list will be correctly hidden, all good so far.
What I want is to be able to enter ac,va into the text box and have
both of these items required, but not in any specific order or location.
I assume some sort of
$("#filter_chemistry").val().split(",") will be
required to create an array but it is beyond me. Can anyone help please?
I am using some URL parameters in my jQuery and have come across a bug.
Since JS is not my primary (or even secondary if I'm honest)
language I am at a loss to know why.
I have the following function.
function urlParam(name){
var results = new RegExp('[\?&]' + name + '=([^&#]*)').exec(window.location.href);
if (results == null) {
return null;
}
else {
return results[1] || 0;
}
};
I then call this with the following lines (much reduced for debugging)...
var
urlProduct = urlParam('product');
if
(urlProduct != null) {
alert(urlProduct);
};
if I go to http://mysite/dir/?product=xxx then all seems to work
unless the string xxx contains a lower-case a, m or p. any of these
3 letters will interrupt the string so...
"?product=123a456" will be "123"
but
"?product=123b456" will correctly return "123b456"
As far as I can tell it is only these 3 letters, upper-case works
fine so 123A456 will work. It also make no diference where in the
string they occur.
I assume the issue is being caused by some faulty regex,
specifically in this bit...
'=([^&#]*)'
but can someone with more knowledge than help me fix it?
To set the form field to the clicked value and focus the field. As I understand it the .val() won't work here, but will anything else? Can I even select the "1234" without it being in a form field?