Hey, I’m a complete beginner when it comes to any kind of programming language and I just started learning on here and Khan Academy. I currently have a project I’m working on while I learn to try and help me and have a good reference to fall back on in the future that I wrote and understand. I made a very basic example of what I need help with in the pen below. Can someone please show me an example of the JS function needed. Thank you.
Wow thank you seeing it like this really helps me understand better!
Thank you, I really appreciate it.
for some reason I still can’t get it to work is there any way you could view my project its hosted on codepen, i’m open to any advice you may have i’m sure my code is horrendous lol but i’m practicing. I only have the first selection page built so far but its coming up with a 404 error when I try it.
on the index page, click on the reroof img
then keep the first radio button selected and click Submit,
I want it to then load reroofShingles.html
now i’m getting the alert message even though my first radio button is selected.
I renamed the id and name in the html code
input id=“submit” class=“submit” type=“submit” value=“Submit” name=“submit”
window.addEventListener(‘load’, function() {
var submit = document.getElementById(‘submit’);
submit.addEventListener(‘click’, function(event) {
event.preventDefault();
var pages = document.getElementsByName(‘links’);
for (var i = 0, page = “”; i < pages.length; i++) {
if (pages[i].checked) {
page = pages[i].id + “.html”;
Ok thank you, I’ll look into that and hopefully it covers it here. I still don’t see any spelling discrepancy but I’ll keep looking. Do I have my script tag right in the html? is there a problem that my submit button has the same name and id?
var submit = document.getElementById(‘Submit’);
When I change “S” in (‘Submit’); to capitol it reloads the existing page. Is that right and I just don’t have my files organized right or something?
page = pages[i].id + “.html”;
it says the pages id + .html, well the id for the button for shingles is id=“reroofShingles” and the file for the page I wont it to load is saved as reroofShingles.html
Thanks why i’m confused I guess by that line of code it makes me think it will just add .html to the end of what ever the selected radio id is
and if I change the name of the radio button then it wont be grouped with the other buttons right? Meaning the user would be able to select more than one option. I’m sorry i’m so new at this, I’m hoping it eventually starts making more sense.