user3014040
user3014040

Reputation:

Cant post from input form into javascript array?

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>

Upvotes: 1

Views: 66

Answers (1)

flitig
flitig

Reputation: 531

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.

Upvotes: 2

Related Questions