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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T09:59:36+00:00 2026-05-30T09:59:36+00:00

Hey guys and gals I’m having some major issues trying to get my application

  • 0

Hey guys and gals I’m having some major issues trying to get my application to work. I’ve been trying to hack through this and am missing the very first part which is sending the correct input value (button value) to get the ball rolling, I’m sure this is something simple but I’ve been having an issue getting it working. I’d appreciate it if someone could pick out the error(s) to help me along.

This is extremely easy to do in PHP, but since this is a standalone offline
app I cannot use PHP =( I need to do all my fetching and parsing in JQuery
or Javascript….

We start with a very basic form with some buttons that have unique values.

<form>

<fieldset>
<legend>Select Orders</legend>

<table id='master'></table>

  </div> <!-- end input1 -->
    <div>
     <button name="select" type="submit" id="btnLoad" value="load">Refresh</button>
     <button name="select" type="submit" id="btnJson" value="down">Download JSON</button>
     <button name="select" type="submit" id="btnView" value="view">View/Enter</button>
    </div>
</fieldset>

</form>

which triggers this function

$(function() {
    $("form").submit(function() {

        /* what obj are we recieving?
        $.each($(this), function(index, obj) {
            console.log('Index: ' + index + ' Obj: '+ obj);
            // returns this B/S: Index: 0 Obj: [object HTMLFormElement]
        });
        */

        // $this.button.val() never makes it through?
        queryJsonServer($(this), "class/");
        return false;
    });
});

I’ve tried things like

var button = $(this).attr("value");
var button = $('button').attr("value"); // ends up with the first buttons value,
                                        // but never the selected or $(this).val()

$('button').click(function() {          // which WILL console.log the buttons val,
  console.log($(this).val());           // but will not let me turn it into a var?
  return false;                         // ALSO this looks like it only reads the
});                                     // value the SECOND click?

The Mission here is to send the buttons value as a $_POST type over to a parser which will return the appropriate JSON array to be parsed, or to be stored in a Local SQLite DB.

Either way, here’s the full code of the page, could someone please give me a hand, or if I need to clarify please let me know.

<?php 
    ini_set('display_errors', 1);
    error_reporting(E_ERROR | E_PARSE);
    var_export($_POST);
?>

<!DOCTYPE html>
<html lang="en-US">
    <head>
     <title> </title>

     <script src='http://www.google.com/jsapi'></script>
     <script> google.load('jquery', '1.7.1'); </script>

     <script>
        $(function(){
            $("form").submit(function() 
            {

                /* what obj are we recieving?
                $.each($(this), function(index, obj) {
                    console.log('Index: ' + index + ' Obj: '+ obj);
                    // returns this B/S: Index: 0 Obj: [object HTMLFormElement]
                });
                */

                $('button').click(function() {
                    var state = $(this).val();
                    return true;
                });

                // state is undefined. L29
                console.log(state);

                // $this.button.val() never makes it through?
                queryJsonServer($(this), state, "class/");
                return false;
            });

            // query json server for
            function queryJsonServer(form, state, path) 
            {

                // on first return or refresh inputs will be returrned
                var view    = $('input[name="orders"]:checked').val();
                var url     = path + "json.php?" + state; // status = button.val()
                var state   = $(this).attr("value"); // ends up class/json.php?undefined

                // we have data, lets post to json parser and 
                $.getJSON(url, view, function(data) 
                {
                     $('form').unbind('submit').trigger('submit');

                    var items = [];

                        switch(state)
                        {
                            case 'load' : 

                                $.each(data, function(index, obj) { 
                                    items.push('<tr>');
                                    $.each(obj, function(key, val) { 
                                      items.push((key == "report_number") 
                                      ? '<td class="check" ><input type="checkbox" name="' + val + '" /></td><td><label class="caps" for="'+ key +'">'+ key.replace("_", " ") +'</label><input disabled="disabled" type="text" id="' + key + '" value="' + val + '" /></td>' 
                                      : '<td><label class="caps" for="'+ key +'">'+ key.replace("_", " ") +'</label><input disabled="disabled" type="text" id="' + key + '" value="' + val + '" /></td>')
                                    }); 
                                    items.push('</tr>');
                                });

                                $('<div/>', {
                                    'class': 'jsonOutput',
                                    html: items.join('')
                                  }).appendTo('#master');

                              break;

                            case 'down' : 
                              // populate SQLite Database
                              break;

                            case 'view' : 

                                $.each(data, function(index, obj) { 
                                    items.push('<tr>');
                                    $.each(obj, function(key, val) { 
                                      items.push('<td><label class="caps" for="'+ key +'">'+ key.replace("_", " ") +'</label><input disabled="disabled" type="text" id="' + key + '" value="' + val + '" /></td>')
                                    }); 
                                    items.push('</tr>');
                                });

                                $('<div/>', {
                                    'class': 'jsonOutput',
                                    html: items.join('')
                                  }).appendTo('#master');

                              break;

                            default: 
                              return false; 
                              break;
                        }

                });
            }
        });
     </script>

    <style type="text/css">
     p, ul {width:100%; text-align:left;font-size:80%;}
     .reports_box {width:auto; padding:25px 20px 20px 20px;border:1px solid #91bce6;background-color:#eff5fb;}
     .inputs {width:300px; font-size:15px;padding:5px;}
     .check input {padding:0 !important;}
     .caps {text-transform:capitalize;}
     #reports_list td, #reports_list tr {padding:10px 0 10px 2px;color:#34567b;}
    </style>

    </head>

 <body>


<div class="reports_box">
    <form id='submit'>

    <fieldset>
    <legend>Select Orders</legend>

    <table id='master'></table>

      </div> <!-- end input1 -->
        <div>
         <button name="select" type="submit" id="btnLoad" value="load">Refresh</button>
         <button name="select" type="submit" id="btnJson" value="down">Download JSON</button>
         <button name="select" type="submit" id="btnView" value="view">View/Enter</button>
        </div>
    </fieldset>

    </form>
</div> <!-- end reports_box -->

  </body>
</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-05-30T09:59:38+00:00Added an answer on May 30, 2026 at 9:59 am

    Block form submission unless triggered by a button.

    When form submission is triggered by a button:

    1. Use $(form).serialize() to serialize the form
    2. add “&select=ButtonValue” to the serialized string
    3. Use $.getJSON to send a get request to your server page and get a JSON object back.

    FINAL EDIT: Here’s a working fiddle where I use serialize correctly: http://jsfiddle.net/YYZGG/5/

    (When using the code change the form action to your correct page)

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

Sidebar

Related Questions

Hey guys/gals I'm writing a python script that fixes some duplicate issues on my
Hey guys i am trying to automate my system at work for sending artwork
Hey guys im trying to get a simple button masher up, What i want
Hey guys I'm trying to make a GUI which can navigate through JTextAreas when
Hey guys i want to execute my SQL statement but im having synatx trouble,
Hey Guys, here is my code for this, the only help i get from
Hey guys, I'm having a problem with IE7, my menu always drops down behind
Hey guys I was wondering if there is a way to get a certain
Hey guys i'm making a website but for some reason my div tags are
Hey guys I'm trying to add the string 'url( ) ' around my a

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.