/    Sign up×
Community /Pin to ProfileBookmark

need helping assigning value to javascript variable using javascript

I am using a review program that requires that I use their javascript for purposes of displaying the review info for a product. I have a tabbed interface where I have one tab set to “customer reviews” . I need to assign the link value I have referenced below to their pr_read_review variable for their “read reviews” link to select the proper tab.
I do not know the proper syntax to assign a value within javascript based on a javascript function. My test link below gives me the desired result but I cannot determine how to incorporate that into their code (and thus far they have been of little help). Does anyone know the proper way to get the desired result?

This is my test page if you need to view the source – [url]http://www.petcratesdirect.com/dog-crates-icrates2.html[/url]

script type=”text/javascript”>POWERREVIEWS.display.snippet(document, { pr_page_id : “icrate 1500″, pr_read_review : link below needs to be here” });</script>

<a href=”javascript:void(0)”
onclick=”document.getElementById(‘producttabs’).tabber.tabShow(5)”)>Test
link</a>

Thanks,
Lori

to post a comment
JavaScript

12 Comments(s)

Copy linkTweet thisAlerts:
@merryseekerauthorAug 25.2009 — missed the beginning quote in the link below needs to be here -

script type="text/javascript">POWERREVIEWS.display.snippet(document, { pr_page_id : "icrate 1500", pr_read_review : "link below needs to be here" });</script>
Copy linkTweet thisAlerts:
@justinbarneskinAug 26.2009 — Very confusing.

So, you can edit the HTML but only have access to view their .js

and then call their functions and set their variables with onclick events?

If I'm correct in this assumption, we may be able to help.
Copy linkTweet thisAlerts:
@merryseekerauthorAug 26.2009 — the review program normally uses base HREF of a product page and appends an HTML anchor in order to scroll the page down to the Review Display (a separate snippet of javascript that I insert into the html where I want the reviews to be displayed - in this case <div class="tabbertab" title="customer reviews">). Because I am using tabs this does not work as intended since that section of the html page is in a tab div and their link cannot "select" the tab.They indicated that I can explicitly define a Read Review link on the product page by adding the pr_read_review : variable to their code - see example below.

[CODE]div class="pr_snippet_product">
<script type="text/javascript">
POWERREVIEWS.display.snippet(document, {
pr_page_id : "icrate 1500",
pr_read_review : "http://www.petcratesdirect.com/dog-crates-icrates.html#ReviewHeader"
});
</script>
</div>[/CODE]


The only way that I could find to explicitly define the link to select the proper tab is by using this code

[CODE]<a href="javascript:void(0)"
onclick="document.getElementById('producttabs').tabber.tabShow(5)")>Test
link</a> [/CODE]


thus I need to determine if I can insert the above code (minus the a href open/close which is supplied by their script) into their script between the " " for the pr_read_review variable.

Basically, the desired result is that I need to have their "read reviews" link point to the place that my manual test link does - see the test page - http://www.petcratesdirect.com/dog-crates-icrates2.html

I don't care how I get there so if there is another solution that is easier to implement that would be fine.

Thanks for your input,

Lori
Copy linkTweet thisAlerts:
@justinbarneskinAug 26.2009 — Have you look at other similar pages by others, to see how they did it, is that possible?
Copy linkTweet thisAlerts:
@merryseekerauthorAug 26.2009 — well both staples.com and rei.com use the same review program and they have it working like I need....but I looked at their view source and there is way too much going on there for me to decipher. I really know very little about javascript and you can probably tell from the view source on my page that I keep things pretty basic. Here are a couple of links to some of their pages with reviews. If you know javascript, perhaps you can view these and more easily decipher how they dealt with it.

http://www.staples.com/Pentel-Twist-Erase-III-Automatic-Pencils-.5mm-Assorted-Colors-2-Pack/product-nr_434347?cmArea=HOMEPAGE

http://www.rei.com/product/70762
Copy linkTweet thisAlerts:
@justinbarneskinAug 26.2009 — Lets review,

From the test link you gave at your first post, I see tabs half way down the page.

I click them and get expected results. (I need to understand the problem when I don't see evidence of one)

You can feel smug tho,, the staples page fails in more ways than one.

I like the rei page, its clean and fast. I've felt comfortable shopping with them.

I'm afraid this has become too cluttered for anyone. Solving code & rewriting code is one thing but I can't say I even savvy the problem as yet. Would you mind taking a time out and then, try to present the problem more succinctly and, don't add any extra clues.
Copy linkTweet thisAlerts:
@merryseekerauthorAug 26.2009 — on my test page you will see the product rating section just below the add to cart button. the two links below the stars (write a review and read 6 reviews) are generated by the powerreviews code. Note that just below their two links I have inserted my own link (test link). Click my test link and it opens the appropriate customer reviews tab below where the reviews are shown. However, if you click their read 6 reviews link you do not go to the tab. At present you'll just get a page not found because I have inserted the words "insert link here" into the place where I need in supply the information for it to work properly. So, I need to insert the code from my working test link into that place in their code to control their read 6 reviews link.
Copy linkTweet thisAlerts:
@justinbarneskinAug 26.2009 — There are two external .js scripts where to find the workings of this-

POWERREVIEWS.display.snippet(document, { pr_page_id : "icrate 1500", pr_read_review : link below needs to be here" });

I see your masters have conveniently made those pages difficult to decipher.

Sorry, i will not work with those unhelpful monsters. I apologize for wasting your time,

I'm cutting the line you hoped would save you.

Please abandon this thread and find new hope by posting on a fresh new heading.
Copy linkTweet thisAlerts:
@justinbarneskinAug 26.2009 — One last chance.

Clicking directly on the tab "customer reviews" achieves what you wish to do with the link?

Why not clone the code from that div?
Copy linkTweet thisAlerts:
@merryseekerauthorAug 26.2009 — I still need to have their code there so that the product rating stars appear along with the write a review link. Cloning from my tab div which is controlled by a javascript would again, require that I insert javascript within javascript so shouldn't be any different from trying to insert my javascript link.

My next best attempt will be to determine if I can somehow hide the visability of their pr_read_review variable while keeping the remainder (stars and write review)of that script intact. Then I could use my link directly below that and it would look the same as if theirs actually worked.

Thanks for your help anyway.
Copy linkTweet thisAlerts:
@merryseekerauthorAug 26.2009 — sometimes the easiest solution isn't the most apparent. After poking around in the full.js file from powerreviews, I was able to determine that they assign a class of prSnippetLink to the read reviews link. So I set display for that class to :none in my style sheet and have achieved the desired result.
×

Success!

Help @merryseeker spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.6,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...