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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T19:24:02+00:00 2026-05-24T19:24:02+00:00

I am using Json to retrieve elements from mysql and insert them into form

  • 0

I am using Json to retrieve elements from mysql and insert them into form boxes. Displaying in form boxes(text type) was not a problem but in my html one of my form structure is dropbox … How should i display info that is in the database to the one that is in dropbox??

Here is the code that i used for displaying elements in form type (text). One of them is dropbox in the html.

<html>
<head>
<script type="text/javascript" src="jquery.js"></script> 
<script type="text/javascript">
$(document).ready(function(){
$("#button1").click(function(){
$.post('script_1.php', { id: $('input[name="id"]', '#myForm').val() },
function(json) {
$("input[name='title']").val(json.title);
$("input[name='rno']").val(json.rno); 
$("input[name='url']").val(json.url); 
}, "json");
});
</script>
</head>
<body>
<form id="myForm" method="post">
id: <input type="text" name="id"/>
<input type="button" id="button1" value ="Get"/>
<input type="button" id="button2" value="Submit to script 2" />
<p>title:<input type="text" name="title"/></p>
<p>Report No:<input type="text" name="rno"/></p>
<p>URL:<input type="text" name="url"/></p>
Institution: <select name="institution">
<option value="abc">abc</option>
<option value="cdf">cdf</option> 
</select>
</form>
<div id="age"></div>
</body>
</html>

PHP part or script_1.php

<?php

 ini_set('display_errors', 1);
error_reporting(E_ALL ^ E_NOTICE);
//connect to DB part
$name = mysql_real_escape_string($_POST['id']);
$sql ="SELECT * FROM parentid WHERE id = '$name'";       
$result = mysql_query($sql);
while($row = mysql_fetch_array($result))
{
**//i am not using $row['institution'] (no institution or dropbox part)**
$abc_output = array('title' => $row['title'],'rno' => $row['reportno'],'url' => $row['calc_url']);
}
}
echo json_encode($abc_output);

 }

}
?>

Help appreciated.John.

  • 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-24T19:24:04+00:00Added an answer on May 24, 2026 at 7:24 pm
    var option1 = new Option("InstitutionName1","InsitutionValue1");
    var option2 = new Option("InstitutionName2","InsitutionValue2");
    document.myForm.institution.options.length = 0;
    document.myForm.institution.options[0] = option0;
    document.myForm.institution.options[1] = option1;
    

    This is the way its done normally. In this particular case, you may want to have a for loop or something or jQuery’s each(..).

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

Sidebar

Related Questions

I am trying to retrieve JSON data from an external text file using a
I am using jQuery's $.ajax method to retrieve some JSON from an API. Each
I'm using this to retrieve RSS news feeds from Yahoo (JSON): select * from
I'm looking to retrieve JSON (from a third-party website) and convert it into a
I am using Following json url to retrieve images from flickr http://api.flickr.com/services/rest/?method=flickr.photosets.getPhotos&api_key=***&photoset_id=72157625776815845&extras=original_format&format=json&jsoncallback=? Response jsonFlickrApi({photoset:{id:72157625776815845,
I am using jQuery.ajax(...) to retrieve JSON data from an ASP.NET MVC service. When
I am using json.net to parse objects and delivering them to a webservice I
I am using json data and iterating it through jquery and displaying my results...
I'm trying to retrieve JSON data from a remote site with Rails/Prototype. I've found
I'm using a jQuery ajax json call to retrieve a 3 dimensional PHP array

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.