Now I want to be able to access the individual radio button id and whether it has been checked or not.
I would think JSON.stringify is needed as first step?
I had tried that earlier actually with a forEach loop, and this was returned:
[object HTMLCollection]
interactive-rating.js:20 value: [
interactive-rating.js:20 value: o
interactive-rating.js:20 value: b
interactive-rating.js:20 value: j
interactive-rating.js:20 value: e
interactive-rating.js:20 value: c
interactive-rating.js:20 value: t
interactive-rating.js:20 value:
etc.
I have tried this
function getString(obj){
[...obj].forEach(function(value,index){
return('value:',value);
});
}
container = JSON.stringify(container,getString(container));
function getString(obj){
[...obj].forEach(function(value,index){
return('value:',value);
});
}
function getClass(className){
return document.getElementsByClassName(className);
}
//'page' variable is returned by another function, but not relevant
window.addEventListener('click',function(){
if(page === 'index.html'){
let htmlArr = getClass('form-control');
htmlArr = JSON.stringify(htmlArr,getString(htmlArr));
sessionStorage.setItem("htmlArr", htmlArr);
}
});
I use sessionStorage.getItem(‘htmlArr’) for another page, and it returns: votesArr: {"0":{},"1":{},"2":{},"3":{},"4":{}}
I’m actually getting some errors now in github.
It works just fine on my laptop, I can select a button, click submit, and it will display the correct radio button number.
But on github I’m getting error messages?
Could this something in getPage() , the url is wrong or such?
Hi, I hope you can help. I think it’s a github issue, as my code works fine with no errors on my laptop ,just in github deployment it’s throwing this error (before any click/submit):
Error with Permissions-Policy header: Origin trial controlled feature not enabled: ‘interest-cohort’.
Do you have a link to the live project showing the error? You linked to the project code on GitHub.
EDIT: Never mind. I found the live url.
The only error I see when the page loads is:
interactive-rating.js:8 Uncaught TypeError: Cannot read properties of null (reading 'join')
at getPage (interactive-rating.js:8:30)
at interactive-rating.js:26:15
The error has to do with the way you are attempting to parse the url to get the page. The home page will load the index.html file by default but the url will not show it at the end, so pageArray will be null.
The interest-cohort is just a warning that you can ignore. It has to do with how GitHub hosted pages disable FloC.
I also noticed you did not try to incorporate the code I wrote that would allow you to get the id of the the checked radio button. Instead, you wrote a ton of repeated code.
I did yes, I’m a bit stressed atm as I’m going on a overseas trip soon, so wanted this done asap to avoid the stress .
It does work though , I’m still learning, I will experiment with your code as well when I get back
I also mentioned your help in the readme.md file
Thanks!