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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T18:27:44+00:00 2026-05-13T18:27:44+00:00

The intent is to use an html dialog box as a settings page for

  • 0

The intent is to use an html dialog box as a settings page for a program. In this settings page, the user can create a list of salespeople that can be selected later on from a drop-down box. My goal now, is to add a checkbox that indicates witch salesperson is the default selection in that drop-down list.

Here’s what i have so far:

This is the .js function that creates the html salespersons-table list.

function addSalespersonRow(id, name, phone, email, defsales) {
var newRow = $('<tr>'+
    '<td><input type="hidden" class="id" /><input class="name" size="20" /></td>'+
    '<td><input class="phone" size="15"/></td>'+
    '<td><input class="email" size="30"/></td>'+
    '<td><input type="checkbox" class="defsales"</td>'+
    '<td><a href="#" onclick="$(this).parent().parent().remove(); return false;">Delete</a></td>'+
    '</tr>');
if (id === undefined) {
    id = new Date().getTime();
}
$('.id', newRow).val(id);


if (name !== undefined) {
    $('.name', newRow).val(name);
}
if (phone !== undefined) {
    $('.phone', newRow).val(phone);
}
if (email !== undefined) {
    $('.email', newRow).val(email);
}
if (defsales !== undefined) {
    $('. defsales', newRow).val(defsales)
}

$('#salespersons-table tbody').append(newRow);

return false;

This is the part of the html that displays the list.

    <fieldset>
        <legend>Sales Person Information</legend>
        <table class="text-c" id="salespersons-table" width=100%>
            <thead>
                <tr>
                    <th>Name</th>
                    <th>Phone</th>
                    <th>Email</th>
                    <th>Default</th>
                    <th></th>
                </tr>
            </thead>
            <tbody></tbody>
        </table>
        <a href="#" onclick="return addSalespersonRow();">Add new Salesperson</a>
        <input type="hidden" id="salespersons" />
    </fieldset>

So far the only thing that’s not working is that the user can select any or all checkboxes. “I need help figuring out how to limit them to one choice as the default.”

Then when the user saves the settings, this part of the .js saves the data to .dat file.

function saveSettings() {

var salespersons = [];
$('#salespersons-table tbody tr').each(function(){
    var salesperson = '{';
    salesperson += '"id"=>"' + $('.id', this).val() + '",';
    salesperson += '"name"=>"' + $('.name', this).val() + '",';
    salesperson += '"phone"=>"' + $('.phone', this).val() + '",';
    salesperson += '"email"=>"' + $('.email', this).val() + '",';
    salesperson += '"defsales"=>"' + $('. defsales', this).val() + '"';
    salesperson += '}';
    salespersons.push(salesperson)
});
$('#salespersons').val('['+salespersons.join(', ')+']');

The .dat entry looks like this.

 "defsales"on"name"Bob Summers"id"1254233372387"phone"(953) 684-9557"email"bsummers@company.com

As you can see, the checkbox for this person was checked. This value is either “on” or “”.
The problem i have now is that when the settings.html is reopened, the above salespersons checkbox is not checked indicating no default selection was made. So if the user does not notice this and re-saves their settings, there previous choice will be lost.

any help you can give would be great.

thanks for enduring my long question-explanation.

  • 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-13T18:27:45+00:00Added an answer on May 13, 2026 at 6:27 pm

    I figured out how to limit their choices to one. As it turns out, I needed to be using radio buttons. Radio buttons buy default, only allow one to be selected. In order for this to work, the radio button will need to compare itself with all others of its kind to know if it’s the only one checked. So to do this, I had to give all of the dynamically created radios the same name.

    So I corrected this line:

    '<td><input type="checkbox" class="defsales"</td>'+
    

    To look like this:

    '<td><input type="radio" name="ds" class="defsales" /></td>'+
    

    Now all I need, is to figure out how to get the radio to display the saved selection at lunchtime.

    Any suggestions?

    Cheers,

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

Sidebar

Related Questions

I intend to use Javascript to dynamically create a group of html elements (input
I want my intent to be launched when the user goes to a certain
I'm a little embarrassed to post this but I can't seem to figure out
I have the following code that works fine in IE: <HTML> <BODY> <script language=JavaScript>
I want to teach myself enough machine learning so that I can, to begin
I'm trying to use XPath in PHP and I get too many elements. This
I am trying to use JQuery to parse a sitemap.xml to look like this
I want to make the following using list in HTML The following are the
I use Intent it = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); to take photos by call up camera.
I intend to use RADIX / MTRIE as my preferred data-structure for a routing

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.