Notes for Codefellows Code 401 301 201 and 102
Form controls live inside a <form>
element. This element should always carry the action attribute and will usually have a method and id attribute too.
Every <form>
element requires an <action="http.....php>
attribute. Its value is the URL for the page on the server that will receive the information in the form when it submitted.
Forms can be sent using one of two methods: get or post.
The <input>
element is used to create several different form controls. The value of the type attribute determines what kind of input they will be creating.
Value of name
attribute identifies the form control and is sent along with the information users enter to the server.
<form action="thhp.....php" method="get OR post">
get is for short querries/input post for more data; id attribute for both styling and js;<input type="text" name="username">
<input type="password" name="password" maxlength="30">
means the input is hidden<input type="textarea" name="comments" cols="20" rows="4"> Enter Your comment </textarea>
<input type="radio" name="genre" value="rock" checked="checked"> Rock
means radio butto on current selection;<input type="radio" name="genre" value="pop"> Pop
<input type="radio" name="genre" value="jazz"> Jazz
<form action="........php" method="get OR post">
<input name="delivery_option" type="radio" value="pickup" />
<input name="delivery_option" type="radio" value="delivery" />
</form>
<input type="checkbox" name="service" value="itunes" checked="checked"> iTunes
means checkmark on current selection;<input type="checkbox" name="service" value="lastfm"> Last.fm
<input type="checkbox" name="service" value="spotify"> Spotify
<form action="........php" method="get OR post">
<select name="devices">
<option value="ipod">IPoD</option>
<option value="radio">Radio</option>
<option value="computer">Computer</option>
</select>
</form>
Form controls live inside a <form>
element. This element should always carry the action attribute and will usually have a method and id attribute too.
Every <form>
element requires an action attribute. Its value is the URL for the page on the server that will receive the information in the form when it submitted.
Forms can be sent using one of two methods: get or post.
The <input>
element is used to create several different form controls. The value of the type attribute determines what kind of input they will be creating.
Value of name
attribute identifies the form control and is sent along with the information users enter to the server.
<input type="submit"> elements can have a type attribute set to submit, by adding type="submit". With this attribute included, a submit button will be rendered and, by default, will submit the <form> and execute its action.
<form action = "http....php">
<input type = "submit" name = "subscribe" value = "Subscribe" />
</form>
Properties for LISTS:
list-style-type
<ol>
, <ul>
, and <li>
elements.disc
, circle
, square
) / OL values (decimal-leading-zero
, lower-alpha
, lower-roman
)list-style-image
list-style-image: url("picture.png")
list-style-position
: outside or inside
list-style
list-style: inside circle;
Properies for TABLES:
width
padding
text-transform
letter-spacing
, font-size
border-top
, border-bottom
text-align
background-color
:hover
empty-cells
border-spacing: 5px 15px;
border-collapse
Events are actions or occurrences that happen in the system you are programming, which the system tells you about so you can respond to them in some way if desired. For example, if the user selects a button on a webpage, you might want to respond to that action by displaying an information box.
In the case of the Web, events are fired inside the browser window, and tend to be attached to a specific item that resides in it — this might be a single element, set of elements, the HTML document loaded in the current tab, or the entire browser window. There are many different types of events that can occur. For example:
<button>Change color</button>
//storing a reference to the button inside a variable called btn, using the Document.querySelector() function. Defining a function that returns a random number.
var btn = document.querySelector('button');
function random(number) {
return Math.floor(Math.random() * (number+1));
}
btn.onclick = function() {
const rndCol = 'rgb(' + random(255) + ',' + random(255) + ',' + random(255) + ')';
document.body.style.backgroundColor = rndCol;
}
//code generates a random RGB color and sets the <body> background-color equal to it.
Event Types :
Events | Description |
---|---|
load | web page has finished loading |
error | browser encounters JavaScript error |
click | user presses and releases a button over the same element |
dblclick | user presses and releases a button twice over the same element |
mousemove | user moves the mouse |
mpouseover | user moves the mouse over an element |
input | Value in any <input> or <textarea> element has changed or any element with the contented i table attribute |
change | Value in select box, checkbox, or radio button changes |
submit | User submits a form (using a button or a key) |
select | User selects some text in a form field |
copy | User copies content from a form field |
paste | User pastes content into a form field |