- This topic has 3 replies, 2 voices, and was last updated 1 year, 2 months ago by Brameister.
-
AuthorPosts
-
2023-10-10 at 12:30 am #67425BrameisterParticipant
Hello.
Tried using “Set prop” puzzle targeting an html text element with a specific id, but it didn’t work.
The example shown in Soft8Soft’s manual shows a specific property called “textContent” being used. However, this prop is not listed in the puzzle. I tried the “innerHTML” prop, but it also didn’t work.
The app link is: https://cdn.soft8soft.com/AROAJSY2GOEHMOFUVPIOE:8b1dc361cf/mesa_de_cabeceira_lumi/index.html
I’ve also attached a screenshot of the puzzles I’m trying to use at the moment.
The text I’m trying to change is the “R$ 2500” text. I’m following an adapted pricing logic taken from one of Soft8Soft’s examples, which is used in a Scene text object. However, I need to do the same thing using an HTML text element, rather than a Scene text object.
Does anyone know how we can change HTML text using puzzles?
Attachments:
You must be logged in to view attached files.2023-10-10 at 12:55 am #67427kdvParticipantThe text I’m trying to change is the “R$ 2500” text
You are trying to set
innerHTML
for the wrong element.
The element you need have no id. Read about
querySelector()
and sequential requests or set some unique id for<p>
.Puzzles and JS coding. Fast and expensive.
If you don’t see the meaning in something it primarily means that you just don’t see it but not the absence of the meaning at all.
2023-10-10 at 1:07 pm #67445BrameisterParticipantTried setting the id “pricetag” to p in the index.html file (<p id=”pricetag”> R$ 2500 </p>) but it still didn’t work.
I’m trying to learn about querySelector and did a few tries, calling <p> content via type (“p”), id (“#pricetag”) and class (“.pricetag”) in the querySelector puzzle. None of them worked.
I also tried placing a JS exec script puzzle with the following code:
var x = document.getElementById(“texto_preco”);
x.querySelector(“p”).innerHTML = “Hello World!”;That also didn’t work.
What could I be missing?
Thanks for the help once again.2023-10-10 at 2:38 pm #67449BrameisterParticipantUpdate for future reference:
I set the ID “pricetag” to the <p> element in the HTML file and it worked when the Set Prop puzzle was by itself. It wasn’t working when it was inside the price_recount procedure created to update product price based on client selections in the configurator.
The reason it wasn’t working is because the procedure was set, but not called.
Now everything seems to be working correctly. Thanks again for the help!
- This reply was modified 1 year, 2 months ago by Brameister.
Attachments:
You must be logged in to view attached files. -
AuthorPosts
- You must be logged in to reply to this topic.