2

I'm using this jQuery token input to the user choose languages and submit it to his MySql database. (Like facebook settings)

Everything is working well, but I have no idea about how to Prepopulate the languages loaded from user's MySql database.

Example: mysql database result: 11,26,55

Legend: The user go to his profile's settings page, click on (Edit Languages).

<input type="textbox" name="profile_languages" id="pro_token_languages">

How to make the page prepopulate the three languages inside the textbox input?

11 => English (US)

26 => Portuguese (Brazil)

55 => Japanese

1 Answer 1

1

Try this

 <input type="textbox" id="pro_token_languages" name="profile_languages" data-authors="<?php echo $language['lang']; ?>" />

and then

$(document).ready(function() {                                  
   $("#pro_token_languages").tokenInput("YOUR_URL", {                                   
   theme: "facebook",
   preventDuplicates: true,                             
   prePopulate: $('#pro_token_languages').data('authors')                                            

  });   

});

But Don't Forget your SQL Query which included the returned JSON array including langiage names and id. For Documentation Read Json Returned Format at http://loopj.com/jquery-tokeninput/

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.