Assignment 8 Forms
Assignment 8 Forms
Assignment 8 Forms
1. On your “contact” html page revise the “placeholder” heading text to say something like
“Let us know how to contact you with the answers you need.” Follow this with a short
short introductory paragraph that informs the user that this is how to get the business a
message so they can answer questions or call you back at a convenient time.
2. Next, add a <form> element that uses the “post” method and the action attribute to
invoke server-side processing. Configure the action attribute to send the form data to
https://webdevbasics.net/scripts/demo.php . This is a server-side site set up for the Felke-
Morris text book. It will just return a “mirror” of what the user entered. You can learn
how to create one of your own in ITC3150.
(required) (you should set the phone number format to the common US
format (999-999-9999 ) if you can. Look at the pattern
attribute and see if you can do it! )
Preferred Select https://www.w3schools.com/tags/tag_select.asp
contact (dropdown
list)
Choices:
Email me
Phone me between 1pm – 4pm
Phone me between 6pm – 9pm
4. Test your page and see that the response you get from the demo server gives you back the
form items with the user input you entered.
There are a few different approaches to styling the input forms. Briefly review them
with the w3schools links below and decide which you will use. The most
straightforward is probably the w3schools Stacked Form because it will have only one
column for both the Large or Small screen. The w3schools In-Line Form example is also
simple, but it uses flexbox to manage vertical vs horizontal placement for the two screen
sizes. The most comprehensive is the w3schools Responsive Forms example, which uses
Grid View techniques. We haven’t covered Gridview, but it is very effective for layout,
and will get you extra points! Choose the approach you are most comfortable with.
STACKED FORM. Use a single column with the label ABOVE the user input field for
both large and small screen. Things to pay attention to:
The <input> selector needs to include the attribute that specifies whether it is for
text, tel, checkbox, etc. The syntax is:
o selector [attribute = value]
o Example: input[type=text]
Other kinds of input like textarea and select do not need this special syntax.
Combine any of the input selectors together in one set if they use the same
rules. See: https://www.w3schools.in/css3/group-selector
You can apply the hover pseudoclass to a submit input selectors just like you can
to the <a> anchor/link tag!
Here is example CSS for a stacked form:
https://www.w3schools.com/howto/howto_css_stacked_form.asp
IN-LINE FORM. Practice your flexbox skills and have a different look for large and
small screens. Things to pay attention to:
W3schools has the small screen rules AFTER the @media query instead of
above it!! If you have been following previous instructions and putting the
small screen at the top of your CSS file, and the Large screen rules at the
bottom, remember to reverse what you see in w3schools to fit your existing
code.
The w3schools example uses a .form-input class for the form itself, and then
uses this class for every label and input selector. This is good practice for a
site with multiple forms. It is not strictly necessary on a site as simple as this
one. If you are typing by hand, save yourself the keystrokes. If you prefer to
copy/paste from w3schools, you might want to stick with their convention.
W3schools uses the <button> element for the “submit” instead of <input type
= submit> . They are different, but not by much. You may use either one.
Here is the example code:
https://www.w3schools.com/howto/howto_css_inline_form.asp
Notice that with this approach, every label and every control must be
positioned into the appropriate “row” and “column”. Make sure to plan this
out before working on the coding.
As with the Stacked Form, the <input> selector needs to include the
attribute that specifies whether it is for text, tel, checkbox, etc. The syntax
is:
o selector [attribute = value]
o Example: input[type=text]
As with the In-Line form, W3schools has the small screen rules AFTER the
@media query instead of above it!! If you have been following previous
instructions and putting the small screen at the top of your CSS file, and the
Large screen rules at the bottom, remember to reverse what you see in
w3schools to fit your existing code.
2. Create a .js file SEPARATELY from your html file. You can do this in Dreamweaver,
VS Code or Brackets. Your new file must have the .js file extension. (Each tool
does this a bit differently but it should not be hard to figure out. ASK if you can’t
get it to work!) In your root folder, you may already have a “scripts” folder set
up. If not, make one. Put your .js file in it.
3. In your .js file, code a function for a simple “Alert” message that says: “Welcome
pets of all ages, sizes and skills”. Give your function a descriptive name with NO
SPACES OR SPECIAL CHARACTERS.
https://www.w3schools.com/js/js_functions.asp
https://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_alert
4. Add the <script src ….> tag in the html for your index.html page. You may put it
at the bottom of the html file, just before the </body> tag, or in the <head>
element, just like the link to your css file:
https://www.w3schools.com/js/tryit.asp?filename=tryjs_whereto_external
(second example)
6. Now it is time to associate the Alert message script with an EVENT so the
browser will know WHEN to find and execute the script for the Alert message.
Often the EVENT for a function is associated with a button click. But for this
assignment, you will use the ONLOAD event for your index.html page.
https://www.w3schools.com/jsref/event_onload.asp
7. Test your index.html page to see that the message pops up (yes, it is an
annoying alert message!)
8. Load your site, including your new script folder and .js file to the server and
upload your work to Canvas.