CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   JavaScript frameworks (http://www.codingforums.com/forumdisplay.php?f=62)
-   -   Mootools 1.1 - Help please for get element (http://www.codingforums.com/showthread.php?t=159048)

lumo 02-18-2009 09:24 AM

Mootools 1.1 - Help please for get element
 
Hi all,
I'm trying to adapt an exsisting script.
It's a "live search" module for Joomla 1.5 and I'm trying to modify to use with Virtuemart (shopping cart component)

I've got most of it to work but just can't figure how to extract the element I need.
The script makes a url call to a search script which returns the formatted results. (works fine)
The results are "set" in a hidden div. (works fine)
They are in this format...

<div id="search_tmpdiv">
<div id="vmMainPage">
<h3>Search: foo</h3>
<div id="productlist" style="width:100%; float:none;">
<div style="margin-right: 5px; width:98%; float:left;" id="row_499a94c33a84d">
<div class="browseProductContainer">
<h3 class="browseProductTitle">
<a title="food" href="/index2.php?page=shop.product_details&amp;product_id=3">food</a>
</h3>
</div>
</div>
<br class="clr" />
<div style="margin-right: 5px; width:98%; float:left;" id="row_499a94c33aa68">
<div class="browseProductContainer">
<h3 class="browseProductTitle"><a title="foot" href="/index2.php?page=shop.product_details&amp;product_id=4">foot</a>
</h3>
</div>
</div>
<br class="clr" />
<div style="margin-right: 5px; width:98%; float:left;" id="row_499a94c33acaa">
<div class="browseProductContainer">
<h3 class="browseProductTitle"><a title="fooz" href="/index2.php?page=shop.product_details&amp;product_id=5">fooz</a>
</h3>
</div>
</div>
</div>
</div>
</div>


the resulting hidden div (#search_tmpdiv) is then parsed by the following code and the results "should" display..
but what ever I try I get the result_div but without the elements parsed, e.g.


<div>Results</div>
<div class="ps_row_1">
<h3>
<a href=""></a>
<h3/>
</div>
<div class="ps_row_2">
etc
</div>
<div class="ps_row_1">
etc
</div>
</div>

The correct number of rows are returned for the appropriate results so the logic is working but no matter what I try it doesn't pick up the wanted elements.
The script is as follows

result_div.addClass('ps_results');

search_res = $$('#search_tmpdiv .browseProductContainer');
if(search_res.length > 0) search_res.each(function(res) {
x +=1;
var res_data='';
res_data=res.getChildren();
if(res_data.length > 0){
res_data.each(function(r) {
if(r.getTag() == "div"){
if(r.getChildren().length > 2){
var suri=r.getFirst().getNext().getProperty('href');
if(row == "ps_row_2") row = "ps_row_1";
else row = "ps_row_2";
var el = new Element('div', {'class': row });
var link = new Element('a').setProperty('href',suri).injectInside(el);
var name = new Element('h3').setHTML(r.getFirst().getNext().getText()).injectInside(link);
el.inject(result_div);
}
}
});


I assume my mistake s in the line "var suri=r.getFirst().getNext().getProperty('href');" ?

Any help gratefully accepted
Cheers,
Lumo


All times are GMT +1. The time now is 06:13 PM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.