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 1544
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_profile_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,...
|
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...
|
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...
|
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...
|
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...
| |
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...
|
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...
|
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...
|
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...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
| |
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...
|
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...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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...
| |