patcarvalhais / javascript-course-repo

https://lab.github.com/bitprj/javascript-with-html-and-css
0 stars 0 forks source link

Week 1 #1

Open github-learning-lab[bot] opened 3 years ago

github-learning-lab[bot] commented 3 years ago

Task 1: Environment setup and starting your first HTML file

In this task, you'll be setting up your computer to get ready to code. We'll also show you how to create a simple HTML file.

If you have not already set up your environment for this course, be sure to watch the video and download Microsoft Visual Studio Code for your machine.

github-learning-lab[bot] commented 3 years ago

Task 2: Getting user input with buttons

For task 2, we'll go over how to insert a radio button, or an option button, as well as a regular button.

Next, lets set up a form for a user to select their timezone for the clock we're going to build. To do this, we'll use radio buttons since we want to give the users a few different options to select from, but, we only want to show one time. Radio buttons are the type of buttons that you'd associate with a multiple choice question - the computer only allows you to select one bullet from a given set.

Radio buttons can be defined using the HTML input field if you set the type property to "radio".

The input field is defined just like any other tag, with the name of the element and its properties enclosed by less-than and greater-than signs, like so:

<input [property1]=[value1] [property2]=[value2]>

However, the input field is special - because it isn't a tag, it doesn't need to be closed (no need for </input>).

Next, we need to add a submit button.

Whenever we want to take in some user input involving input fields and a submit button, we want to make sure to group our relevant code in the form tag so that the computer knows what to look for. With that being said, make sure to surround your code related to the input fields and submit button with a form tag.

Finally, add a break and a div tag with a unique id right below the submit button, outside of the form tag. We will use this later to print the selected timezone.

By the end of this step, your page should look like this:

tz-buttons-1-2

Open a pull request for your code

Just as you did for the last task, be sure create a new branch, titled [your GitHub username]-[week]-[task number], for your task. As a reminder my GitHub username is danzelo1 so my branch name for week 1's second task (this assignment) would be danzelo1-1-2.

After you've created your branch, commit your code to this branch and open a pull request to merge with your main branch. When creating this request, be sure to title it appropriately in accordance with your changes, and include any specific details in your comments.

As long as there are no conflicts with the base branch, you can now merge your pull request with your main branch. From here, click on "Issues" on the top left of your screen, below the name of your repository, and click on the week (so this week would be week 1). A new comment should have appeared for your next task. This is where you'll find the instructions for task 3.

github-learning-lab[bot] commented 3 years ago

Task 3: Using JavaScript to read user input

Now that we've set up the form, we'll use JavaScript to grab the user's input for us to use in our code.

Outside of the form, but still in the body, open the script tag with its type property set to "text/javascript". This will let the computer know to read the content inside of this tag as JavaScript, not HTML.

Now, you've found and saved the timezone selected by the user!

Finally, you'll want to scroll up to your submit button

Now, your page should print out the value of whichever item the user has selected when they click the submit button, like so:

printing-tz-1-3

Open a pull request for your code

Just as you did for your previous tasks, be sure create a new branch, titled [your GitHub username]-[week]-[task number], for your task. As a reminder my GitHub username is danzelo1 so my branch name for week 1's third task (this assignment) would be danzelo1-1-3.

After you've created your branch, commit your code to this branch and open a pull request to merge with your main branch. When creating this request, be sure to title it appropriately in accordance with your changes, and include any specific details in your comments.

As long as there are no conflicts with the base branch, you can now merge your pull request with your main branch. From here, click on "Issues" on the top left of your screen, below the name of your repository, and click on the week (so this week would be week 1). A new comment should have appeared for your next task. This is where you'll find the instructions for task 4.

github-learning-lab[bot] commented 3 years ago

Task 4: Printing the time with JS

In this task, we'll show you how to print your local machine's time onto your webpage using some basic JS tools.

Next, we will print the time on your local machine onto the webpage with a simple JavaScript function.

First, define a new function inside your script tag, but outside of the function you just wrote for finding the selected radio button.

Next, create variables for the current hour, minute, and second using the respective Date functions.

Once you've defined your time variables, define a new variable to concatenate the hour, minute, and second variables, each separated by a colon (you can also add your session variable here). This will make the time show up in hour:minute:second format on your webpage.

We'll want our clock to be updated every second, so, at the bottom of the function, call the setTimeout() function with the name of your clock function and 1000 as parameters.

Lastly, to print your clock, add a break and a div tag outside of your form tags.

Now, scroll back down to your JavaScript clock function

Now, you should have a working digital clock and a form that prints the item selected!

P.S. Don't forget call your clock function once at the bottom of your script!

Open a pull request for your code

Just as you did for your previous tasks, be sure create a new branch, titled [your GitHub username]-[week]-[task number], for your task. As a reminder my GitHub username is danzelo1 so my branch name for week 1's fourth task (this assignment) would be danzelo1-1-4.

After you've created your branch, commit your code to this branch and open a pull request to merge with your main branch. When creating this request, be sure to title it appropriately in accordance with your changes, and include any specific details in your comments.

As long as there are no conflicts with the base branch, you can now merge your pull request with your main branch. From here, click on "Issues" on the top left of your screen, below the name of your repository, and click on the week (so this week would be week 1). A new comment should have appeared for your next task. This is where you'll find the instructions for task 5.