I'm using Dojo Drag and Drop. When a user adds an item to a container (div dojoType='dojo.dnd.Source') then I need to get that data into a form so I can later process it on a server when the user submits the whole page. That part is working. Then to remove an item, I allow them to drag/drop an item to a "trash" container. I'm having difficult conceptualizing how to remove the item from the hidden fields. I already have subscribe/event code to call the following two functions.
Can you let me know if there is better way to do the removeGoalFromHiddenFields function? There can be many "subgoal" items.
I'm about to begin testing with what I have below, but I have some doubts about it.
Thanks,
Neal Walters
function addGoalToHiddenFields( goalText){
var field = document.createElement("input");
field.setAttribute("type","hidden");
field.setAttribute("value",goalText);
field.setAttribute("name","subgoal");
//add new hidden-element to the existing form
document.getElementById("form1").appendChild(field);
}
function removeGoalFromHiddenFields( goalText){
//remove hidden field
nodes = document.getElementById("form1")
for (i=0;i<nodes.length ;i++ )
{
var pos = nodes[i].innerHTML.IndexOf(goalText)
if (pos > 0)
{
nodes.removeChild(node[i]);
}
}
}
Also, can I do this instead: nodes = document.getElementById("subgoal")