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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T09:27:11+00:00 2026-06-05T09:27:11+00:00

Here is my submit button written dynamically through AJAX: var htmlpage = <div class=’pages’>

  • 0

Here is my submit button written dynamically through AJAX:

var htmlpage = "<div class='pages'>"
                for (i=1 ; i < pages+1 ; i++)
                    {
                        htmlpage += "<li><input type='submit' value='"+i+"' onclick='updatefilters;' /></li"
                    }
                htmlpage += "<div>"    
                htmlpage += "</ul>";

I am trying to rerun the updatefilters() function to change the items that are displayed. I imagine its a bit tough to conceptualize without seeing all the code…but essentially, all I need to do is run the function again on each click of the submit button…right now, its giving me a updatefilters is undefined error in firebug.

Heres my whole JS for reference

$(function() {
    $( "#selectable" ).selectable({
        selected: updatefilters  
    });
    getactivesession();
    function getactivesession(ev, ui){
        var i = 0;
        var actfilter, strfilter;
        var strfilterarray = new Array();
        $.ajaxSetup({cache: false})
        $.ajax({
        type: "POST",  
        async: false,
        url: 'welcome/getactivesession', 
        dataType: 'json',
        success: function (data){
            strfilter = JSON.stringify(data)
            strfilterarray = strfilter.split(',')
            for (i=0 ; i < strfilterarray.length ; i++) {
                strfilter = strfilterarray[i]
                strfilter = strfilter.replace(/[\[\]'"]+/g,'');
                var strfilterdash = strfilter.replace(/\s+/g, '-')
                actfilter = '#'+ strfilterdash
                $(actfilter).addClass('ui-selected')
            }
            updatefilters();
        }
        });
    }

    function updatefilters(ev, ui){
        // get the selected filters
        var template, html;
        var i = 0;
        var page;
        if(! page){
            page = 0; 
        }

        var $selected = $('#selectable').children('.ui-selected');
        // create a string that has each filter separated by a pipe ("|")
        var filters = $selected.map(function(){return this.id;}).get().join("\|");
        $.ajax({
            type: "POST",
            async: false,
            url: 'welcome/updatefilters',
            dataType: 'json', 
            data: { filters: filters, page: page },
            success: function(data){
                var html = "";
                html += "<div id=board>"
                html += "<div class='board' id='table'>"
                html += "<div id='row'>header here</div>"
                var pages = Math.ceil(data['num_threads']/10);
                var htmlpage = "<div class='pages'>"
                for (i=1 ; i < pages+1 ; i++)
                    {
                        htmlpage += "<li><input type='submit' value='"+i+"' onclick='updatefilters;' /></li"
                    }
                htmlpage += "<div>"    
                htmlpage += "</ul>";
                htmlpage += "</br>";
                html += htmlpage;
                for (i=0 ; i < data['threads'].length ; i++)
                {
                    html += "<div id=row>";
                    html += "   <div id='author' style='background: url("+data['threads'][i].location + ") no-repeat; background-position: center;'><p>"+data['threads'][i].username + "</p></div>";
                    html += "   <div id='arrow'></div>";
                    html += "   <div id='subject' title='"+ data['threads'][i].body +"'>";
                    html += "       <a href=thread/" + data['threads'][i].slug + ">"+ data['threads'][i].subject +"</a><p>Created: "+data['threads'][i].posttime+"</p></div>";                    
                    html += "   <div id='info'>";
                    html += "       <div id='replies'>" + data['threads'][i].replies_num + "</div>";
                    html += "       <div id='lastpost'>"+ data['threads'][i].lastreply+"</div>";
                    html += "   </div>";
                    html += "</div>";
                }
                html += "</div></div>";
                $('#board').html(html);
            }
        });
    } 
});
  • 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-05T09:27:13+00:00Added an answer on June 5, 2026 at 9:27 am

    There appears to be a few problems with this approach.

    First, you’re not actually calling the function in your onclick handler.

    htmlpage += "<li><input type='submit' value='"+i+"' onclick='updatefilters;' /></li"
    

    should be:

    htmlpage += "<li><input type='submit' value='"+i+"' onclick='updatefilters();' /></li"
    

    Second, the updatefilters function isn’t accessible from the global scope, which is where that anonymous function will be executed from. You’d have to move function updatefilters(ev, ui) outside the onload callback, perhaps to the top of your script block.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im writing a class that replaces all input type=button and input type=submit in the
Here is what I have going on in my AJAX: $('#submit-button').click(function(){ var twit =
I have the following submit button: <form id=form1 runat=server> <input type=submit id=submit value=Submit runat=server/>
I have a simple Jquery function here: function submit_selection(del,submit) { del='yes'; submit=true; var ITAMZ=new
I am trying to submit a form with ajax. Here is my complete code
HTML: <div id=wrapper> <div class=body> text text text </div> <div class=comment_submit> <!-- here goes
I am using jQuery to swap out the image here after the submit button
I want to put a form with input field and submit button inside a
Something is eluding me here. Every time I press the submit button, the form
i have a form element- text input and a submit button- Im trying to

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.