Help with jquery to modify SCC

User 2062767 Photo


Registered User
166 posts

Hi,
Can anyone help with this please?

As it is looking unlikely that there will be any updates on SCC I have decided to modify it myself using jquery. So far so good. :D See some on the results here http://www.woodentopstoys.co.uk/shop/viewcategory.php?groupid=344
Click on a "Get it fast" then an "Order Now" item & see what happens. ;) (I have 2 sites running back to back - 1 with "instock" items & the other with "order only items". I have also used jquery to make my site responsive. (Still some work to do!)

Although I am stuck on this:-
I want to add the relevant url to "scs_stocksold" classes.
This is my code so far-
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script>
$(document).ready(function(){

href = ($(".scs_thumbnail_wrapper a").attr("href"));

$(".scs_productlist_item .scs_stocksold").prepend(" <a href='"+href+"'><img src=' '></img></a>");
$(".scs_stocksold img").attr("src", "../images/any_image.png");
});
</script>

The problem with this is it places the first url in ALL .scs_stocksold. I have tried .parent, .siblings, .children & also loop (i = 0; i< x.length; i++) but none work. How do I get just the url from each "scs_productlist_item" class?
www.heylisflorist.co.uk - My Florist Shop.
www.woodentopstoys.co.uk - My Wooden Toy Shop.

I use CoffeeCup HTML Editor, WIS, Direct ftp, Sitemapper, Website Insite & RED Personal to create my websites.

Send your parcels with Despatch Bay! Signup using this code and get £10.00 worth of free shipping http://despatchbaypro.com/s/1H431
User 187934 Photo


Senior Advisor
18,074 posts

Hi Sue,
Take a look at using first() or next()
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

Here's my S-Drive site with
examples of what can be accomplished in VSD.
http://progrower.coffeecup.com/
Here's my CoffeeCup SCCP Shop with examples of what can be done.
http://progrower.coffeecup.com/shop/
This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personnel site used for testing and as an easy way to share photos.(RLM imported to RSD)
http://ericrohloff.com
http://ericrohloff.com/property/
User 2062767 Photo


Registered User
166 posts

Thanks Eric,
But tried href = ($(".scs_thumbnail_wrapper:first a").attr("href")); - still brings up the first url to all .scs_stocksold classes.
next did'nt work at all.
I want the 1st .scs_thumbnail_wrapper href to the 1st .scs_stocksold
& the 2nd .scs_thumbnail_wrapper href to the 2nd .scs_stocksold & so on.
Not the 1st href to all!
www.heylisflorist.co.uk - My Florist Shop.
www.woodentopstoys.co.uk - My Wooden Toy Shop.

I use CoffeeCup HTML Editor, WIS, Direct ftp, Sitemapper, Website Insite & RED Personal to create my websites.

Send your parcels with Despatch Bay! Signup using this code and get £10.00 worth of free shipping http://despatchbaypro.com/s/1H431
User 187934 Photo


Senior Advisor
18,074 posts

Ok Gotcha
You need an each function. ;)
$(".scs_thumbnail_wrapper").each(function(){
href = ($(this).find("a").attr("href"));

$(".scs_productlist_item .scs_stocksold").prepend(" <a href='"+href+"'><img src=' '></img></a>");
$(".scs_stocksold img").attr("src", "../images/any_image.png");

});
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

Here's my S-Drive site with
examples of what can be accomplished in VSD.
http://progrower.coffeecup.com/
Here's my CoffeeCup SCCP Shop with examples of what can be done.
http://progrower.coffeecup.com/shop/
This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personnel site used for testing and as an easy way to share photos.(RLM imported to RSD)
http://ericrohloff.com
http://ericrohloff.com/property/
User 2062767 Photo


Registered User
166 posts

Oh! thought we were there then.
That has the opposite effect :lol: it returns ALL href's into each scs_stocksold class.
Result:
<div class="scs_stocksold">
<a href="viewitem.php?productid=919">
<img src="../images/any_image.png">
</a> <a href="viewitem.php?productid=8429">
<img src="../images/any_image.png">
</a> <a href="viewitem.php?productid=10919">
<img src="../images/any_image.png">
</a>
<span class="scs_sdkworkaround">&nbsp;</span>
</div>
www.heylisflorist.co.uk - My Florist Shop.
www.woodentopstoys.co.uk - My Wooden Toy Shop.

