![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programmer
Join Date: Oct 2005
Location: India
Posts: 30
Rep Power: 0
![]() |
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? |
|
|
|
|
|
#2 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
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> |
|
|
|
|
|
#3 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
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 |
|
|
|
|
|
#4 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
Yeah... sucks, doesn't it? :p
|
|
|
|
|
|
#5 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
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 |
|
|
|
|
|
#6 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
Now that'd be something to see.
|
|
|
|
|
|
#7 |
|
Programmer
Join Date: Oct 2005
Location: India
Posts: 30
Rep Power: 0
![]() |
Thank you for the code, now I have to start working on it.
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|