I apologize if this question has been answered before, I've tried searching but haven't found anything that's helped me with this issue. On to the issue!
I'm attempting to update a community character sheet for Roll20. The sheet uses both HTLM and Javascript. I am trying to set up the sheet so that when a player selects the power type of the spell he's using (think spell school from D&D) it places a different icon onto the button for the spell.
The spells are contained within an HTML button component of a repeating_spell container that is designed to create new, unique buttons for each spell.
I am able to successfully have the image be a static image, the same image no matter the power type, but am unsure of how to dynamically change the HTML img tag based on the power type.
I recently realized that the site I'm designing this character sheet for doesn't allow the id flag within the img tag. I've edited my code to show the change. I'm currently trying to do this using the name= flag, and I'm not sure if the jQuery is finding it as I get no image returned. This is the current code for my img tag:
<img name="powertype" src="#" style="width: 15px; height: 15px; padding: 2px;">
with appropriate JS/jQuery references set in an if/else loop which checks the attribute set by the drop down using the following code:
on("change:spellschool", function(eventinfo){
getAttrs(["spellschool"], function(v) {
var spell_school = spellschool.toLowerCase();
if(spell_school === "biotic") {
document.getElementById("powertype").src = "https://n7.world/images/spells/biotic.svg";
}
else if(spell_school === "combat") {
document.getElementById("powertype").src = "https://n7.world/images/spells/combat.svg";
}
else if(spell_school === "tech") {
document.getElementById("powertype").src = "https://n7.world/images/spells/tech.svg";
}
else {
return;
}
});
});
However when I have the above code set, it simply returns a blank image with padding.