Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Mar 6th, 2006, 10:01 PM   #1
Uday
Programmer
 
Join Date: Oct 2005
Location: India
Posts: 30
Rep Power: 0 Uday is on a distinguished road
To name the text box automatically

Is it possible to name the text boxes that are created automatically and how to do it?

ex:

for(i=0;i<;i++)
{
document.write('<input type="text" name=?>');
}

Is it possible to have something in place of the question mark that will help in automatically give names like matix[1], matrix[2], matrix[3] etc.

Another question is whether it is possible to declare two dimensional arrays using javascript?
Uday is offline   Reply With Quote
Old Mar 7th, 2006, 1:07 PM   #2
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
Sure it is. I would advise against using document.write() though - it's on its way out. Use the innerHTML property of the element instead.

<script type="text/javascript">
function ShowTextBoxes (count)
{
    var textBoxes = document.getElementById("textboxes");
    
    var HTML = "";
    for (i = 0; i < count; i++)
    {
        HTML += '<input type="text" name="' + i + '" />\n';
    }
    
    textBoxes.innerHTML = HTML;
}
</script>

<div id="textboxes">
</div>
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Mar 7th, 2006, 1:36 PM   #3
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Even innerHTML is taking a hit from other forms of child-element specification and content. For more than minor messing around, good page design these days will require some significant study of (X)HTML, CSS, and the DOM in general.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Mar 7th, 2006, 2:20 PM   #4
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
Yeah... sucks, doesn't it? :p
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Mar 7th, 2006, 2:40 PM   #5
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Yeah. Even though cross-browser support and page design is a lot easier than it was in 1999-2000, it's still (for me) a headache. Fortunately, the big scare against script seems to be undergoing a reversal; things like the Google Maps API and such require it for functionality. It at least allows one to hack recalcitrant browsers like IE. All in all, I'd rather write a C++ program to poke me in the eye with a sharp object.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Mar 7th, 2006, 3:33 PM   #6
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
Now that'd be something to see.
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Mar 13th, 2006, 6:58 AM   #7
Uday
Programmer
 
Join Date: Oct 2005
Location: India
Posts: 30
Rep Power: 0 Uday is on a distinguished road
Thank you for the code, now I have to start working on it.
Uday is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 1:35 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC