Without going into great detail (which I can do if it turns out more info is needed), I would like to:
All on one page, using ajax:
1. In a text field, have the user enter a plant name to insert into a database
2. Have a form pop up with attributes for the plant (name, scientific name, related species)
3. Have the user fill this field out and submit it to a mysql database table.
So far I have part 1 and 2 working. However, I cannot figure out how to continue to part 3 without submitting the data and loading to the next page for confirmation of insertion.
Please look and see what I've accomplished so far at this link
I can provide further information and source if it is needed. Thanks
Esscher
2 1548
It might be helpful for you to run the code yourself, so i'll include my sources
demo_add_plant. php - <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-
<html xmlns="http://www.w3.org/1999/xhtml">
-
<head>
-
<script src="showplantprofileform.js"></script>
-
-
-
<script language="javascript">
-
var url = "add_plant_profile_record.php?id=";
-
-
function handleHttpResponse() {
-
if (http.readyState == 4) {
-
if(http.status==200) {
-
var results=http.responseText;
-
document.getElementById('PlantInfoDiv').innerHTML = results;
-
}
-
}
-
}
-
-
function showPlantProfileForm() {
-
var sId = document.getElementById("Plant2Check").value;
-
http.open("GET", url + escape(sId), true);
-
http.onreadystatechange = handleHttpResponse;
-
http.send(null);
-
}
-
function getHTTPObject() {
-
var xmlhttp;
-
-
if(window.XMLHttpRequest){
-
xmlhttp = new XMLHttpRequest();
-
-
}
-
else if (window.ActiveXObject){
-
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
-
if (!xmlhttp){
-
xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
-
}
-
-
}
-
return xmlhttp;
-
-
-
}
-
var http = getHTTPObject();
-
</script>
-
-
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-
<title>Phytobase Home</title>
-
</head>
-
<body bgcolor="white">
-
-
<form>
-
Add Plant Profile (type anything):<input id="Plant2Check" type="text" name="inputplant" value="">
-
<p><input type="button" value="Click 4 Plant Profile Form" onClick="showPlantProfileForm()" />
-
-
</form>
-
<div id="PlantInfoDiv"><b>Plant info will be listed here.</b></div>
-
-
</body>
-
</html>
-
add_plant_profi le_record.php
plants mysql table -
--
-
-- Table structure for table `plants`
-
--
-
-
CREATE TABLE `plants` (
-
`id` smallint(6) NOT NULL auto_increment,
-
`common_name` varchar(255) NOT NULL default '',
-
`additional_names` varchar(2000) default NULL,
-
`genus` varchar(255) default NULL,
-
`species` varchar(255) default NULL,
-
`warnings` varchar(2000) default NULL,
-
`picture` varchar(255) default NULL,
-
`fx` varchar(2000) default NULL,
-
`law` varchar(1000) default NULL,
-
`native_land` varchar(255) default NULL,
-
`social_group` varchar(2000) default NULL,
-
`notes` varchar(10000) default NULL,
-
`ref` varchar(1000) default NULL,
-
PRIMARY KEY (`id`,`common_name`)
-
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=16 ;
-
-
--
-
-- Dumping data for table `plants`
-
--
-
-
INSERT INTO `plants` (`id`, `common_name`, `additional_names`, `genus`, `species`, `warnings`, `picture`, `fx`, `law`, `native_land`, `social_group`, `notes`, `ref`) VALUES
-
(1, 'kava kava', 'none', 'piper', '', '', '', 'sedative', '', '', '', '', '')
-
Thanks for checking this out and helping
esscher
acoder 16,027
Recognized Expert Moderator MVP
See an AJAX POST example. Post the values entered to a script which inserts the values into the MySQL database.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: cooldv |
last post by:
i know how to replace the sign " when SUBMITTING a form in asp by this
code:
message = Replace(usermessage, "'", "''").
My problem is DISPLAYING data in an asp FORM, from an an access
database, when the data already contains a " sign
problem is like this:
access database .... to update on the internet .... a *dataupdate.asp*
page ..... On this page, the data gets displayed in a form where i
|
by: Japhy |
last post by:
Hello,
I'm am pulling data from a mysql db and want to use the data to
populate a <ul.
Here are relavent parts of my code :
$wohdate = mysql_result($wohRS,$wohndx,woh_date);
$woh_display .="<li>".$wohdate."</li>" ;
$TemplateText = Replace($TemplateText,"@$wohdisplayndx@",$woh_display);
|
by: Mal P |
last post by:
Hi there,
I'm a J2EE fellow who (as usual) has been thrown in the deep end and
have to learn a fair chunk of the .NET platform (VS, ADO, WebForms, C#
etc) in roughly two days. I'm doing ok so far, but am wondering on a
better way to do something...
Basically, I have a form which has a few fields the user fills in.
When submitted, the data is stored as a row in an SQL database table.
Then, I have another page which lists all the rows...
|
by: Nithin |
last post by:
My code as an txt attachment.
I have 2 drop down list boxes that on selection populate text boxes
from my database table. I am able to display the correct values in
these text boxes.
I have 2 questions:
1) I would like the user update these text fields that get populated
with data from the database. For some reason I get the error when I
change the textbox value.
|
by: Yul |
last post by:
Hi,
We are in the process of designing an ASP.NET app, where a user will
enter some 'Customer ID' to be queried in the database. If the ID is
valid, several stored procedures will be called to populate multiple
webpages containing customer information. There isn't a one-to-one
correlation between the stored procedure and a webpage. In other
words, a webpage may have to refer to 1 or more DataTables to populate
itself. Therefore, a...
| |
by: vj |
last post by:
How i can populate all fileds dynamically in jsp page based on contents
found in xml file?
I have written jsp servlets and java class file.
i transferred automatic data from jsp to servlet then to java class
which creates a xml file based on values entered in dynamic jsp page.
Now i want to read all those values entered to xml in my other jsp
page.
I am able to call values from file in my jsp page.
But as dynamic values can be any in no...
|
by: eholz1 |
last post by:
Hello PHP programmers.
I had a brilliant idea on one of my pages that selects some data from
my mysql database.
I first set the page up to display some info and an image, just one
item, with a row of data, etc.
then I thought it would be nice to do a select, and perhaps an update
(the title of the image) on the same page.
|
by: MIkeC |
last post by:
Apologies if this has already been posted.
I am coding in VB
I am trying to find the best way to populate a form from a sql Database in .net 2005
I have a company table that has > 20 columns, I will be selecting a specific row. I have populated the form with textboxes that are named so that they reflect the column names of the company table.
I want to select the row, populate the form by looping through the columns.
|
by: chromis |
last post by:
Hi,
I'm having trouble fully implementing the edit section of a contact admin system, so far I have written the following:
- Bean (Contact.cfc)
- Data Access object (ContactDAO.cfc)
- Gateway (ContactGateway.cfc)
- index.cfm - Deals with the business logic
- display/form.cfm - Produces the form for both add and edit behaviour
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |