473,396 Members | 2,087 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,396 software developers and data experts.

Dynamically Created Fields with Firefox

I want to give the user the abillity to add extra fields as needed.
I've got it working in IE (surprsingly this works in IE but not in
Firefox), however, basically I have an input field for a paragraph. If
the user decides they want two paragraps then they can click an image
and a new textarea field is show that allows them to add another
paragraph. The fields are named as an array for example name="para[0]"
the next one would then be name="para[1]". Firefox creates the field
and shows it to the user however when you submit the form the new field
does not come through. My array of paragraphs consists only of the
original number I started with. Any added by the javascript are lost.
Again IE this works fine, Firefox it works till you submit the form.
Any ideas?

Apr 4 '06 #1
5 3936
ogdenmd said on 05/04/2006 9:38 AM AEST:
I want to give the user the abillity to add extra fields as needed.
I've got it working in IE (surprsingly this works in IE but not in
Firefox), however, basically I have an input field for a paragraph. If
the user decides they want two paragraps then they can click an image
and a new textarea field is show that allows them to add another
paragraph. The fields are named as an array for example name="para[0]"
the next one would then be name="para[1]". Firefox creates the field
and shows it to the user however when you submit the form the new field
does not come through. My array of paragraphs consists only of the
original number I started with. Any added by the javascript are lost.
Again IE this works fine, Firefox it works till you submit the form.
Any ideas?


Show how you are adding the extra form controls - we can't fix what we
can't see.

Try this sample - I've used an input element, but you could use a
textarea or whatever:
<script type="text/javascript">

function addInput(el)
{
var b, o, p;
if ( document.createElement
&& (o=document.createElement('input'))
&& (p=el.parentNode)){
o.type = 'text';
o.name = 'para[' + (el.form.elements.length - 1) + ']';
b = document.createElement('br');
p.appendChild(b);
p.appendChild(o);
p.appendChild(document.createTextNode(o.name));
}
}

</script>
<form action="">
<div>
<input type="button" value="Add input"
onclick="addInput(this);">
</div>
<div><input type="submit"></input>
</form>

--
Rob
Group FAQ: <URL:http://www.jibbering.com/FAQ>
Apr 5 '06 #2
ogdenmd wrote:
I want to give the user the abillity to add extra fields as needed.
I've got it working in IE (surprsingly this works in IE but not in
Firefox), however, basically I have an input field for a paragraph. If
the user decides they want two paragraps then they can click an image
and a new textarea field is show that allows them to add another
paragraph. The fields are named as an array for example name="para[0]"
the next one would then be name="para[1]".


Is that a legal value for an attribute? Have you tried 'para0' and 'para1'?

--
Ian Collins.
Apr 5 '06 #3
Ian Collins said on 05/04/2006 11:29 AM AEST:
ogdenmd wrote:
I want to give the user the abillity to add extra fields as needed.
I've got it working in IE (surprsingly this works in IE but not in
Firefox), however, basically I have an input field for a paragraph. If
the user decides they want two paragraps then they can click an image
and a new textarea field is show that allows them to add another
paragraph. The fields are named as an array for example name="para[0]"
the next one would then be name="para[1]".

Is that a legal value for an attribute? Have you tried 'para0' and 'para1'?


Yes. The value of the name attribute for a form control is CDATA, i.e.
almost anything.

<URL:http://www.w3.org/TR/html4/interact/forms.html#adef-name-INPUT>


--
Rob
Group FAQ: <URL:http://www.jibbering.com/FAQ>
Apr 5 '06 #4
My appologies for not adding my code :(. I'll give yours a try, however
here's what I've used....

function add_paragraph(curNum) {
showNum = curNum + 1;
var para_table =
document.getElementById('desc_para').getElementsBy TagName("TBODY")[0];
var new_tr = document.createElement("TR");
var new_td = document.createElement("TD");
new_td.width = "15%";
new_td.className = "form_lable";
new_td.vAlign = "top";
new_td.innerHTML = "Description " + showNum + ":";
new_tr.appendChild(new_td);
new_td = document.createElement("TD");
txt_area_name = 'item[item_details][long_desc][' + curNum + ']';
new_td.innerHTML = "<textarea name='" + txt_area_name + "' cols='40'
rows='5' wrap='virtual'></textarea>&nbsp;<a href='javascript:void()'
onClick='javascript:add_paragraph(" + curNum + ");'><img
src='modules/constancontact/xarimages/add_para.gif' border='0' /></a>";

new_tr.appendChild(new_td);
para_table.appendChild(new_tr);
}

Apr 5 '06 #5
okay tracked the error down.....Turns out is all goes back to not
closing my original Form tag. I had started the form, then after a
couple of includes the document that actually contains the form is
called and then it should have closed it....I got the example above
working just fine outside my original program which then told me that
it wasn't Firefox that was the problem :). Big surprise there.

Apr 5 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Thomas | last post by:
Hi, I'm having a problem with the dynamically created inputfields in Internet Explorer. The situation is the following: - I have a dynamically created table with a textbox in each Cell. - It...
16
by: sirsean | last post by:
Hi all. I'm trying to dynamically build menus and objects after my page loads. Data is stored in an XML file and is parsed at runtime into Javascript objects. At the moment, I'm working on creating...
20
by: David | last post by:
I have a one-line script to add an onunload event handler to the body of the document. The script is as follows: document.getElementsByTagName("BODY").onunload=function s() {alert("s")} Now...
0
by: John Crowley | last post by:
I'm having an odd problem with viewstate and a dynamically created control inside a repeater template. Basically, I have a repeater setup like this in the aspx:
5
by: BJ | last post by:
Hi, I add label and text box fields dynamically in code using C# and ASP.NET. I set the width of the label using: Label label = new Label(); label.Width = 20; label.Text = "Test";...
3
by: ted benedict | last post by:
hi everybody, didn't find this using the search :( this is my problem: i create a dom element dynamically (<span>) and want to assign a class attribute to it such that it has some css style, this...
4
by: Stone Chen | last post by:
Hello, I have form that uses javascript createElement to add additional input fields to it. However, my validating script will not process new input fields because it can only find the named...
5
by: stellstarin | last post by:
I have a html where fields are created and added dynamically on the client side. I use the AppendChild() call to create fields dynamically. On submit i try to get the value for all the...
5
by: Amoril | last post by:
I've read quite a few different message on various boards and for some reason I'm still having trouble wrapping my head around this viewstate maintenance and trying to get these dynamically created...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.