Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-18-2009, 09:24 AM   PM User | #1
lumo
New to the CF scene

 
Join Date: Feb 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
lumo is an unknown quantity at this point
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
lumo is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:54 AM.


Advertisement
Log in to turn off these ads.