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 777941
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T19:41:16+00:00 2026-05-14T19:41:16+00:00

I am creating a form with 5 lines of text, and each text I

  • 0

I am creating a form with 5 lines of text, and each text I am allowing the user to select if they want the text to be centered, left, or right justified. I have a unnumbered list with list elements x5.

<li><img src="images/justify_left.png" alt="left" /><span>Justify Left</span></li>
<li><img src="images/justify_center.png" alt="center" /><span>Justify Left</span></li>
<li><img src="images/justify_right.png" alt="right" /><span>Justify Left</span></li>

Each of the 5 set of <li> items refers to its respective line.

With jQuery, how would I go about determining which of the 15 <li> items did the user select so that I can correspond the proper justification as a post method?

  • 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-05-14T19:41:16+00:00Added an answer on May 14, 2026 at 7:41 pm

    On the click handler’s callback, this refers to the clicked <li>. You may want to add a class just for these list items, or place them in a div with such class, this will allow you to target them and bing the event to them. Also, note that alt is invalid here, you’re probably looking for title.

    $('li').click(function(){
       var justify = $(this).attr('alt');
       alert(justify);
    });
    

    You may want to set an hidden field to that value. You can do that, for example, by adding $('#hiddenJustify').val(justify).

    Since you have five groups of these <li>s, you probably want to group them under one element. For example:

    <div class="line-justify-group">
       <ul>
           <li>...</li>
           <li>...</li>
           <li>...</li>
       </ul>
       <input type="hidden" name="line1justify" id="line1justify" class="justify-value" />
    </div>
    

    You can then set it using the code:

    $(this).closest(".line-justify-group").find(".justify-value").val(justify);
    

    The items will then be posted to the server.

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

Sidebar

Related Questions

I'm creating a user registration form and after they fill in all the information
I am creating a form where i have to populate X form elements (text-fields
I am creating a form in c#.net . I want to populate the gridview
I am creating a form designer and have a toolbox that contains images of
I was creating a form like this : if select b, the textbox is
I am creating one form in html using table. Which have one Drop down
I am creating a form where a user will register with a struts2 application.
I am creating a form that requires the user to input their name and
I have a list of form elements. Labels go next to each element. Some
I'm creating a form with dojo, and I want a range-restricted number input field.

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.