473,403 Members | 2,284 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

Problem: Javascript & PHP form with HTML_QuickForm

Hi,

I have a problem with a form using the PHP PEAR HTML_QuickForm package &
javascript:

I want to record the content of my form into a mySQL database then
execute a javascript function.

My problem is that javascript is executed before the mySQL insertion.
I actually need the mySQL insertion first, since my javascript function
is supposed to close the window...

Thanks for your help.
Ronan
A short explanation of my code:
#--- 1 ---
#javascript function
#---------
#--- 2 ---
# javascript is called by the action field of my form

# PHP code
$form = new HTML_QuickForm('createNewsCategoryForm',
'post','javascript:addValue();');

# HTML result
<form action="javascript:addValue();" method="post" ... >
#------
#--- 3 ---
# form validation du formulaire and insertion into the mySQL database:
if ($form->validate()) {
$form->process('dataProcessing', false);
}
else {
$form->display();
}

function dataProcessing($values){
#mySQL Insert request
}
#---------
Jul 23 '05 #1
1 1828


Ronan wrote:
I have a problem with a form using the PHP PEAR HTML_QuickForm package &
javascript:

I want to record the content of my form into a mySQL database then
execute a javascript function.

My problem is that javascript is executed before the mySQL insertion.
I actually need the mySQL insertion first, since my javascript function
is supposed to close the window...


Use a HTML form with a normal action attribute pointing to your PHP page
doing the database insertion and then let the PHP page return a HTML
page with script closing the window e.g.

<html>
<head>
<title>confirmation</title>
<script type="text/javascript">
function closeAfterDelay () {
setTimeout('window.close();', 2000);
}
window.onload = function (evt) {
closeAfterDelay();
};
</script>
</head>
<body>
<p>Your data has been stored.</p>
</body>
</html>

Of course there are restrictions on the windows script can close, you
might only be able to close a window that script opened before or the
browser might ask the user for confirmation to close the window.

--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Ronan | last post by:
Hi, I have a problem with a form using the PHP PEAR HTML_QuickForm package & javascript: I want to record the content of my form into a mySQL database then execute a javascript function. ...
3
by: Bob Bedford | last post by:
I've a function that validate a form field: <html> <head> <script language="JavaScript"> function CheckFields(FormSubmit,BtnName) { if (BtnName!="Cancel") { check = true;
6
by: bonehead | last post by:
Greetings, I'm working on an e-mail form (btw many thanks to Philip Ronan for the very cool email address format tester function, best I've seen so far). I've been trying, with limited...
5
by: comshiva | last post by:
Hi all, I have converted my existing ASP.NET project from 1.1 to 2.0 and i have found that everything works fine except the linkbutton control in my datagrid which throws an javascript error when...
0
by: WhatsPHP | last post by:
Hi I have seen the view helper in the Zend Framework. Does anyone know if there is any kind of plan to bring in bring in HTML_QuickForm like validation into the Zend Framework? The view helper...
3
polymorphic
by: polymorphic | last post by:
I have succeeded in embedding PDF files in a dynamic iframe. The problem is that I need the PDF to cache. If the PDF remains the same from page load to page load then the pdf is somehow cached with...
10
by: ellie2905 | last post by:
Hello, I am new to this forum and I am glad I found it because it seems that it will help me with my problem.I have creates a site using jsf components like grid panels and buttons.In the mozilla...
3
by: Venturini | last post by:
I am trying to put together a web page where the customer makes choices of products and is then given a total. I am extremely new to Javascript and have managed to get as far as I have from web...
2
by: swethak | last post by:
Hi, I am getting the problem the problem with google map in Internet Explorer. This map worked fine in mozilla . When i opened the same map in Internet Explorer i am getting the error...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
Oralloy
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,...
0
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...
0
tracyyun
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...
0
agi2029
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,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.