r/javaScriptStudyGroup • u/Arri3cubed • Apr 28 '23
Slamming my head Against the Wall with Zybooks
I am almost at the end of a 16 week online course that exclusively uses Zybooks and I feel like I have been teaching myself. I was doing okay (if you call having a mental breakdown almost every assignment okay) when the lessons were individual. I'm now near the end and really struggling with this chapter that only has vague information about form widgets. I just barely found this group and would like some feedback. Why is my form not stopping the post to the action link? I tried using min and max in the label, and with a Javascript function (separately). Neither work. I turned it in but my teachers comments aren't enough of an insight. TIA
Here is the instructions:
Fred's French Fry Shack specializes in serving fresh, delicious fries and needs a way to collect feedback from its customers. Create a web page named FriesFeedback.html with a form for user input. Use at least three different widget types to collect the following:
Customer name (ensure that this is between 5 and 30 characters)
Date of visit
Size of fries ordered (Small, medium, large)
Whether or not the customer plans to return
Comments
A button should submit the form data to he form-viewer page at wp.zybooks.com, as you did in the zyBooks activities.
Here is my code:
<html>
<head>
<title>Module 09 - Part A</title>
<style> body { background-color: azure; } main { background-color: white; margin-left: 200px; margin-right: 200px; padding: 25px; border: 1px solid black; } h1 { color: navy; } </style>
</head>
<body>
<main>
<h1> Thank you for choosing Fred's French Fry Shack</h1>
<p><i>We would like to hear more about your experience!</i></p>
<br>
<form id="fryFeedback" action="[https://wp.zybooks.com/form-viewer.php](https://wp.zybooks.com/form-viewer.php)" target="_blank" method="POST">
<p>
<label for="full" min="5" max="30">Full Name:</label>
<input type="text" name="full" id="full" placeholder="Your name...">
</p>
<p>
<label for="date">Date visited:</label>
<input type="date" name="date" id="date" required>
</p>
<p><b>What size of frys did you order?</b></p>
<p>
<label for="fryS"> Small</label>
<input type="checkbox" name="fryS" id="fryS">
<label for="fryM"> Medium</label>
<input type="checkbox" name="fryM" id="fryM">
<label for="fryL"> Large</label>
<input type="checkbox" name="fryL" id="fryL">
</p>
<p><b>Do you plan to return?</b></p>
<p>
<label for="yes">Yes</label>
<input type="checkbox" name="yes" id="yes">
<label for="no">No</label>
<input type="checkbox" name="no" id="yes">
</p>
<p>
<label for="comments"><b>Do you have any thoughts about your experience you would like to share?</b></label>
</p>
<p>
<textarea name="comments" id="comments" rows="3" cols="20"> I liked...</textarea>
</p>
<p>
<input type="submit" value="Finish" onclick="checkName()">
</p>
</form>
</main>
<script> function checkName(){ var name = document.getElementById("full").value; var nameLength = name.length > 5 && name.length <= 30; // borrowed this function from Zybooks function checkForm(event) { if (!nameLength) { event.preventDefault(); } } </script>
</body>
</html>