JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsWeb DesignJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old January 11th, 2005, 01:03 PM
vbrtrmn's Avatar
vbrtrmn vbrtrmn is offline
4:04 Time Not Found
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Jan 2004
Location: Northern Virginia
Posts: 2,273 vbrtrmn User rank is Major (30000 - 40000 Reputation Level)vbrtrmn User rank is Major (30000 - 40000 Reputation Level)vbrtrmn User rank is Major (30000 - 40000 Reputation Level)vbrtrmn User rank is Major (30000 - 40000 Reputation Level)vbrtrmn User rank is Major (30000 - 40000 Reputation Level)vbrtrmn User rank is Major (30000 - 40000 Reputation Level)vbrtrmn User rank is Major (30000 - 40000 Reputation Level)vbrtrmn User rank is Major (30000 - 40000 Reputation Level)vbrtrmn User rank is Major (30000 - 40000 Reputation Level)vbrtrmn User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 22 h 10 m
Reputation Power: 337
Send a message via ICQ to vbrtrmn Send a message via AIM to vbrtrmn Send a message via MSN to vbrtrmn Send a message via Yahoo to vbrtrmn
Lightbulb Object Builder of Doom

I just finished an in-depth break-out of this code, found a few posts down.

Okay, we've been getting many many many many many questions here about createElement appendChild and all that, which is a big hassle to work with, especially if you need to add a bunch of different elements. So, I wrote this monster to help everyone out.

Code:
// p = parent id or full object - required
// i = new id - required
// t = element type (p,h1) - required
// h = innerHTML - pass '' for nothing
// a = attributes - should be passed as:  attribute=value:attribute=value:attribute=value
// z = styles - should be passed as: style=value:style=value:style=value
//     be sure to use the javascript style names, instead of the CSS ones ie: background-color == backgroundColor
// debug - this turns on alerts

function objBuilder(p,i,t,h,a,z,debug) {
	debug = (debug==1)?1:0;
	var d = document;
	var s = 'string'
	var exit=0;
	p = (typeof p==s) ? d.getElementById(p) : p;
	(typeof i!=s)?eO('New id must be a string value.'):null;
	(d.getElementById(i))?eO('An element with that id already exists.'):null;
	(typeof t!=s)?eO('Element type must be a string value.'):null;
	(typeof h!=s)?eO('innerHTML must be a string.'):null;
	(typeof a!=s)?eO('Attributes must be a string.'):null;
	(typeof z!=s)?eO('Styles must be a string.'):null;
	if(exit!=1) {
		var EL=d.createElement(t);
		p.appendChild(EL);
			EL.id=i;
			EL.innerHTML=h;
			for(var n=0;n<a.split(':').length;n++) {
				if (a.split(':')[n]=='') break;
				(!a.split(':')[n].match(/=/))?
					eO('Error in attributes missing equal (=) sign in '+ a.split(':')[n] +'.'):
					(a.split(':')[n].split('=')[0]=='class')?
						EL.className=a.split(':')[n].split('=')[1]:
						EL.setAttribute(a.split(':')[n].split('=')[0],a.split(':')[n].split('=')[1]);
			}
			for(var n=0;n<z.split(':').length;n++) {
				if (z.split(':')[n]=='') break;
				(!z.split(':')[n].match(/=/))?
					eO('Error in styles missing equal (=) sign in: '+ z.split(':')[n] +'.'):
			  	EL.style[z.split(':')[n].split('=')[0]] = (z.split(':')[n].split('=')[1].match(/^\d+$/))?
			  		z.split(':')[n].split('=')[1] +'px':
			  		z.split(':')[n].split('=')[1];
			}
		return(EL);
	}
	function eO(message) { exit=1; (debug==1)?alert(message):null; }
}


So, let's say you wanted to add a dozen TD elements to a TR...
Code:
<table>
  <tr id="tr1"></tr>
</table>

