Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-09-2009, 01:11 AM   PM User | #1
markjohnson
New Coder

 
Join Date: Feb 2009
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
markjohnson is an unknown quantity at this point
prototype: How to wrap an input field with span tag...

Hello everyone,

I am not at all a JavaScript expert so please bear with me.

Please have a look at the following code:

Code:
		add_option_link.onclick = function() {
				j++;
				
				var tr = document.createElement("tr");

				var td = document.createElement("td");
				Element.insert(td, "Option " + j);
				tr.appendChild(td);

				var td = document.createElement("td");
				var input = document.createElement("input");
				input.name = "options["+i+"][option]["+j+"][display]";
				Element.insert(td, input);			
				tr.appendChild(td);

				var td = document.createElement("td");				
				var input = document.createElement("input");
				input.name = "options["+i+"][option]["+j+"][option_number]";
				Element.insert(td, input);
				tr.appendChild(td);

				var td = document.createElement("td");
				var input = document.createElement("input");
				input.name = "options["+i+"][option]["+j+"][price]";
				Element.insert(td, input);
				tr.appendChild(td);
				
				var td = document.createElement("td");
				var a = document.createElement("a");
				a.href = "";
				Element.insert(a, "delete");
				a.onclick = function() {
					tr = this.parentNode.parentNode;
					Element.remove(tr);
					return false;
				}
				Element.insert(td, a);
				tr.appendChild(td);

				Element.insert(options_table, tr);
				
				return false;
			}
This is obviously generating tr's and td's with input fields in them.

I would like the input field marked in red above (lines 25, 26) to be wrapped by <span> tags...

Hence, it should appear in HTML as follows:

Code:
<span id="sprytextfield1">
<input name="options[1][option][1][option_number]"/>
<span class="textfieldRequiredMsg">A value is required.</span></span>
I have no idea how to achieve this with the code above, and any help will be greatly appreciated.

Many thanks!
markjohnson is offline   Reply With Quote
Reply

Bookmarks

Tags
prototype, span

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:59 PM.


Advertisement
Log in to turn off these ads.