r/programminghelp • • Sep 27 '19

I’m in an intro level programming class. I have to take even though my major is Social Studies Education. Our assignment is to make a form letter that get erased on a button click. For some reason, when I click the button, nothing happens. What am I doing wrong?

Post image
9 Upvotes

10 comments sorted by

2

u/[deleted] Sep 27 '19

What error are you getting in your debug console?

1

u/ConnorJones9 Sep 27 '19

“SCRIPT1015: SCRIPT1015: Unterminated string constant”.

2

u/[deleted] Sep 27 '19

You'd probably be way better off not doing that onClick function inline like that. Your strings are a mess.

Add a script block with your onclick function, then call it from the button

<script>
function OnButtonClick() {
    document.getElementById("outputDiv").innerHTML="etcetcetc";
}
</script>

then

<input type="button" value="Click for Form Letter" onclick="OnButtonClick();">

This way you should be able to get a better visual of where your strings and quotes are terminating.

1

u/ConnorJones9 Sep 27 '19

The only reason I’m doing it this way is because that’s how our teacher and textbook are showing us right now. I’m comparing what I have to the textbook and I’m not seeing what I’m doing wrong

6

u/[deleted] Sep 27 '19

Alright, fair enough.

Well, next time if you can please copy your work into a PasteBin (www.pastebin.com) and paste the link here. It's easier to work with when we can replicate the issue directly.

From what I see, I THINK your issue might have something to do with lines 35 and 35. You close the p tag, then close a single quote but don't add a + between that line and the next.

2

u/ConnorJones9 Sep 27 '19

1

u/[deleted] Sep 27 '19

Line 34 you forgot to open with a singlequote.

Should be:

'</p>' +

1

u/ConnorJones9 Sep 27 '19

You’re a saint, thank you so much

1

u/[deleted] Sep 27 '19

This is really cool for you to help. Not OP but thank you from the community.

1

u/[deleted] Sep 27 '19

I take this subreddit very seriously ;)