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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T06:01:30+00:00 2026-06-02T06:01:30+00:00

When a user messages another user. They can pick which type of profile to

  • 0

When a user messages another user. They can pick which type of profile to send to. (Common or Manager)… I’m checking in the backend which profile to send it to with “recipient_type”, How do I get my autocomplete to choose the hidden radio button for me?

The autocomplete looks like this:
To: John Doe - Manager
or
To: John Doe

template:

<div class="hide">
     <input type="radio" id="id_recipient_type" name="recipient_type" value="0" />
     <input type="radio" id="id_recipient_type" name="recipient_type" value="1" />
</div>
<div class="inline-block">
     <label for="id_omnibox"></label>
     <input type="hidden" name="recipient_username" id="id_recipient_username" />
     <input id="message-to" class="required input-text" style="width: 145%;"name="omnibox" placeholder="Search for user..." autocomplte="on" type="text" />
</div>

script:

$(document).ready(function(){
    $.get('/autocomplete/message/', function(data) {
        var completions = new Array();
        var dict = JSON.parse(data, function(key, value) {
            completions.push(key);
            return value;
        });
        $('#message-to').autocomplete({
            source: completions,
            minLength: 1,
            select: function(value, data){
                $('#id_recipient_username').val(dict[data.item.value])
                split_string = data.item.value.split("- ");
                $('#id_recipient_type_'+(split_string[1]=="Manager"?"1":"0")).attr('checked', true);
            }     
        });
    });
});
  • 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-02T06:01:31+00:00Added an answer on June 2, 2026 at 6:01 am

    It seems that in order to your code to work you need to change or:

    <div class="hide">
         <input type="radio" id="id_recipient_type_0" name="recipient_type" value="0" />
         <input type="radio" id="id_recipient_type_1" name="recipient_type" value="1" />
    </div>
    

    Radio boxes IDs. or:

    $('#id_recipient_type[value="'+(split_string[1]=="Manager"?"1":"0")+'"]').attr('checked', true);
    

    The jquery selector to #id_recipient_type[value="1"] or #id_recipient_type[value="0"].

    I’d ratter use the first solution, since in html ids should be unique.

    You need to solve a problem stated by kmfk with your split where it throws an error when don’t find the ' - ' string, so change:

    split_string = data.item.value.split("- ");
    

    To:

    split_string = 'John Doe - Manage'.match(/ - (Manager)$/)
    split_string = split_string != null ? "0" : "1";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have make a messaging system in which user can send messages to each
I'm displaying user messages through templates using RequestContext in Django, which gives access to
We want to implement a News feed where a user can see messages broadcasted
I have a secured event type, which will check to see if the user
In my messages_controller I have the following private method: def find_message_or_404(slug) message = user.messages.find_by_slug(slug)
We have a customer that would like to modify application user messages that we
I have a class in c# in that store some user messages, and return
Is it possible to access and read all the inbox messages of user? It
I have three tables: User: UserId (pk) FirstName Lastname Messages: MessageId (pk) Heading Body
I want to list messages that received specific user from other users group by

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.