1

Hi i'm having a problem with posting from the input "searchtag" into "hash:'searchTag'" inside the javascript array. Please help me out! I'm very new to Javascript.

<form action="" method="post">
<input type="text" name="searchTag" placeholder="Search">
<input class="submit" name="Search" type="submit">

<div class="instagram"></div>
    <script type="text/javascript">

        $(".instagram").instagram({
            hash:'searchTag',
            clientId: 'My-clientId',
            image_size:'tumbnail'
        });

    </script>
2
  • look at onchange event, them get the value of the input and you will have the trick ;) Commented Mar 5, 2014 at 8:49
  • use $(document).ready(function() { //code here javascript });... Commented Mar 5, 2014 at 9:21

1 Answer 1

2

You need to collect the value from searchTag, which I assume you'll want to do when clicking the search button. For example:

$(document).ready(function() {

    $('#SearchButton').click(function () {
        var searchTag = $('#SearchTagInput').val();

        $(".instagram").instagram({
            hash: searchTag,
            clientId: 'My-clientId',
            image_size:'tumbnail'
        });
    });
});

The above example requires that you add the corresponding ids, SearchButton and SearchTagInput, to the input fields.

See this fiddle for an example.

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

2 Comments

It worked but now if i want to search for a new tag i have to reload the site so i can search agian otherwise it wont update
try to empty the collection first

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.