I use CoffeeCup HTML Editor, WIS, Direct ftp, Sitemapper, Website Insite & RED Personal to create my websites.

Send your parcels with Despatch Bay! Signup using this code and get £10.00 worth of free shipping http://despatchbaypro.com/s/1H431
User 187934 Photo


Senior Advisor
18,074 posts

Oops.:lol:
$(".scs_thumbnail_wrapper").each(function(){
href = ($(this).find("a").attr("href"));

$(this, ".scs_productlist_item .scs_stocksold").prepend(" <a href='"+href+"'><img src=' '></img></a>");
$(".scs_stocksold img").attr("src", "../images/any_image.png");

});
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

Here's my S-Drive site with
examples of what can be accomplished in VSD.
http://progrower.coffeecup.com/
Here's my CoffeeCup SCCP Shop with examples of what can be done.
http://progrower.coffeecup.com/shop/
This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personnel site used for testing and as an easy way to share photos.(RLM imported to RSD)
http://ericrohloff.com
http://ericrohloff.com/property/
User 2062767 Photo


Registered User
166 posts

Nothing at all that time, must be an error in there somewhere :/
www.heylisflorist.co.uk - My Florist Shop.
www.woodentopstoys.co.uk - My Wooden Toy Shop.

I use CoffeeCup HTML Editor, WIS, Direct ftp, Sitemapper, Website Insite & RED Personal to create my websites.

Send your parcels with Despatch Bay! Signup using this code and get £10.00 worth of free shipping http://despatchbaypro.com/s/1H431
User 187934 Photo


Senior Advisor
18,074 posts

It' seems to work on the html that I copied from your page but not totally sure.
Are you testing on the page you linked to or a test page?
Here's my complete test code.
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script>
$(document).ready(function(){

$(".scs_thumbnail_wrapper").each(function(){
href = ($(this).find("a").attr("href"));

$(this, ".scs_productlist_item .scs_stocksold").prepend(" <a href='"+href+"'><img src=' '></img></a>");
$(".scs_stocksold img").attr("src", "../images/any_image.png");
alert(href);
});

});
</script>
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

Here's my S-Drive site with
examples of what can be accomplished in VSD.
http://progrower.coffeecup.com/
Here's my CoffeeCup SCCP Shop with examples of what can be done.
http://progrower.coffeecup.com/shop/
This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personnel site used for testing and as an easy way to share photos.(RLM imported to RSD)
http://ericrohloff.com
http://ericrohloff.com/property/
User 2062767 Photo


Registered User
166 posts

Not for me, I don't need the alert & it doesn't work without it. The alert is bringing up all href's, I only need those parent elements that have a scs_stocksold in them.
I have attached a copy of my original test file so you can play with it further.
Remember -
I want the 1st .scs_thumbnail_wrapper href to the 1st .scs_stocksold
& the 2nd .scs_thumbnail_wrapper href to the 2nd .scs_stocksold & so on.
Not the 1st href to all!

I was testing by right clicking & inspecting the live page.
I have had to save as a txt document for upload purposes.
Attachments:
www.heylisflorist.co.uk - My Florist Shop.
www.woodentopstoys.co.uk - My Wooden Toy Shop.

I use CoffeeCup HTML Editor, WIS, Direct ftp, Sitemapper, Website Insite & RED Personal to create my websites.

Send your parcels with Despatch Bay! Signup using this code and get £10.00 worth of free shipping http://despatchbaypro.com/s/1H431
User 187934 Photo


Senior Advisor
18,074 posts

The alert is only for testing to show the variables are being set. You can comment it out or delete it.
Let me look at the html more as I think I have an Idea of what your actually doing now after further explanation.
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

Here's my S-Drive site with
examples of what can be accomplished in VSD.
http://progrower.coffeecup.com/
Here's my CoffeeCup SCCP Shop with examples of what can be done.
http://progrower.coffeecup.com/shop/
This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personnel site used for testing and as an easy way to share photos.(RLM imported to RSD)
http://ericrohloff.com
http://ericrohloff.com/property/

Have something to add? We’d love to hear it!
You must have an account to participate. Please Sign In Here, then join the conversation.