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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T17:24:54+00:00 2026-06-11T17:24:54+00:00

I have a web page with a small form in it. HTML code for

  • 0

I have a web page with a small form in it.

enter image description here

HTML code for the page.

<html>
<head>
<link rel="stylesheet" type="text/css" href="stylesheets/styles.css" />
<script type="text/javascript" src="scripts/jquery-1.8.0.min.js"></script>
<script type="text/javascript" src="scripts/scripts.js"></script>
</head>
<body id="body_services">

<?php

include_once 'DatabaseHandler.php';
$db = DatabaseHandler::getInstance();

//loading taxi service names for updating combobox
$queryLoadSids = $db->prepare("SELECT * FROM taxi_services ORDER BY SID");
$queryLoadSids->execute();
$dropdown = "<select name='serviceID'>";
while ($row = $queryLoadSids->fetch(PDO::FETCH_ASSOC))
{
    $dropdown .= "\r\n<option value='{$row['SID']}'>{$row['Name']}</option>";
}
$dropdown .= "\r\n</select>";

?>

<div id="tasks">
    <ul>
        <li><a id="add" href="#">Add a new taxi service</a></li>
        <li><a id="update" href="#">Update a taxi service</a></li>
        <li><a id="delete" href="#">Delete a taxi service</a></li>
        <li><a id="view" href="#">View taxi services</a></li>
    </ul>
</div>

<form id="cmbServiceIDs" name="sids">
<table width="380" border="0">
  <tr>
    <td><label for="serviceId">Select the Service ID</label></td>
    <td><?php echo $dropdown; ?></td>
    <td><input id="load" type="submit" value="Load" name="btnload" /></td>
  </tr>
</table>
</form>

<form id="frmUpdateService" name="Update" action="" method="post">
<table width="300" border="0">
  <tr>
    <td><label for="sid">Service ID</label></td>
    <td><input type="text" name="sid" value="" style="text-align:right" /></td>
  </tr>
  <tr>
    <td><label for="name">Name</label></td>
    <td><input type="text" name="name" value="" /></td>
  </tr>
  <tr>
    <td><label for="cost">Cost</label></td>
    <td><input type="text" name="cost" value="" /></td>
  </tr>
  <tr>
    <td><label for="active">Active</label></td>
    <td><input type="checkbox" name="active" value="" /></td>
  </tr>
  <tr>
    <td></td>
    <td><input type="reset" value="Cancel" /> <input type="submit" value="Update" name="update" /></td>
  </tr>
</table>
</form>

</body>
</html>

When the Load button is clicked, it should run a query against a DB, return the results to populate the textboxes in the form. I’m using jQuery AJAX for this task.

$(function()
{
    $("#frmUpdateService").hide();
    $("#cmbServiceIDs").hide();

    $("#update").click(function()
    {
        $("#cmbServiceIDs").slideDown("slow");
        $("#frmUpdateService").hide();
    });

    $("#cmbServiceIDs").submit(function(e)
    {
        $("#frmUpdateService").fadeIn("slow");
        e.preventDefault();

        $.ajax(
        {
            type        : 'GET',
            url         : 'request.php',
            data        : {'serviceID' : $("#serviceID").val()},
            dataType    : 'json',
            success     : function(response)
            {
                var loadedSID = response[0];
                var loadedName = response[1];
                var loadedCost = response[2];
                var loadedActive = response[3];

                $("#sid").append(loadedSID);
                $("#name").append(loadedName);
                $("#cost").append(loadedCost);
                $("#active").append(loadedActive);
            }
        });
    });
});

This is the request.php page.

<?php

include_once 'DatabaseHandler.php';
$db = DatabaseHandler::getInstance();

$param = $_GET['serviceID'];

$queryLoadToUpdate = $db->prepare("SELECT * FROM taxi_services WHERE SID = :serviceID");
$queryLoadToUpdate->bindParam(':serviceID', $param, PDO::PARAM_STR);
$queryLoadToUpdate->execute();
$results = $queryLoadToUpdate->fetchAll(PDO::FETCH_ASSOC);

echo json_encode($results);

?>

But when I run the page and click on the Load button, nothing appears in the textboxes. I looked into the response using Firebug and it shows an empty response. I checked the SQL query as well. No errors there either.

I have no idea what I should check or do next. Can anyone give any suggestions as to why its not working properly here?

Thank you.

  • 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-11T17:24:56+00:00Added an answer on June 11, 2026 at 5:24 pm

    Apparently the query was not working correctly because the value I supplied for the variable $param was NULL. I could figure that out using var_dump. Further checking led me to notice that the dropdown’s selected value was not getting passed correctly because I hadn’t specified an id on this line.

    $dropdown = "<select name='serviceID'>"; 
    

    I corrected it like this.

    $dropdown = "<select id='serviceID' name='serviceID'>";
    

    And in the jQuery code, changed this line

    data : {'serviceID' : $("#serviceID option:selected").val()},

    to this to get the value of the selected dropdown item.

    data : {'serviceID' : $("#serviceID option:selected").val()},
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a web page that whenever your in a text-field, if you hit
I'm building a web page form with jquery append() , html() etc and I'm
I have created a small survey web page on our company Intranet. This web
I have made small web-app in jsp with a start page with login and
I have a ASP.Net web form that contains both text box fields and hidden
I'm using CakePHP for a small web app and on one form page there's
I have web page in PHP which displays all records in a table. I
I have web page which is passing a querystring parameter to page 2: <a
new on rails and using windows for now,, i have web page that user
I have web forms page that has 2 controls. A gridview and an associated

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.