Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Javascript Conflicting error on wordpress website

Status
Not open for further replies.

codylegge

Technical User
May 23, 2020
1
CA
Dear support community!

I am wondering if anyone may know a quick fix to this issue.
Right now while applying a single java script to a WordPress block its working fine.

Once adding a second widget with similar code then it’s causing some type of conflict with the first one.. perhaps this may be because they are using the same name or sharing some type of information.

I’ll post both code snippets below & you may know a way to completely separate them so they do not recognize each-other and conflict.

These are “buy now” Java script buttons from Xsolla & they each have different values, i need to add a total of 10 – 12 but right now I cannot add more then one without some type of conflict.

Code 1:
<div id=”XS-pay2play-widget”></div> <script> var options = { access_token: “9upbu4RrjLChk8PgP42n5LqSmqANijKY”, theme : { foreground: “green”, background: “dark” }, lightbox: { height: “700px”, spinner: “round” }, target_element: “#XS-pay2play-widget” }; var s = document.createElement(“script”); s.type = “text/javascript”; s.async = true; s.src = “ s.addEventListener(“load”, function (e) { var widgetInstance = XPay2PlayWidget.create(options); }, false); var head = document.getElementsByTagName(“head”)[0]; head.appendChild(s); </script>

Code 2:
<div id=”XS-pay2play-widget”></div> <script> var options = { access_token: “9upbGoqnbonvXqyfgaBtsDcyWnv0FXEe”, theme : { foreground: “green”, background: “dark” }, lightbox: { height: “700px”, spinner: “round” }, target_element: “#XS-pay2play-widget” }; var s = document.createElement(“script”); s.type = “text/javascript”; s.async = true; s.src = “ s.addEventListener(“load”, function (e) { var widgetInstance = XPay2PlayWidget.create(options); }, false); var head = document.getElementsByTagName(“head”)[0]; head.appendChild(s); </script>

Thanks in advance for your kind efforts

Cody.

The blog I need help with is You can see a buy button below and there is spouse to be a buy button for all packages but they are conflicting with eachother.
 

Cannot have the same id (XS-pay2play-widget) for both DIVs. The Ids must be unique to the page...


Mark

"You guys pair up in groups of three, then line up in a circle."
- Bill Peterson, a Florida State football coach
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top