Problem with dynamicaly adding a hidden form element. IE vs NN

P

Paul

I am trying to get a form to dynamicaly add hidden elements. Below is the
function I've created, basicaly it loops thru an array and attempts to add
those values to a newly created hidden input field which it then appends to
the form. I works in IE, but in NN7 nothing is passed.

function processAssortment(){
// get the form Element
var formElement=document.getElementById("candyBoxForm");

//loop thru the candy box contents, add them to the form
for(var x=0;x<CandyBox.size;x++){
var stringNewEle = '<input type="hidden" name="'+'name_'+x+'"
value="'+CandyBox.BoxContents[x].id+'" id='+x+'>'
newField=document.createElement(stringNewEle);
formElement.appendChild(newField);
}

document.assortmentForm.submit();

}

Thank you
Paul
 
L

Lasse Reichstein Nielsen

Paul said:
I am trying to get a form to dynamicaly add hidden elements. Below is the
function I've created, basicaly it loops thru an array and attempts to add
those values to a newly created hidden input field which it then appends to
the form. I works in IE, but in NN7 nothing is passed.

The argument to createElement is the tag name, not the entire tag. That is
a proprietary Microsoft extension.
var stringNewEle = '<input type="hidden" name="'+'name_'+x+'"
value="'+CandyBox.BoxContents[x].id+'" id='+x+'>'
newField=document.createElement(stringNewEle);

Change this to
newField = document.createElement("input");
newField.type = "hidden";
newField.name = "name_"+x;
newField.value = CandyBox.BoxContents[x].id;
newField.id = x;

/L
 
P

Paul

Thank you :)

Lasse Reichstein Nielsen said:
Paul said:
I am trying to get a form to dynamicaly add hidden elements. Below is the
function I've created, basicaly it loops thru an array and attempts to add
those values to a newly created hidden input field which it then appends to
the form. I works in IE, but in NN7 nothing is passed.

The argument to createElement is the tag name, not the entire tag. That is
a proprietary Microsoft extension.
var stringNewEle = '<input type="hidden" name="'+'name_'+x+'"
value="'+CandyBox.BoxContents[x].id+'" id='+x+'>'
newField=document.createElement(stringNewEle);

Change this to
newField = document.createElement("input");
newField.type = "hidden";
newField.name = "name_"+x;
newField.value = CandyBox.BoxContents[x].id;
newField.id = x;

/L
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top