<script type="text/javascript">
   // objBuilder(p,i,t,h,a,z,debug) 
  for (var n=0;n<12;n++) {
    objBuilder('tr1','td'+n,'td','col'+n,'','',0);
  }
</script>
That's freaking it!

Please post if you need further help with this code or you want to know what kind of crack I have been smoking.
Comments on this post
benno32 agrees: Nice One

Last edited by jacktasia : March 14th, 2005 at 12:35 AM.

Reply With Quote
  #2  
Old March 2nd, 2005, 02:08 PM
vbrtrmn's Avatar
vbrtrmn vbrtrmn is offline
4:04 Time Not Found
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Jan 2004
Location: Northern Virginia
Posts: 2,273 vbrtrmn User rank is Major (30000 - 40000 Reputation Level)vbrtrmn User rank is Major (30000 - 40000 Reputation Level)vbrtrmn User rank is Major (30000 - 40000 Reputation Level)vbrtrmn User rank is Major (30000 - 40000 Reputation Level)vbrtrmn User rank is Major (30000 - 40000 Reputation Level)vbrtrmn User rank is Major (30000 - 40000 Reputation Level)vbrtrmn User rank is Major (30000 - 40000 Reputation Level)vbrtrmn User rank is Major (30000 - 40000 Reputation Level)vbrtrmn User rank is Major (30000 - 40000 Reputation Level)vbrtrmn User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 22 h 10 m
Reputation Power: 337
Send a message via ICQ to vbrtrmn Send a message via AIM to vbrtrmn Send a message via MSN to vbrtrmn Send a message via Yahoo to vbrtrmn
So, I realized that a lot of new coders will look at this mess and think WTF is vbrtrmn thinking, this code is insane!

So, here's what I'm doing..

