0

I have a list of string items on a html page, as follows-

<h1><b>Subject Groups</b></h1>
        <div id="listContainer">
            <div class="listControl">
            </div>
            <ul id="expList">
                <li>
                    Maths 
                    <ul>
                        <li>
                            John Smith       
                        </li>
                        <li>
                            Jane Smith
                        </li>
                        <li>
                            Elvis Presley
                        </li>
                    </ul>
                </li>
                <li>
                    Science 
                    <ul>
                    <li>
                    Jane Smith
                    </li>
                    <li>
                    Kate Smith
                    </li>
                    </ul>
                </li>
                <li>
                    Literature
                    <ul>
                        <li>
                            Kate Smith
                        </li>
                        <li>
                            Tom Hanks
                        </li>
                    </ul>
                </li>
                <li>
                <a href = "JavaScript:newPopup('new.html');"<b>New Student..</b></a>
                </li>
            </ul>

At the end of the list, there is a link to a pop up form which allows you to input a new student and select via checkboxes what subjects that person is studying-

<form action="" style= "font-size: 16pt">

<h3> First Name: </h3>

    <div class="input-group">
      <input type="text" class="form-control">

      <h3> Last Name: </h3>

    <div class="input-group">
      <input type="text" class="form-control">


      <h3> Email Address: </h3>

    <div class="input-group">
      <input type="text" size="70" class="form-control">

    </div><!-- /input-group -->

    <h3> Select the subjects that this student will study: </h3>


<input type="checkbox" name="Maths" value="Maths"> &nbsp Maths<br>
<input type="checkbox" name="Science" value="Science"> &nbsp Science<br>
<input type="checkbox" name="Literature" value="Literature"> &nbsp Literature>
<input type="button" class="btn btn-lg btn-primary btn-block" value="Submit" />
</form>

My question is- how would I go about using the onClick event of the submit button to take the first name and last name of a newly created student and add them to the appropriate subject category in my list? Is that possible without having a database behind it?

1

1 Answer 1

2

I think it will be easy to do with jquery...just give each subject an a ID to like e.g <li id="Maths"> then when user submits form get the checkbox value and use .append to add to the list e.g.

> $(chekBoxValue).append("<li>"+name+'</li>');

hope this helps

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.