Re: onclick attribute with innerHTML?

2020-06-05 Thread AudioGames . net Forum — Developers room : Ty via Audiogames-reflector


  


Re: onclick attribute with innerHTML?

I'll have ot try that. Thanks stewie

URL: https://forum.audiogames.net/post/537828/#p537828




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: onclick attribute with innerHTML?

2020-06-05 Thread AudioGames . net Forum — Developers room : stewie via Audiogames-reflector


  


Re: onclick attribute with innerHTML?

Each of the choices should look similar to this.choicesDiv.innerHTML = "Begin exploring.";

URL: https://forum.audiogames.net/post/537827/#p537827




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: onclick attribute with innerHTML?

2020-06-05 Thread AudioGames . net Forum — Developers room : stewie via Audiogames-reflector


  


Re: onclick attribute with innerHTML?

Each of the choices should look like this.choicesDiv.innerHTML = "Begin exploring.";

URL: https://forum.audiogames.net/post/537827/#p537827




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: onclick attribute with innerHTML?

2020-06-05 Thread AudioGames . net Forum — Developers room : Ty via Audiogames-reflector


  


Re: onclick attribute with innerHTML?

Alright now in the error console I get thisindex.html:38 Uncaught SyntaxError: Unexpected identifierAnd line 38 isHere's the codeSurvive.Survive.By Ty Gillespie.Story.Choices.Copyright 2020-present by Ty Gillespie. All rights reserved.<br />let storyDiv = document.getElementById("storyDiv");<br />let choicesDiv = document.getElementById("choicesDiv");<br />function updateStory(sscene) {<br />storyDiv.innerHTML = "";<br />choicesDiv.innerHTML = "";<br />if (sscene == "intro1") {<br />storyDiv.innerHTML = "You awake, in the middle of a grass field. You're cold, and everywhere hurts. You don't remember anything about yourself, or about how you got here.";<br />choicesDiv.innerHTML = "<button _onclick_ = &quot;updateStory(&quot;intro2&quot;)&quot;>Begin exploring.</button>";<br />} else if (sscene == "intro2") {<br />storyDiv.innerHTML = "You walk for hours on end. Your legs are starting to get tired. Looking up at the sky, the sun is already almost completely hidden behind the Earth.";<br />choicesDiv.innerHTML = "<button _onclick_ = &quot;updateStory(&quot;intro3&quot;)&quot;>Keep exploring.</button><br /><button _onclick_ = &quot;updateStory(&quot;intro4&quot;)&quot;>Go to sleep and continue your search tomorrow.</button>";<br />} else {<br />storyDiv.innerHTML = "Not yet.";<br />}<br />}<br />updateStory("intro1");<br />Any idea what's going on here?Thanks

URL: https://forum.audiogames.net/post/537822/#p537822




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: onclick attribute with innerHTML?

2020-06-05 Thread AudioGames . net Forum — Developers room : stewie via Audiogames-reflector


  


Re: onclick attribute with innerHTML?

\" is the escape string yeah, but you're escaping the " in _javascript_, not for the innerHTML also. So when you use the \" in _javascript_, _javascript_ gets a " character, which is then added to the html string. When the html itself is parsed, it needs its own escaping.

URL: https://forum.audiogames.net/post/537798/#p537798




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: onclick attribute with innerHTML?

2020-06-05 Thread AudioGames . net Forum — Developers room : Ty via Audiogames-reflector


  


Re: onclick attribute with innerHTML?

I do not see any errors when pressing the buttons but I'll try with  I assumed that \" is the escape string. I'll let you know if it worked. Thanks.

URL: https://forum.audiogames.net/post/537791/#p537791




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: onclick attribute with innerHTML?

2020-06-05 Thread AudioGames . net Forum — Developers room : stewie via Audiogames-reflector


  


Re: onclick attribute with innerHTML?

I think the problem is that you aren't escaping the quotes correctly within the attributes on the generated buttons. For example, this code:choicesDiv.innerHTML = "Begin exploring.";This would generate the following html:Begin exploring.So the browser tries to parse the html, hits a quote after the (, thinks that's a closing quote for the attribute value and silently breaks. Do you get a console error after clicking the buttons? You can use  to represent a " character in html.

URL: https://forum.audiogames.net/post/537775/#p537775




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector