Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8143269
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T13:04:47+00:00 2026-06-06T13:04:47+00:00

I want to create a form using an unordered list ul must have only

  • 0

I want to create a form using an unordered list ul must have only two levels which I am not getting in this demo:

http://jsfiddle.net/rathoreahsan/9SCCn/

When I add a sub-list it adds one sub list of parent list (it is fine) but when I add another sub-list it adds a sub-list for newly added sub-list (that i don’t want). I want when I add sub-list it only add 1 sub-list of a parent list instead of adding sub-list of newly added sub-lists.

Current Structure:

<ul>
    <li><input type="text" />
        <ul>
            <li><input type="text" /></li> // New added sub list
                <ul> //It should'nt be like this when added more 
                    <li><input type="text" /></li>
                </ul>
            </li>
        </ul>
    </li>
</ul>

The structure should be like this:

<ul>
    <li><input type="text" />
        <ul>
            <li><input type="text" /></li> // New added sub list
            <li><input type="text" /></li> //It should be like this when added more
        </ul>
    </li>
</ul>

Edited
Finally got the solution See Workin Demo: http://jsfiddle.net/rathoreahsan/2hwLp/

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T13:04:48+00:00Added an answer on June 6, 2026 at 1:04 pm

    JQUERY

    $.fn.exists = function(){ return this.length>0; }    
    function dBtnClick(val){
        if( $('#duties li#' + val + ' ul.sublists').exists() ) 
        {
           $('#duties li#' + val + ' ul.sublists').append('<li><input type="text" /></li>')
        } 
    
       else if( !$('#duties li#' + val + ' ul.sublists').exists() ) 
       {
         $("#duties li#" + val).append('<ul class="sublists"><li><input type="text" /></li></ul>')
       }
    }
    
    
    var dutiesListID = $('#duties li#0').attr('id');
    var d_cur_no = parseInt(dutiesListID);
    
    $('#dr').click(function(){
        d_cur_no++;
        $('#duties').append('<li id="' + d_cur_no + '"><input type="text" />&nbsp;&nbsp;<a href="javascript:void(0)" onclick="dBtnClick(' + d_cur_no + ');">Add Sub List Item</a></li>');
    });
    

    HTML:

    <h3>Duties and Responsibilities:</h3>
    <ul id="duties">
        <li id="0"><input type="text" />&nbsp;&nbsp;<a href="javascript:void(0)" class="dbtn" onclick="dBtnClick(0)">Add Sub List Item</a></li>
    </ul>
    <span class="controls">
        <a href="javascript:void(0)" id="dr">Add List Item</a>
    </span>
    

    DEMO:
    http://jsfiddle.net/rathoreahsan/2hwLp/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new In ASP.NET, I want to create to Login Form using Membership
I'm trying to create a splash screen using LWUIT. I want a form to
I want to create a form which has a text entry box where a
i want to create a form that has two submit buttons, but each one
I want to create a form in which if the User presses Enter the
I have a database table named Categories . I want to create a form
I want to create a simple form for adding new products using jqModal .
I want to create simple form using CForm (yii framework) but 'elements' => array('username'=>array('type'=>'text'))
i want to create login form using sqlite in iphone view based application please
i want to create a dynamic generated form using javascript, everything works fine, until

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.