WWW Interactive Programming
WWW Interactive Programming
Serverside are executed by the webserver. Server sends it to the browser and then your computer will interpret all of that.
PHP is serverside and you need a server, we can download and Install one :D.
USB Webserver is back at it again.
Document is just our html file, visual file, visual document etc.
HTML page is made up of elements and first of all remember that these elements are NESTED (elements within elements and shiet).
ALL HTML tags have opening and closing tags, indicated by angle brackets.
< > - opening tag -> ATTRIBUTES *ONLY* GO HERE
Our ROOT element: we don't NEED to put it, but standards are kewl
<html>
Element that includes all the elements, the ROOT
</html>
The browser will try and guess what u have, but don't rely on it. Learn to code properly shazawg.
<head> <!--Stuff like navbar and specific shiet like files associated to ur page like .css and .js ykwim and METADATA, also title lol -->
</head>
<body> <!--Most of the stuff visible to you is in the body-->
</body>
Headings:
<h1> … <h6>
Largest -> Smallest
Paragraph:
<p> </p>
Allows you to hold MAD text.
Line Break:
<br>
Image:
<img>
Bold:
<b>
Vs
Strong:
<strong>
Italic vs Emphasis
<i> <em>
Underlined vs Inserted
<u> <ins>
Deleted
<del>
SuperScript
<sup>
Subscript
<sub>
If you just want bold, just use css. If you wanna use <b> in ur css then just use <strong> lol
2 Kinds of elements:
Inline and Block.
Block element means it'll take up a whole section of your website.
An inline element means whatever comes next will take up whatever space next to it in the same line.
Whenever we wanna insert an img, we can use the img tag:
<img src="filepath">
Source attribute is a general attribute and only applicable to certain attributes, attributes such as name, id, class and title are general attributes and are applicable to a majority of the elements. Usually we
use ID or Classes for CSS, duh, u know that.
Image Map
-> image with clickable areas that may be hyperlinks
<img src="Resources/piano.jpg" style="width:400px;" alt="is a piano" usemap="#treemap"> <!-- ALWAYS USE RELATIVE FILE PATH-->
<map name="treemap">
<area shape="circle" coords="200,120,70" href="http://sjcconnect.edu.bz">
</map>
-> Example of an image map
Shapes -> circle only needs 3 values, aka the location of the center and the radius/diameter
Rectangle -> you need to define the coordinates of top left corner and bottom right corner
Polygon -> depends on how much stuff u need lmao
<a href="#top">Top</a> - same page same website, #top is an element in our page
Target attribute:
-> how the target page should be opened
-> may be:
_blank - new tab
_parent - parent frame - same frame
_top - full body of the window
_self - current tab
Character entities
< <
> >
& &
© ©
® ®
™ ™
" "
' '
non breakable space]
Because <,> wont show normally. Need to type these things
CSS
-> Cascading Style Sheet
-> may be
a) Inline => style attribute
b) Internal/embedded => style element in <head>
c) External => css file
Week 3 Page 3
Week 4
Monday, January 27, 2025 2:41 PM
5. If h1 and para have the same margin 25 ^ other than doing them separately, we
Next type of selector is what we call pseudo class selector can combine them. No relationship needed, can use anything. Commonly used for
Pseudo-class selector -> targets a particular state or a variety family relationship of an element like border/margin and you want to clear out all the particular styling/spacing this
e.g b:hover{ is commonly used. Another one is if u wanna apply lines for ur table and stuff
Background-color:yellow; etcetc.
}
How style interact:
-> some pseudo-class selectors: 1. Inheritance
a:link -> :first-child -> some inheritable properties: color, font, text
a:visited -> :last-child -> non-inheritable properties: border, spacing, background, size
:active -> :nth-child() 2. Specificity
:focus -> the more specific the selector, the more it takes precedence
Eg:
id>class>element selector -> order
<p> 3. Location
<b>….</b> -> when inheritance and specificity cannot determine the style precedence,
<img> location principles are applied
<a>….</a> -> the latest rules are given more weight
</p>
Box Model
Active can apply to anchor or clickable element - applies to when it's being clicked on
Active goes last, hover goes third, visited is second and link is first. Link and visited are interchangeable but we usually
do link then visited.
6. Pseudo-element selector
-> selects something that does not exist explicitly as an element but is a recognizable selectable object
Eg: p::first-letter
{font-size:24pt;}
7. Contextual/combinator
a) Descendent (space)
Eg: p b{ Dashed box - content of parent
Text-decoration:overline; Remember html is nested, so boxes in boxes, When we define border, we can define
} color for that.
b) Child(>)
Eg p>b From the margin to your content is the padding
{ When you define width and height, you are defining width and height of your
Font-size:2em; content element.
}
c) Adjacent sibling (+) Research background, margin, padding and border.
Eg:
h2+p
{
Margin:50px;
}
<p>
<div>
<b>…</b>
<i>…</i>
</div>
<b>….</b>
</p>
Week 4 Page 4
Week 5
Monday, February 3, 2025 2:16 PM
Background-image: url("pic1.jpg"),url(pic2.jpg);
Background-repeat: no-repeat; (basically makes ur image span as tiles if it doesn’t cover the entire thing naturally)
Background-size:cover; (If u don’t have cover/contain, this will NOT necessarily cover the entire web-page, just stretches it to fit the width of the page)
Background-position: center; //can also put x,y positions, basically where u want it lmao/ can use percentages too lmao,
Background-attachment: fixed; (fixed means it stays the same place when you scroll, the scroll one means default)
Adjacent Siblings
Basically means these 2 elements that are siblings should be vertically adjacent, vertically next to ecah other. Margin collapsing only applies to vertical
margins.
Week 5 Page 5
Week 6
Monday, February 10, 2025 2:10 PM
Background-origin:
Padding-box - starts from the top left of the padding
Border-box - goes up to the border, so might get cut off slightly by ur border
Content-box - the actual content, like the background of ur text
Background-blend-mode: overlay;
Margin Collapse
-> vertical margins only
-> 3 basic cases
1. Adjacent siblings
2. Nothing separates the margin of parent and child
3. Empty block -> margins of floating or absolutely positioned elements never collapse.
Bottom margin of the first one and top margin of the second will collapse, means that whichever one is the largest value
that’s the margin between the two elements.
Box Dimension
-> box-sizing -> content-box.border-box
Content-box
WIDTH -> WIDTH OF CONTENT AREA
BORDER-BOX
WIDTH->width of content area + Padding at both sides + border at both sides
-> width, min-width, max-width
-> height, min-height, max-height
Units
1. px -> pixel. Absolute
2. em -> size relative to the font size. Relative (if u apply it to the font size then it gets it from the parent
3.
Google:
Vw
Vh
Rem
Ch
Week 6 Page 6
Week 7
Monday, February 17, 2025 2:17 PM
Font Lists
1. Font-family: ideal, alternative, common, (generic - usually use this) 1. Ordered <ol>
-> 5 general font 2. Unordered <ul>
a. Serif eg: Times New Roman (adds lil strokes at the end) 3. Description <dl>
b. Sans-serif eg. Arial a. <dt>
c. Monospace eg. Courier - consistent width for all characters b. <dd>
d. Cursive - varies from system to system Can make an unordered list, ordered, with CSS
e. Fantasy - varies from system to system
2. Font-size - we usually use pt and em and sometimes %, px is not very common List-style-type:lower-greek;
3. Font-weight - allows us to bold our text: 100-900, lighter, light, normal, bold, bolde List-style-type:circle;
4. Font-style: normal, italic, oblique
Can use
Text: List-style-image:url(link); //if u don’t wanna resize image you can resize it with css like:
1. Text-decoration:none, underline, overline, line-through //this is the underline for your text
2. Text-align: left, right, center, justify Ul li
3. Text-transform: none, capitalize, uppercase, lowercase {
4. Text-shadow: x y blur color Background-image:url(resources/check.png);
5. Letter-spacing - size lol Background-repeat:no-repeat;
6. Line-height - Background-size:25px;
7. Word-spacing - Padding-left:25px;
5,6 and 7 are related }
List-style-type:
List-style-image:
List-style-position:
Table
<table>
<caption> //automatically center aligned
<tr>
<th>
<td>
COLGROUP
Caption must be the first child of the table, if you put caption in the table it has to be the first one within the
table, if you have caption, colgroup has to be the second child of the table
Week 7 Page 7
Week 8
Monday, February 24, 2025 2:13 PM
Caption should be first child in the table Float u don’t really gotta worry about for inline elements, more block elements yk
Sometimes we want a striped table or a different bg color CSS Layout properites
2. Position
Striped Table -> static - normal flow - default
-> relative - the element is placed in relation to its normal flow
tr:nth-child(even) //alternating row color or every nth child -> absolute - the element is placed in relation to its nearest positioned ancestor
{ -> fixed - the element is placed at specific location of the window even when the document is scrolled
Background-color:lightgrey; -> sticky - the element is positioned in according to its normal flow, and then offset in relation to its nearest scrolling ancestor
}
These elements do not apply styling to ur page, by default they look the same as div, but ofc then the initial intention for
them is to allow us, the web dev, to divide the page into different parts. To the browser though, they are no different than the
div. They are BLOCK elements. They basically just make your webpage content a little bit clearer to other coders. Before
HTML5 they used div and when it came to styling we had to use classes for each div.
2.
Week 8 Page 8
Week 9
Wednesday, March 5, 2025 10:02 AM
Display:flex; - Creates main axis and cross axis Grid starts in HTML. Container with some items inside of it. HTML Form
Flex-direction: row/column; row by default, can make it go vertically with column - <form>
Justify-content: flex-start/flex-end/center/space-between/space-around/space-evenly; Grid-template-rows:length length length; ➢ action - specify the script file that will process the data sent via the form
Aligning content along the main axis^, flex-start is the left, flex-end is the right, center is clearly the center, space Grid-template-columns:length length length; ➢ Method - how the data will be sent to the actual page
between puts space in between elements and makes them touch the border, space-around puts space between them Assigns rows and columns of SPECIFIC lengths depending on the parameters, the number ▪ Get: data form part of the URL for the action page
but spaces them out from the border also, space-evenly duh, evenly spaces them all. of parameters tells you how much rows/columns you are going to have, so 3 parameters in □ Can bookmarked
the grid-template-rows means you have 3 rows of the specified lengths. □ Cannot work with binary data
We can align them along the cross axis using: □ Restrictions on the length of the data
Align-items: same as for justify content, this time it just goes vertically. Each specific element can have these properties: ▪ Post: data are sent as part of HTTP request; data are not directly visible
We have baseline which allows all the fonts on the elements to be aligned. Grid-row-start:1; - Text: <input type="text" name="school" placeholder="schooltext">
Grid-row-end:1; - Password: <input type="password" name="pass">
Flex-direction:column; switches our main and cross axes Grid-column-start:1; - Number: <input type="number" name="years" min="1" max="5">
Normally they'll try and squeeze together inside the parent container, but we can make them wrap using, well duh: Grid-column-end:1; - Date: <input type="date" name="dob">
Flex-wrap: nowrap/wrap; - Color: <input type="color" name="bg">
Nowrap is default, and wrap makes them wrap and not try and fit on one line Specifies which specific column/row you want it to end/start - Telephone: <input type="tel" name="phone">
When it wraps you unlock a property called: You can use these for shorthand: - Email: <input type="email" name="email">
Align-content: ; Grid-row:start / end; - Radio buttons: <input type="radio" name="gender" value="male"> male
Only works when flex-wrap:wrap; Grid-column:start / end; □ <input type="radio" name="gender" value="female"> female
Allows us to align everything on the cross axis, same as justify content Separate it with a slash ! ! ! □ <input type="radio" name="gender" value="unspecified"> unspecified
Gap:length; 2 parameters tell us start and ending points - Checkboxes: <input type="checkbox" name="hobbies[]" value="dance"> Dancing
Gap duh, allows you to have gaps in between each element You can also use: □ <input type="checkbox" name="hobbies[]" value="basketball"> Basketball
Grid-row:span number; □ <input type="checkbox" name="hobbies[]" value="movies">
Flex-grow:1; Grid-column:span number; □ ^ specify it's an array with [], otherwise the last one will overwrite the rest
Takes a unitless value that allows the element to grow if it has the space Doesn't allow you to specify where you want it to start^ - Button: <input type="button" value="Button A">
Basically shorthand for the shorthand, tells you how much rows/columns u want it to span - Reset: <input type="reset" value="Clear All">
Flex-shrink:0/1+; - Submit: <input type="submit" name="Send">
Dictates how fast that element will shrink in proportion to the window, 0 means it'll never shrink - <select> <option value="Belize">BZ </option> <option>Cayo</option> <option>Corozal</option>
Flex-basis: length; Grid-area: row-start / col-start / row-end / col-end; </select>
Basically allows you to overwrite the width of the element z-index:num;
Basically what layer we want it in ^ ^ ^
Flex:; is the shorthand for the 3 above, 2nd and 3rd parameters are optional
Grid-auto-rows:sets the rows on any implicit grid created;
Align-self:same as justify-content; Grid-auto-flow:basically sets what gets created when we exceed grid limit, either columns
Just aligns a specific item or rows;
Order: ;
Can use this to change the order in which elements appear
-1 for first, 1 for last
Week 9 Page 9
Week 10
Friday, March 14, 2025 2:12 PM
Javascript
<select name="District" multiple>
<textarea name="comments" rows="10"> Case sensitive
<input type="image" src="resources/check.png">
<button><img src="resources/check.png">Done</button> <!DOCTYPE html>
<script>
<input type="range" min="1" max="10"> Let x =10;
Var y= 15;
Alert(x+y);
</script>
Let - lets say if u create a variable using let, within an if, or within a loop, then that means the scope of
that variable is limited to that block of code
Week 10 Page 10
Week 11
Monday, March 17, 2025 2:11 PM
Script usually goes in head so we can easily call any function we write so we don't get any errors.
Javascript Objects
Let course= {
Num: "Cis 286",
Title: "WWW Interactive",
Credits: 3,
Display: function() {
Return this.Num + " " + this.Title + " " + this.Credits;
}
};
Empty object:
Let room = {};
room.Num="W7"
room.capacity=30;
Week 11 Page 11
Week 12
Monday, March 24, 2025 2:42 PM
Document.querySelector("h1").style.backgroundColor="#ffddff";
Document object represents your html file. <script>
Document is your HTML file. Let it2 = { Manipulation Method
How JS understands each html object: display:function() 1. createElement()
Document Object Model (DOM) { 2. createTextNode()
Root is the document object and then child 3. createAttribute()
Relationship between every element, the two paras on the bottom left are the child of the div and the time is the child } 4. appendChild()
of one of the p's. } 5. insertBefore()
Every single element we see in the HTML consists of 3 parts. 6. replaceChild()
Function Major(n,dep,cre) 7. removeChild()
<a> { 8. setAttributeNode(), setAttribute()
this,name = n;
this.department = dep; Let content = document.querySelector("body"); //parentheses has to be an html element
this.credits=cre; Let message = document.createTextNode("This is added by JS");
} Let par = document.createElement("p");
Par.appendChild(message);
Let cis = new Major( Let format = document.createAttribute("style");
Central Park "Computer Information Systems", Format.value="color: red;";
Href=".." "Computer Science", Par.setAttributeNode(format);
text node 73 Content.appendChild(par);
attribute </script> Let heading=document.querySelector("h1"); par.setAttribute("style","color: red");
Content.insertBefore(par. Heading);
Let a = document.getElementById("cis"); Selection Methods:
1. getElementById() -> return a single element node whose id matches the argument Events
2. getElementsByClassName() -> return a NodeList of elements whose clsas name matches the argument 1. Define Event Handler
3. getElementsByTagName() -> return a NodeList of elements whose tag name matches the argument 2. Register Event handler
4. querySelector() -> return the first element node that matches the passed CSS selector 3. Event triggered
5. querySelectorAll() -> return a NodeList of elements that match the [pass CSS selector] 4. Event handler executes
document.getElementsByClassName("honor")
Document.querySelector(".honor") - use a css
Week 12 Page 12
Week 13
Monday, March 31, 2025 2:09 PM
Using javascript to handle the event like miss said so miss has 2 buttons, one for changing bg to red and another for PHP Date Types <?php
changing to green, everything else is the same so she use same eventlistener and in the case cuz she needs to know 1. Boolean declare(strict_types=1);
whats the value for the button. One for red and one for green and we want to check if its blue red or green we basically 2. Integer ?>
want event listener to figure out what color we specified using the button. 3. Float
4. String ^^ declaration at the top of your code that ensures that the data that enters your function from your
5. Array parameters MUST be that data type, if not included then php will attempt to convert the data.
b.addEventListener("click",changeBackground) 6. Object
7. NULL Function
Function checkForm() 8. Resources -> function names are not case-sensitive
{
let pw = document.forms['aForm']['pass']; Operators Scopes:
let msg = document.querySelector("#message"); 1. === identical - Declared in function is local scope
2. !== not identical - Declared outside function is global scope
If(pw.value.length < 8) 3. <> not equal In PHP you cant access a global variable in a function, global is global, local is local. NO OVERLAP.
{ 4. <=> compare/spaceship We cannot directly access a global variable within a function, why? Ofc only PHP knows.
let text = document.createTextNode("password length must be at least 8 characters"); 5. AND &&
msg.appendChild(text); 6. OR || Inclue and Require
msg.style.color='red'; 7. XOR only OR, not AND, only OR, only true if you have ONE true -> include
return false; 8. ** exponentiation -> include_once
} 9. . string concatenation -> require
10. ?? $x=$var1??$var2; (if var1 is not null, then has var2 value) -> require_once
} ^ assigns value to x, will have var1 if var1 exists and not null, if not, it has var2
If(pw.value.search(/[0-9]/)<0) 11. ?: ternary operator Facilities needed for our project.
{ Allows you to take the contents of one file and just slap it on top of another file.
let text=document.createTextNode("Must contain a digit"); $x = $var1>10?$var1:$var2; We have, include and require.
Msg.appendChild(text); what comes before question mark is comparison
msg.style.color='red'; What is the difference?
return false; if(isset($var1)) In terms of the include, if PHP cant find the target file, you get a warning then continue with the rest of
} $x=$var1; ur php file. Until it finishes executing ur PHP code.
else
<form name="aForm" action="process.php" method="post" onsubmit="return checkForm()"> $x=$var2; When it comes to require, it is MANDATORY. So, if the file is not found or something went wrong or PHP
If u don’t add return It goes to a broken page, you NEED return. cant load the file. Then it will give you a warning then STOP the execution of PHP script, that's the
difference.
<label for="pass">Password</label>
<input type="password" name="pass"><br> If it has been included, it will not be included again.
<input type="submit"> The include facility is basically the same thing as you copy and pasting the content of your file right into
where u put it.
Regular Expression So, whatever function you have in that file, it remains ? ? As if you actually copy and pasted the content
/[0-9]/ into the page. It's a very useful tool when we are creating websites, and rather than go and copy and
The (-) would be considered as a range pasting that shit urself. Get PHP to do it.
/[A-Z]/
At least one capital letter
/abc/
Means ur looking for (abc) that exact same thing
/[a-c]/
This means, a b or c
/[0-9A-Z]/
Looking for several things ykwim
/[*%+,.]/
/[^0-9]/
Not between 0-9, will return the position of anything not a number
Week 13 Page 13
Week 14
Friday, April 11, 2025 2:12 PM
User
Password 8+chars and check for numbers
PHP Arrays Balance 0-x$
-> actually an ordered map, which associates each value in the array with a key
-> types of array Email [email protected]
1) Indexed -> using integers as keys First Name
Eg.
Last Name
$nums = array(10,20,30,40);
=> $nums = [10,20,30,40]; Middle
$nums = array(0=>10, 1=>20, 2=>30, 3=> 40); Initial
echo $nums[0]; Date of
$oddsIndex = array(1=>15, 3=>27, 5=>55); Birth
Problem with that one is that it gives an error when you want to iterate through it with a for loop
That generates gaps in our array ^, which we DON'T want Username
UserID
2) associative -> using strings as keys Cart Items
eg. $rains = array("Mon" => 31, "Tue"=>16, "Wed" => 5, "Thu"=> 3, "Fri"=>1);
echo $rains["Tue"];
$quarter1 = array(
"Jan" => array(100,100,200,150),
"Feb" => array(160,140,220,160),
"Mar" => array(230,165,170,250));
echo $monthly[1]["Tue"];
echo $quarter1["Jan"][2];
Superglobal arrays
access everywhere
Week 14 Page 14
Week 15
Monday, April 28, 2025 2:19 PM
Week 15 Page 15