Skip to content

Changes for issue #38530 on mdn/content #787

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions html/forms/tasks/form-structure/form-structure1.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,31 @@

<div class="playable-buttons">
<input id="reset" type="button" value="Reset" />
<input id="solution" type="button" value="Solution" />
</div>


<textarea id="solution-code" style="display: none;">
<form>
<fieldset>
<legend>Personal details</legend>
<label for="name">Name:</label>
<input type="text" id="name" name="name">

<label for="age">Age:</label>
<input type="number" id="age" name="age">
</fieldset>

<fieldset>
<legend>Comment information</legend>
<label for="comment">Comment:</label>
<input type="text" id="comment" name="comment">

<label for="email">Email:</label>
<input type="email" id="email" name="email">
</fieldset>
</form>
</textarea>
</body>
<script src="../playable.js"></script>
</html>
7 changes: 7 additions & 0 deletions html/forms/tasks/playable.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ var editable = document.querySelector(".editable");
var textareaHTML = document.querySelector(".playable-html");
var textareaCSS = document.querySelector(".playable-css");
var reset = document.getElementById("reset");
var solution = document.getElementById("solution");
var solutionCode = document.getElementById("solution-code").value;
var htmlCode = textareaHTML.value;
var cssCode = textareaCSS?.value;

Expand All @@ -19,6 +21,11 @@ reset.addEventListener("click", function () {
fillCode();
});

solution.addEventListener("click", function () {
textareaHTML.value = solutionCode;
fillCode();
});

textareaHTML.addEventListener("input", fillCode);
textareaCSS?.addEventListener("input", fillCode);
window.addEventListener("load", fillCode);