473,379 Members | 1,187 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,379 software developers and data experts.

Having a problem mixing HTML and PHP


I am trying to use a form with a button that calls a verification script
but can't seem to get the script to run at all - can anyone tell me if
this SHOULD work in a forms onCLick or have I got the syntax wrong?

The function is previously included with include_once('library.php');
This seems to work ok. I dont get any php errors if I turn on reporting.
The function checks out ok on its own. I've also tried a simple echo with
no luck. the page is called myform.php (not .html)

The form button has:

<input type=button name="btOne" value="Click-Me" id = "mButton" onClick =
"<?PHP verify(); ?>" >

I did think you could do this - am I wrong?
(Incidently I'm also having trouble getting onBlur to work in a similar
form with PHP.)

thanks.
May 23 '06 #1
2 2472
Rik
to**@tony.com wrote:
<input type=button name="btOne" value="Click-Me" id = "mButton"
onClick = "<?PHP verify(); ?>" >

I did think you could do this - am I wrong?
Yes, you are
(Incidently I'm also having trouble getting onBlur to work in a
similar form with PHP.)


PHP != javascript.

It runs on the server not onthe clients machine, so simply speaking as soon
as the content is sent it's job is done. It can't tell what you are doing in
a html page. If you want PHP to handle (new) values, you will have to send
them to the server. In most cases this means requesting a new page.

Grtz,
--
Rik Wasmus
May 23 '06 #2
to**@tony.com wrote:

I am trying to use a form with a button that calls a verification
script but can't seem to get the script to run at all - can anyone
tell me if this SHOULD work in a forms onCLick or have I got the
syntax wrong?

The function is previously included with include_once('library.php');
This seems to work ok. I dont get any php errors if I turn on
reporting. The function checks out ok on its own. I've also tried a
simple echo with no luck. the page is called myform.php (not .html)

The form button has:

<input type=button name="btOne" value="Click-Me" id = "mButton"
onClick = "<?PHP verify(); ?>" >

I did think you could do this - am I wrong?
(Incidently I'm also having trouble getting onBlur to work in a
similar form with PHP.)


PHP is processed on the server, and does this *before* the user ever
sees the HTML page, meaning that the verify() you have is called before
the page is displayed to the user.

Rather use a submit button and let the script referenced to in the
"action" attribute of the <form> tag handle the verification of the
fields.

A process like the one you're shooting for can be done using AJAX, but
in this case, that could be more trouble that it's actually worth.

--
Kim André Akerĝ
- ki******@NOSPAMbetadome.com
(remove NOSPAM to contact me directly)
May 23 '06 #3

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

Similar topics

3
by: bergel | last post by:
Hello, Does anyone already have some experience in mixing AWT and Swing? Is it conceptually doable? Does the design of Swing prevent interaction between an AWT and a Swing widget? Regards,...
7
by: Keith Dewell | last post by:
Greetings! My current job has brought me back to working in C++ which I haven't used since school days. The solution to my problem may be trivial but I have struggled with it for the last two...
4
by: Cristian Tota | last post by:
Hi, I'd appreciate any thoughts on mixing C++ and C code. I have a project that uses a given C interface, the rest of the project can be either in C or C++. What would be the recomended design...
3
by: Tyrone Slothrop | last post by:
The first question, is this even possible? What I need to do is pass the contents of a PHP web page from a textarea using window.open method to a new browser window and display it. The page has...
0
by: Venus | last post by:
Hello, After trying some ways to do it I wanted to use something like the code below but for some reason is not working (I have to generate the entire form dynamically (not only the controls)):...
4
by: chsadaki | last post by:
Hello.... I'm working on a page that finds the shortest path between two nodes. The problem is when I draw a node on the map(in the administrative page) to save it later in a mysql table, the...
28
by: ziman137 | last post by:
Hello all, I have a question and am seeking for some advice. I am currently working to implement an algorithmic library. Because the performance is the most important factor in later...
1
by: speralta | last post by:
For some reason the text in h2 tag is displaying as white in IE. Any suggestions? http://www.salperalta.com/ <td class="sidebar" id="sidebar-right"> <div class="block block-listing"...
8
by: maya | last post by:
this is doctype I was told to use for a site I'm building at work.. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> only problem is, in...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.