Here i my for-each line: <xsl:for-each select="umbraco.library:GetXmlNodeById(1168)/descendant-or-self::*//Product [@isDoc][wwtype/MultiNodePicker/nodeId=$type and wwtotalvaegt/MultiNodePicker/nodeId=$totalvaegt and wwstorrelse/MultiNodePicker/nodeId=$lenght and wwaklser/MultiNodePicker/nodeId=$aksler]">
Using and to build the query, you will only get a result if all four selects match a value on a specific node (which you may of course be very well aware of - just making sure that's the intended behavior :-)
The "length" parameter is spelled "lenght" - it's consistent, so as long as the form input's name attribute is also spelled like that, it should work. (And if it isn't, that could very well be the problem you're not seeing any results).
One way to debug this would be to use individual results, like this:
I want to count number of products that's found. The count is coming from another page and i use Ajax to get it.
This is my count: <xsl:value-of select="count(msxml:node-set($products [@id = $productsByType/@id] [@id = $productsByWeight/@id] [@id = $productsBySize/@id] [@id = $productsByAxels/@id]))"/> But it returs 0 no matter what I'm searching for - and that's not right.
If I change the count to this: <xsl:value-of select="count(msxml:node-set($productsByType | $productsByWeight | $productsBySize | $productsByAxels)"/> it's counting, but I need a count if all four variables are true.
Here's my ajax:
$('#aksler').on('change', function () {
var postData = $(this).serializeArray();
var formURL = "/counttrailers.aspx";
$.ajax({
url: formURL,
type: "POST",
data: postData,
success: function (data, textStatus, jqXHR) {
$("#result").html(data);
},
error: function (jqXHR, textStatus, errorThrown) {}
The node-set() was just for trying. It made no difference for the outcome.
The problem is that this line: count($products[@id = $productsByType/@id][@id = $productsByWeight/@id][@id = $productsBySize/@id][@id = $productsByAxels/@id]) - returns 0 when the result comes from my ajax call and I've checked that there is product that fits my search.
I can't see that my ajax call is wrong, but mabye I'm missing something.
If you just do <xsl:value-of select="count($productsByType | $productsByWeight | $productsBySize | $productsByAxels)" /> you get a number, if I understand correct?
This is the total number of nodes matched - so even if the same node exist in all of the variables, it will only count as one.
Also, if you're getting a number from that count, it's highly likely that there is in fact no node(s) that matches all of them, so you should try to debug, by listing the nodes of each variable then:
Make a search string using RequestFrom
Hi.
I'm trying to make a page to show some results after a visitor hit submit.
My form is a simple form with 4 selects and method is post.
But when I try to show the result nothing shows.
I'm using 4 variables and they contain right data based on the selects, and the values from the selects are ID's.<
Variables:
<xsl:variable name="type" select="umbraco.library:RequestForm('type')"/>
<xsl:variable name="totalvaegt" select="umbraco.library:RequestForm('totalweight')"/>
<xsl:variable name="lenght" select="umbraco.library:RequestForm('lenght')"/>
<xsl:variable name="aksler" select="umbraco.library:RequestForm('aksler')"/>
Here i my for-each line:
<xsl:for-each select="umbraco.library:GetXmlNodeById(1168)/descendant-or-self::*//Product [@isDoc][wwtype/MultiNodePicker/nodeId=$type and wwtotalvaegt/MultiNodePicker/nodeId=$totalvaegt and wwstorrelse/MultiNodePicker/nodeId=$lenght and wwaklser/MultiNodePicker/nodeId=$aksler]">
Does any one have a clue?
/Palle
Hi Palle,
Using and to build the query, you will only get a result if all four selects match a value on a specific node (which you may of course be very well aware of - just making sure that's the intended behavior :-)
The "length" parameter is spelled "lenght" - it's consistent, so as long as the form input's name attribute is also spelled like that, it should work. (And if it isn't, that could very well be the problem you're not seeing any results).
One way to debug this would be to use individual results, like this:
This way, you'll get results for those that work - and you'll be able to see where the results differ from what you expect...
/Chriztian
Hi Chriztian.
Thanks for your reply.
I need all four varibles to be true to show a product.
Should I replace | with anything else to do that, or is it the same as and?
Hi Palle,
No - the pipe is used for joining nodesets, but now that you have the individual sets you can try this:
(Picking any product that also exists in all of the specific sets)
BTW: I just noticed that the wwaklser property is misspelled (should be wwaksler, right?) in the queries - is that the way its alias is spelled?
/Chriztian
Works like a charm.
Thanks
/Palle
Hi Chriztian.
Got one more, if it's okay.
I want to count number of products that's found. The count is coming from another page and i use Ajax to get it.
This is my count:
<xsl:value-of select="count(msxml:node-set($products [@id = $productsByType/@id] [@id = $productsByWeight/@id] [@id = $productsBySize/@id] [@id = $productsByAxels/@id]))"/>
But it returs 0 no matter what I'm searching for - and that's not right.
If I change the count to this:
<xsl:value-of select="count(msxml:node-set($productsByType | $productsByWeight | $productsBySize | $productsByAxels)"/>
it's counting, but I need a count if all four variables are true.
Here's my ajax:
$('#aksler').on('change', function () {
var postData = $(this).serializeArray();
var formURL = "/counttrailers.aspx";
$.ajax({
url: formURL,
type: "POST",
data: postData,
success: function (data, textStatus, jqXHR) {
$("#result").html(data);
},
error: function (jqXHR, textStatus, errorThrown) {}
});
});
Can you see what I'm missing?
/Palle
Hi Palle,
If you're using my other code from earlier, there's no need to use the
node-set()
function - just counting the nodes in the combined set should do it:Any particular reason for having thrown the node-set function in there?
/Chriztian
Hi Chriztian.
The node-set() was just for trying. It made no difference for the outcome.
The problem is that this line: count($products[@id = $productsByType/@id][@id = $productsByWeight/@id][@id = $productsBySize/@id][@id = $productsByAxels/@id]) - returns 0 when the result comes from my ajax call and I've checked that there is product that fits my search.
I can't see that my ajax call is wrong, but mabye I'm missing something.
/Palle
Hi Palle,
If you just do
<xsl:value-of select="count($productsByType | $productsByWeight | $productsBySize | $productsByAxels)" />
you get a number, if I understand correct?This is the total number of nodes matched - so even if the same node exist in all of the variables, it will only count as one.
Also, if you're getting a number from that count, it's highly likely that there is in fact no node(s) that matches all of them, so you should try to debug, by listing the nodes of each variable then:
This should let you inspect the contents and see if you're getting what you expect.
/Chriztian
is working on a reply...