?
Solved

create textbox dynamically

Posted on 2004-11-16
5
Medium Priority
?
763 Views
Last Modified: 2008-03-06
I have created a dynamic tree menu and i have placed a checkbox in each levelitem.how to create a textbox while the checkbox of  a levelitem is checked(the textbox should be placed near the levelitem)?
0
Comment
Question by:lword
2 Comments
 
LVL 4

Accepted Solution

by:
Oliver_Dornauf earned 1000 total points
ID: 12593008
This could be done with javascript. (give http://itangersjack.com/help/CreateText.htm a try)
0
 
LVL 2

Assisted Solution

by:_the_mars_
_the_mars_ earned 1000 total points
ID: 12593851
Assuming your tree is build of <li> tags

// define click handler
function LiChange (e)
{
    // identify who sent this event
    if (e && e.target) {
        // Mozilla browsers
        myTarget = e.target;
    } else {
        // Internet Explorer
        myTarget = this;
        if (event) {
            e = event;
        }
    }
    // delete existing textareas below myTarget
    myTextareas = myTarget.getElementsByTagName('TEXTAREA');
    for (i = 0; i < myTextareas.length; i++) {
        myTextareas.item(i).parentNode.removeChild(myTextareas.item(i));
    }
    if (myTarget.checked) {
        // create textarea
        myText = document.createElement('TEXTAREA');
        // set name to name of target and append some text
        myText.name = myTarget.name + '_text';
        myTarget.appendChild(myText);
    }
}

// attach onchange handler dynamically; so you do not need to set an onchange handler in your HTML code
myLis = document.getElementsByTagName('LI');
for (i = 0; i < myLis.length; i++) {
    myLi = myLis.item(i);
    myLi.onchange = LiChange;
}
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s a season to be thankful, and we’re thankful for users like you who engage on site, solve technology problems, and network with others in the industry. What tech are we most thankful for? Keep reading.
The title says it all. Writing any type of PHP Application or API code that provides high throughput, while under a heavy load, seems to be an arcane art form (Black Magic). This article aims to provide some general guidelines for producing this typ…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

579 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question