First the basic function creation, it requires:
p = The parent id or full object of where you want to stick the new object.
i = The new id of the object you're creating
t = element type (p,h1) - required
h = innerHTML - pass '' for nothing
a = attributes - should be passed as: attribute=value:attribute=value:attribute=value
z = styles - should be passed as: style=value:style=value:style=value
be sure to use the javascript style names, instead of the CSS ones ie: background-color == backgroundColor
debug - this turns on alerts
Code:
function objBuilder(p,i,t,h,a,z,debug) {

This turns on debugging alerts, if you mess up, it will alert you
Code:
debug = (debug==1)?1:0;

These are some function variables. I like to use these, so I don't have to type as much junk.
d is basically a "shortcut to" document so I can call d.getElementById.
s just means 'string' and exit is 0.
Code:
var d = document;
var s = 'string';
var exit=0;

Here I'm checking to see if the Parent ID (p) passed in is an object or a string (s='string'; see above).
Now, you may be wondering where the heck the if statement is, using ?: is a quick way of doing if statements.
This can also be written as:
Code:
if (typeof p=='string') {
  p = document.getElementById(p);
} else {
  p = p;
}

As you can see, this is much smaller than that mess.
Code:
p = (typeof p==s) ? d.getElementById(p) : p;

This checks to see if the new id is a string.
Also can be written as
Code:
if (typeof i!='string') {
  // call eO (error out) function (see below) 
  eO('New id must be a string value.');
} else {
  null;
}

Again this is much nicer.
Code:
(typeof i!=s)?eO('New id must be a string value.'):null;

Checks to see if the i, aka new id exists, if so, error out.
Code:
(d.getElementById(i))?eO('An element with that id already exists.'):null;

These check to see if the rest of the data passed in are strings, otherwise they error out; again they can be written in long format too, but I'm lazy and having 30 lines of if/else is crap
Code:
(typeof t!=s)?eO('Element type must be a string value.'):null;
(typeof h!=s)?eO('innerHTML must be a string.'):null;
(typeof a!=s)?eO('Attributes must be a string.'):null;
(typeof z!=s)?eO('Styles must be a string.'):null;

Now the eO function, below, will set exit to 0, if anything above calls eO
Code:
if(exit!=1) {

Here I'm createing a new element, t is the type, specified, when the objBuilder function was called. I'm assigning that Element to EL
Code:
var EL=d.createElement(t);

Here I'm appending the created Element to the parent.
Code:
p.appendChild(EL);

Now, I'm going to assign the specified ID.
Code:
EL.id=i;

Now, I'm inputting any innerHTML.
Code:
EL.innerHTML=h;

Here's the tricky part, the attributes, I ask for the attributes to be sent in key/value pairs, seperated with colons, let's say you were doing a table:
border=1:cellpadding=0:cellspacing=0:width=100%
In this for loop, I am splitting the attributes at the :, this creates an array of key/value pairs... something like this:
Code:
a.split(':')[0] = 'border=1';
a.split(':')[1] = 'cellpadding=0';
a.split(':')[2] = 'cellspacing=0';
a.split(':')[3] = 'width=100%';

So, I'm getting the length, in that case it would be 4.
Code:
for(var n=0;n<a.split(':').length;n++) {

If the current key/value pair is empty, stop the for loop.
Code:
if (a.split(':')[n]=='') break;

If this key/value pair does not have an equal sign, then...
Code:
(!a.split(':')[n].match(/=/))?

...then call the eO function, and alert an error... else ...
Code:
eO('Error in attributes missing equal (=) sign in '+ a.split(':')[n] +'.'):

... else ... if ... the key (attribute name) is 'class'
This is a bit confusing too, I'm taking the current key/value pair, say border=1, and splitting it again on the =.
So, border is essentially a.split(':')[0].split('=')[0] and 1 is a.split(':')[0].split('=')[1].
Code:
(a.split(':')[n].split('=')[0]=='class')?

Set the className to the value
Code:
EL.className=a.split(':')[n].split('=')[1]:

... else ... if the key is not 'class', do a setAttribute(key,value), again splitting the current key/value pair at the =
Code:
EL.setAttribute(a.split(':')[n].split('=')[0],a.split(':')[n].split('=')[1]);

end of the attribute for loop
Code:
}

Now, I'm going to do basically the same thing with the style sheets..
Code:
for(var n=0;n<z.split(':').length;n++) {

Stop the for loop if the key/value pair is empty.
Code:
if (z.split(':')[n]=='') break;

If the key/value pair is empty ... then ...
Code:
(!z.split(':')[n].match(/=/))?

... then ... error out .. else ...
Code:
eO('Error in styles missing equal (=) sign in: '+ z.split(':')[n] +'.'):

... else ... the style name is in the left side of the equal sign, the first element.
if the value is ONLY digits .. then ..
Code:
EL.style[z.split(':')[n].split('=')[0]] = (z.split(':')[n].split('=')[1].match(/^\d*$/))?

.. then .. it is most likely a number of pixels .. else ..
Code:
z.split(':')[n].split('=')[1] +'px':

.. else .. just use the value, the second element.
Code:
z.split(':')[n].split('=')[1];

End the loop here
Code:
}

return the object
Code:
return(EL);

close the function
Code:
}

The error function, called many times, above.
Code:
function eO(message) { exit=1; (debug==1)?alert(message):null; }
Comments on this post
Markisdee agrees: Wow, quite an explaination. Kudos.
Joseph Taylor agrees: Geez man, going at this rate you might as well save it as .pdf and right a book.

Reply With Quote
  #3  
Old April 4th, 2005, 06:33 PM
ProggerPete ProggerPete is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Brisbane, Australia
Posts: 1,442 ProggerPete User rank is Sergeant (500 - 2000 Reputation Level)ProggerPete User rank is Sergeant (500 - 2000 Reputation Level)ProggerPete User rank is Sergeant (500 - 2000 Reputation Level)ProggerPete User rank is Sergeant (500 - 2000 Reputation Level)ProggerPete User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 1 Week 1 Day 1 h 37 m 42 sec
Reputation Power: 28
Ok, maybe I'm going to come across as a nay-sayer here but I don't see what the big deal is.

Quote:
<script type="text/javascript">
// objBuilder(p,i,t,h,a,z,debug)
for (var n=0;n<12;n++) {
objBuilder('tr1','td'+n,'td','col'+n,'','',0);
}
</script>


Vs

Code:
<script type="text/javascript">
insertPoint = document.getElementById('tr1');
for (var n=0;n<12;n++) {
	var newCell = document.createElement('td');
	newCell.id = 'td' + n;
	newCell.innerHTML = 'col' + n;
	insertPoint.appendChild(newCell);
}
</script>


Doesn't seem like a huge improvement to me. I think the standard method is easier to read & understand and I'd prefer not having to remember what each of the parameters for the objBuilder function are.
__________________
Like the answers I give? Why not ask me directly at my forum. I'm always glad to help.

Javascript scripts and tips can be found at Dynamic Tools.
Check out DynamicTable, the best javascript table sorter around.
Get reliable and affordable hosting at www.thinksmarthosting.com

Reply With Quote
  #4  
Old April 4th, 2005, 09:36 PM
Markisdee's Avatar
Markisdee Markisdee is offline
Contributing User
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Dec 2003
Posts: 2,346 Markisdee User rank is Colonel (50000 - 60000 Reputation Level)Markisdee User rank is Colonel (50000 - 60000 Reputation Level)Markisdee User rank is Colonel (50000 - 60000 Reputation Level)Markisdee User rank is Colonel (50000 - 60000 Reputation Level)Markisdee User rank is Colonel (50000 - 60000 Reputation Level)Markisdee User rank is Colonel (50000 - 60000 Reputation Level)Markisdee User rank is Colonel (50000 - 60000 Reputation Level)Markisdee User rank is Colonel (50000 - 60000 Reputation Level)Markisdee User rank is Colonel (50000 - 60000 Reputation Level)Markisdee User rank is Colonel (50000 - 60000 Reputation Level)Markisdee User rank is Colonel (50000 - 60000 Reputation Level)Markisdee User rank is Colonel (50000 - 60000 Reputation Level) 
Time spent in forums: 1 Month 3 Days 10 h 59 m 31 sec
Reputation Power: 577
Send a message via AIM to Markisdee
Well, the objbuilder function is more flexable and easier for beginners of javascript. It can be used multiple times to add different content, where your method would have to have a separate function for each instance.

That said, I always prefer writing my own code as well.
__________________

Reply With Quote
  #5  
Old April 5th, 2005, 01:34 AM
vbrtrmn's Avatar
vbrtrmn vbrtrmn is offline
4:04 Time Not Found
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Jan 2004
Location: Northern Virginia
Posts: 2,273 vbrtrmn User rank is Major (30000 - 40000 Reputation Level)vbrtrmn User rank is Major (30000 - 40000 Reputation Level)vbrtrmn User rank is Major (30000 - 40000 Reputation Level)vbrtrmn User rank is Major (30000 - 40000 Reputation Level)vbrtrmn User rank is Major (30000 - 40000 Reputation Level)vbrtrmn User rank is Major (30000 - 40000 Reputation Level)vbrtrmn User rank is Major (30000 - 40000 Reputation Level)vbrtrmn User rank is Major (30000 - 40000 Reputation Level)vbrtrmn User rank is Major (30000 - 40000 Reputation Level)vbrtrmn User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 22 h 10 m
Reputation Power: 337
Send a message via ICQ to vbrtrmn Send a message via AIM to vbrtrmn Send a message via MSN to vbrtrmn Send a message via Yahoo to vbrtrmn
Pete, imagine that you had to create 500 objects/elements on the fly, your way would take a bloody long time. Now imagine, adding attributes, styles, and what not to each of those elements, damn, that would be a lot of code!
Comments on this post
jacktasia agrees!
Cheesefood agrees!
__________________
I am so smart, I am so smart, S.M.R.T ... I mean S.M.A.R.T.

Stop Using Pop-Ups

Reply With Quote
  #6  
Old April 5th, 2005, 08:18 PM
ProggerPete ProggerPete is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Brisbane, Australia
Posts: 1,442 ProggerPete User rank is Sergeant (500 - 2000 Reputation Level)ProggerPete User rank is Sergeant (500 - 2000 Reputation Level)ProggerPete User rank is Sergeant (500 - 2000 Reputation Level)ProggerPete User rank is Sergeant (500 - 2000 Reputation Level)ProggerPete User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 1 Week 1 Day 1 h 37 m 42 sec
Reputation Power: 28
If you want 500 near identical elements either way will work fine. If you want 500 wildly different elements I'd use your script, it's still going be a lot of code and take a long time though. In that sort of situation most of the time will be spent typing in id's, attributes etc anyway.

I still take my hat off to you for helping out the javascript noobies and I suspect this thread will stop a lot of the 'how do i add an object' posts.

Reply With Quote
  #7  
Old August 10th, 2005, 06:06 AM
KorRedDevil's Avatar
KorRedDevil KorRedDevil is offline
Contributing User
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Aug 2005
Location: Bucharest ROMANIA
Posts: 2,557 KorRedDevil User rank is Brigadier General (60000 - 70000 Reputation Level)KorRedDevil User rank is Brigadier General (60000 - 70000 Reputation Level)KorRedDevil User rank is Brigadier General (60000 - 70000 Reputation Level)KorRedDevil User rank is Brigadier General (60000 - 70000 Reputation Level)KorRedDevil User rank is Brigadier General (60000 - 70000 Reputation Level)KorRedDevil User rank is Brigadier General (60000 - 70000 Reputation Level)KorRedDevil User rank is Brigadier General (60000 - 70000 Reputation Level)KorRedDevil User rank is Brigadier General (60000 - 70000 Reputation Level)KorRedDevil User rank is Brigadier General (60000 - 70000 Reputation Level)KorRedDevil User rank is Brigadier General (60000 - 70000 Reputation Level)KorRedDevil User rank is Brigadier General (60000 - 70000 Reputation Level)KorRedDevil User rank is Brigadier General (60000 - 70000 Reputation Level)KorRedDevil User rank is Brigadier General (60000 - 70000 Reputation Level) 
Time spent in forums: 4 Weeks 5 h 34 m 26 sec
Reputation Power: 614
Send a message via Yahoo to KorRedDevil
There might be a middle way. When coding, I use 3 "subroutine" functions:
PHP Code:
function cE(el){
this.obj=document.createElement(el);
return 
this.obj;
}
function 
cT(txt){
this.obj=document.createTextNode(txt);
return 
this.obj;
}
function 
cA(obj,att,val){
obj.setAttribute(att,val);
return


and along with a removing all the childs and finding abolute position subroutines, if neded:
PHP Code:
function rC(obj){
while(
obj.hasChildNodes()){
obj.removeChild(obj.childNodes[0])
}

function 
fP(obj,x,y){
while(
obj.offsetParent){
if(
obj==document.getElementsByTagName('body')[0]){break;}
else{
x=x+obj.offsetParent.offsetLeft;
y=y+obj.offsetParent.offsetTop;
obj=obj.offsetParent;
}
}
this.x=x;this.y=y;
return 
this.x;
return 
this.y;
}



would help me to shorten the codes and make them easily to handle.

-------
by the way, vbrtrmn... innerHTML is not a standard DOM method. You may use
object.firstChild.nodeValue='some text'
or better (nodeValue is in fact a read-only property but, surprisingly, sometimes can be used as a writing method)
object.firstChild.data='some text'
or
object.appendChild(document.createTextNode('some text'))

Reply With Quote
  #8  
Old September 23rd, 2005, 11:16 AM
Joseph Taylor's Avatar
Joseph Taylor Joseph Taylor is offline
c0der
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jun 2005
Location: Vancouver
Posts: 665 Joseph Taylor User rank is First Lieutenant (10000 - 20000 Reputation Level)Joseph Taylor User rank is First Lieutenant (10000 - 20000 Reputation Level)Joseph Taylor User rank is First Lieutenant (10000 - 20000 Reputation Level)Joseph Taylor User rank is First Lieutenant (10000 - 20000 Reputation Level)Joseph Taylor User rank is First Lieutenant (10000 - 20000 Reputation Level)Joseph Taylor User rank is First Lieutenant (10000 - 20000 Reputation Level)Joseph Taylor User rank is First Lieutenant (10000 - 20000 Reputation Level)Joseph Taylor User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 2 Weeks 31 m 38 sec
Reputation Power: 154
Certainly makes it simpler, and it doesn't interfere with anything so rock on.

Anything that makes my life as a coder easier is welcome. Hail object oriented programming (or prototype based)!

Reply With Quote
  #9  
Old September 27th, 2005, 05:41 PM
jsKid's Avatar
jsKid jsKid is offline
Application is what Divides Us
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Dec 2002
Location: Titusville, FL
Posts: 2,179 jsKid User rank is Sergeant Major (2000 - 5000 Reputation Level)jsKid User rank is Sergeant Major (2000 - 5000 Reputation Level)jsKid User rank is Sergeant Major (2000 - 5000 Reputation Level)jsKid User rank is Sergeant Major (2000 - 5000 Reputation Level)jsKid User rank is Sergeant Major (2000 - 5000 Reputation Level)jsKid User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 2 Weeks 2 Days 15 h 44 m 6 sec
Reputation Power: 57
Send a message via AIM to jsKid Send a message via MSN to jsKid
MySpace
ObjBuilder v2

ObjBuilder_v2 ... not really... just a few new things. A breakdown below...

Code:
function getObj(ref){
  if (document.getElementById){ return document.getElementById(ref); }
  if (document.all){            return document.all[ref];            }
  if (document.layers){         return document.layers[ref];         }
}

function objBuilder_v2(d,pRef,obj,ref,val,att,sty){

  // d         debug
  // pRef      parent reference
  // obj       element to be created dynamically
  // ref       object reference
  // val       the dynamic element's node value
  // attr      the dynamic element's attributes
  // s         the dynamic element's styles

  var msgError = 'The following errors have occured:\n\n';
  var debug    = (d==1) ? 1 : 0;
  var s        = 'string';
  var _parent  = (typeof(pRef)==s) ? getObj(pRef) : pRef;

  (typeof(ref) !== s) ? msgError += 'Element reference must be a string.\n'            : null;
  (getObj(ref))       ? msgError += 'An element with that reference already exists.\n' : null;
  (typeof(obj) !== s) ? msgError += 'Element must be a string.\n'                      : null;
  (typeof(val) !== s) ? msgError += 'Element node value must be a string.\n'           : null;
  (typeof(att) !== s) ? msgError += 'Element attributes must be a string.\n'           : null;
  (typeof(sty) !== s) ? msgError += 'Element styles must be a string.\n'               : null;

  var el;
  var tmp= (obj.match(/=/)) ? obj.split('=') : null;
  if (obj.match(/=/)){
    el       = document.createElement(tmp[0]);
    (obj.match(/textarea/)) ? (el.rows=tmp[1].split('|')[0],el.cols=tmp[1].split('|')[1]) : el.type= tmp[1];
    el.value = val;
  }else{
    el = document.createElement(obj);
    el.appendChild(document.createTextNode(val));
  }
  _parent.appendChild(el);
  el.name= ref;
  el.id= ref;
  var attS= att.split(':');
  for (var i=0; i < attS.length; i++){
    if (attS[i] == ''){ break; }
    (!attS[i].match(/=/))
      ? msgError += 'Missing equal sign in ' + attS[i] +'.\n'
      : (attS[i].split('=')[0]=='class')
          ? el.className= attS[i].split('=')[1]
          : el.setAttribute(attS[i].split('=')[0], attS[i].split('=')[1]);
  }
  var styS=sty.split(':');
  for (var i=0; i < styS.length; i++){
    if (styS[i]==''){ break; }
    (!styS[i].match(/=/))
      ? msgError += 'Style missing equal sign in: '+ styS[i] +'.\n'
      : el.style[styS[i].split('=')[0]]= ((styS[i].split('=')[1].match(/^\d+$/)) ? styS[i].split('=')[1] +'px' : styS[i].split('=')[1]);
  }
  _parent.appendChild(el);

  (debug==1 && msgError !== 'The following errors have occured:\n\n') ? window.alert(msgError) : null;
}


Specify input types, and value
Code:
 objBuilder_v2(1,'parentObj','input=text','inpText1','Text Input Value 1','','fontFamily=Arial:fontSize=11px');


Specify textarea's rows and columns
Code:
 objBuilder_v2(1,'parentObj','textarea=5|15','tarea1','Textarea Value 1','','fontFamily=Arial:fontSize=16px');
Comments on this post
vbrtrmn agrees: nice mods!
__________________
Download [ Fx | Op ] Validate [ Markup | Css ]

Reply With Quote
  #10  
Old May 23rd, 2008, 09:52 PM
Joseph Taylor's Avatar
Joseph Taylor Joseph Taylor is offline
c0der
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jun 2005
Location: Vancouver
Posts: 665 Joseph Taylor User rank is First Lieutenant (10000 - 20000 Reputation Level)Joseph Taylor User rank is First Lieutenant (10000 - 20000 Reputation Level)Joseph Taylor User rank is First Lieutenant (10000 - 20000 Reputation Level)Joseph Taylor User rank is First Lieutenant (10000 - 20000 Reputation Level)Joseph Taylor User rank is First Lieutenant (10000 - 20000 Reputation Level)Joseph Taylor User rank is First Lieutenant (10000 - 20000 Reputation Level)Joseph Taylor User rank is First Lieutenant (10000 - 20000 Reputation Level)Joseph Taylor User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 2 Weeks 31 m 38 sec
Reputation Power: 154
Quote:
Originally Posted by Joseph Taylor
Geez man, going at this rate you might as well save it as .pdf and right a book.


I wonder how old that comment is? I can't believe I rote that.

Reply With Quote
  #11  
Old May 23rd, 2008, 11:31 PM
Kravvitz's Avatar
Kravvitz Kravvitz is offline
CSS & JS/DOM Adept
Dev Shed God 30th Plane (19500 - 19999 posts)
 
Join Date: Jul 2004
Location: USA
Posts: 19,893 Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level) 
Time spent in forums: 6 Months 2 Days 18 h 21 m 56 sec
Reputation Power: 4192
Quote:
Originally Posted by Joseph Taylor
Quote:
Originally Posted by Joseph Taylor
Geez man, going at this rate you might as well save it as .pdf and right a book.

I wonder how old that comment is? I can't believe I rote that.

2 years, probably. Must we go off-topic in a stickied thread?
Comments on this post
vbrtrmn agrees: Probably time to unsticky this, heh.
__________________
Spreading knowledge, one newbie at a time. I'm available for hire at Dynamic Site Solutions.

Check out my blog. | Learn CSS. | PHP includes | X/HTML Validator | CSS validator | Common CSS Mistakes | Common JS Mistakes

Remember people spend most of their time on other people's sites (so don't violate web design conventions).

Reply With Quote
  #12  
Old October 30th, 2009, 06:05 AM
sirtaxster sirtaxster is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2009
Posts: 81 sirtaxster User rank is Sergeant Major (2000 - 5000 Reputation Level)sirtaxster User rank is Sergeant Major (2000 - 5000 Reputation Level)sirtaxster User rank is Sergeant Major (2000 - 5000 Reputation Level)sirtaxster User rank is Sergeant Major (2000 - 5000 Reputation Level)sirtaxster User rank is Sergeant Major (2000 - 5000 Reputation Level)sirtaxster User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 3 h 40 m 2 sec
Reputation Power: 32
Just reading this gives me a headache.

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignJavaScript Development > Object Builder of Doom

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap