469,625 Members | 1,097 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,625 developers. It's quick & easy.

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

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
Jul 20 '05 #1
2 11637
"Paul" <pa********@hotmaill.com> writes:
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
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #2
Thank you :)

"Lasse Reichstein Nielsen" <lr*@hotpop.com> wrote in message
news:65**********@hotpop.com...
"Paul" <pa********@hotmaill.com> writes:
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
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors:

<URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html> 'Faith without judgement merely degrades the spirit divine.'

Jul 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Lee Mundie | last post: by
6 posts views Thread by Amir Hardon | last post: by
2 posts views Thread by Martin Nadoll | last post: by
7 posts views Thread by exxos | last post: by
3 posts views Thread by wolis | last post: by
1 post views Thread by The Eclectic Electric | last post: by
1 post views Thread by YotamElal | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.