0

I have a input field where you can type in the user id. When typed in, it can display images from that user.

How ever, I would like to type in a username instead of a userid to fetch the images. Does anyone know how I can do that, or which function I could write (how) for that?

Thanks in advance!

1 Answer 1

1

UPDATE: Following this answer, a way to retrieve the ID with a given username https://stackoverflow.com/a/14979901/3032128


If you have a list of users with ids or something you can use autocomplete function from JQuery UI just as this example http://jqueryui.com/autocomplete/#custom-data where you will save the ID from the selected user in a hidden field such as

<input type="hidden" id="user_id">

that is the field that will be processed instead of the one you enter the ID or name,

your javascript will look like

$(document).ready(function() {

 //see JSON datasource for remote load if thats the case
 var users= [
 {
    value: "1",
    label: "JohnDoe"
 } // [...]
 ];
 $( "#user" ).autocomplete({
    minLength: 0,
    source: users,

    select: function( event, ui ) {
        $( "#user" ).val( ui.item.label );
        $( "#user_id" ).val( ui.item.value );
        return false;
    }
 })
});

EDIT: another useful link http://jelled.com/instagram/lookup-user-id

hope that helps

Sign up to request clarification or add additional context in comments.

2 Comments

Hello, I don't have a list of user id's. The meaning is that when you use my web application, you can check out pictures of a user with the name 'Mendes' for example.
Hey, doing a quick search on stackoverflow I found this answer that pretty much is what you need to get user_id from username, guess that will do the part of looking up the ID so you can retrieve the pictures. Edited my answer stackoverflow.com/a/14979901/3032128

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.