zarocknz/javascript-winwheel

Pass textbox values to Segments

Closed this issue · 1 comments

Hello,

First. Thank you for creating this script. It's great, and just what I was looking for. I'm creating a tool that people can enter their names in textbboxes, and I want these to be updated on to the segments (there might be a variable number of names). I can't figure out a way to dynamically create the segment options to send to the New Winwheel function.

Currently I have a loop building up the segment values text and then I try and pass that, but don't seem to be having any luck.

Do you have any suggestions as the best way to achieve this?

Many Thanks,

Adam

Managed to figure out how to pass the values into the array when the wheel is created, thought I would share if anyone else is struggling:

        //setup the array and criteria for the segments
        var segStyle = {};
        var segFinal = [];
        
        var segId = 0;
        
        //build the segment values
        for (i = 0; i < b; i++) 
        {
        		segId++;
        			if (segId > actNum) {
        			segId = 1;
        			segName = "name-" + segId;
								segFinal.push({fillStyle:"#ffffff", text: document.getElementById(segName).value});
								} else {
								segName = "name-" + segId;
								segFinal.push({fillStyle:"#ffffff", text: document.getElementById(segName).value});
    						}	    						
    			}