sei-ec-remote / project-2-issues

1 stars 0 forks source link

Selecting clicked item in a dropdown #360

Closed DaceyForward closed 10 months ago

DaceyForward commented 1 year ago

What's the problem you're trying to solve?

I'm trying to keep the subject selected in the dropdown when editing a goal, but I can't seem to figure out how.

Post any code you think might be relevant (one fenced block per file)

<div class="container-sm">
    <form action="/goals/edit/<%= goal._id %>?_method=PATCH" method="POST">
        <fieldset>
            <label class="editForm form-label">Subject Area:</label>
                <select class="subSelect" name="subject" selected="<%= goal.subject %>">
                    <option value="Reading">Reading</option>
                    <option value="Writing">Writing</option>
                    <option value="Math">Math</option>
                    <option value="Behavior">Behavior</option>
                    <option value="Speech and Language">Speech and Language</option>
                    <option value="Life Skills">Life Skills</option>
                    <option value="Occupational Therapy">Occupational Therapy</option>
                    <option value="Physical Therapy">Physical Therapy</option>
                    <option value="Assistive Technology">Assistive Technology</option>
                    <option value="Social Skills">Social Skills</option>
                    <option value="Social Emotional">Social Emotional</option>
                    <option value="Vocational">Vocational</option>
                </select>      
                <br>  
            <label class="updateHere form-label">Make Your Updates Below:</label>
            <textarea type="text" class="editHere form-control" name="desc"><%= goal.desc %></textarea>
            <br>
            <input type="submit" class="btn btn-light btn-lg" value="Confirm Edit">
        </fieldset>
    </form>
</div>

If you see an error message, post it here. If you don't, what unexpected behavior are you seeing?

None

What is your best guess as to the source of the problem?

I need to add something in the ejs to make it select the already chosen and clicked subject for the goal.

What things have you already tried to solve the problem?

I've tried different things in bootstrap and html to keep the already chosen subject selected

Ex: (see photo below) The "subject area" in this image should have "math" chosen, and not "reading."

edit page

Paste a link to your repository here

https://github.com/DaceyForward/Project-2-Goal-Gather.git

asands94 commented 1 year ago

When you use selected that specifically goes on the option you want to be selected like this:

<option selected="option 1">

You may want to try having a default value that is selected such as having your first option be choose subject

DaceyForward commented 1 year ago

Okay, good idea! I just added an option for choosing a subject. That works! Thank you!