473,386 Members | 1,758 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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 11801
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Lee Mundie | last post by:
Hi there, Simple problem here but can't seem to fix it! Okay, I have a select list from which people choose avatars... the list is option values ie. <option>Worm</option> ...
6
by: Amir Hardon | last post by:
I'm new to DOM and can't figure out this thing: I'm trying to add a row to a table with a form field in one of it's cells, but if I'm appending the field to a form it gets out of the table. Can...
2
by: Martin Nadoll | last post by:
Hello, i try to submit a form with textlink like this snippet: <a href="javascript:document.bestellen.submit()">bestellen</a> <form name="bestellen" method="post"...
7
by: exxos | last post by:
HI all, This has had me confuzzeled for a while now, I've read countless threads on such errors and it seems to be down to the way things are set out and loaded. Can anyone suggest why this...
6
by: Omar | last post by:
Hi, In a JSP I have the next: .... codigo = "<select name='" + nombre + "'>\n<option selected value='default'>Escoge</option><option value='todos'>Todos</option>"; if (miRS != null) while...
3
by: wolis | last post by:
Hi all, In an AJAX environment, is it possible to load and display some HTML and JavaScript and have that JavaScript functional? I have tried but the JavaScript functions dont appear to be...
1
by: The Eclectic Electric | last post by:
I'd be very grateful if anyone could help me with this. From my limited knowledge of Javascript I don't think it is possible, but I'll punt anyway. I downloaded and very slightly adapted this...
1
by: YotamElal | last post by:
Hello, I have a popup problem. When a popup is opened, I want all other popups to close immediatly. (except for its self and it's child popups) Here is my code: code: <!DOCTYPE HTML PUBLIC...
13
by: windsorben | last post by:
I have some javascript that checks whether or not an answer is correct. It was working fine when the question was asked with text but now that I'm asking the question with audio, the javascript no...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.