Jump to content

How do I create form in PHP with many different, mouse clickable buttons?


carlos1234

Recommended Posts

I've figured out how to do this using a workaround technique but am wondering if there is a better way.  Presently every page on my web application is a form.  With multiple submit buttons for First, Next, Last across the top and then many different buttons vertically on the left. 

 

When a user clicks a button a specific action is taken.  Sometimes the action is to process the form and sometimes it's to do something else. 

 

But creating a web application with every screen page a form...whether there is an actual data entry form there or not, so that I can process the users selection of button pressed is...well...a bit clutzy. 

 

Is there a different way to respond to button selections without having to create every screen page as a form? 

 

Any input or suggestions would be appreciated. 

 

Carlos

 

PS.  The PHP code creates the web pages for me.  That is why I am asking on a PHP forum :).

Link to comment
Share on other sites

Thanks The Little Guy...but that is precisely the way I am doing it now.  In order to process the button selected the "form" which has the button must be POSTed to the PHP script that determines the action to take. 

 

But...such button processing is really not what forms were created to be.  I might have a page for example which has no form on it at all...well at least no visible data entry form.  But it has some buttons on the page encased in form HTML.  And when a user clicks on a button...the name of the button pressed is sent to the PHP script in the POST global variable. 

 

That just seems a bit clutzy and a workaround to there being no way to detect a button press other than to have that button inside a form.  At least no way that I know of. 

 

In regular computer programs written in C for example one has buttons, events, and can connect those events to buttons such that when a particular button is pressed it sets off the event code associated with that button.  There is no encasing the button in an HTML form to figure out which button was pressed. 

 

I am just wondering if there is some way to similarly work with buttons using PHP and HTML such that I don't have to fiddle with form processing to determine which button was pressed. 

 

Maybe PHP is not a good language to use.  I don't know. 

 

I am trying to create a web application that runs in a browser and using PHP as my coding language.  Maybe I need to use a different language that can interact with a browser to create an application. 

 

Any suggestions? 

 

I mean PHP is good as far as it goes but it's too tied to the limits of HTML it seems to me.

 

Carlos

Link to comment
Share on other sites

I mean PHP is good as far as it goes but it's too tied to the limits of HTML it seems to me.

 

It seems to me your a little lost with the whole http process and where php sits amongst this process. PHP runs on the server, it has no concept of buttons, browsers or even html for that matter. Scripts are simply executed as they are requested. How scripts are requested is usually handled client-side.

 

You can make buttons submit requests using javascript (client-side) without forms, you can even have javascript react to events caused by buttons (client-side), but for php to do any processing, a request needs to be sent to the server.

Link to comment
Share on other sites

Thanks for the additional input. 

 

Here is what PHP does in my application. 

 

I create a PHP script that produces an HTML page on a browser.  That script and the text used on the page (which PHP converts to a web page) can reside either on a web server or locally on just my computer. 

 

Every page is a form.  Every page has buttons that a person can click on.  Whether a page has an actual data entry form on it or not...every page is nevertheless a form in the underlying HTML. 

 

When a person clicks a button to achieve a desired action...the form sends what button was pressed through the POST method to another PHP script that produces the desired action (whatever that action is). 

 

I am sure all this is old hat to you all but I wanted to lay out what I am doing more clearly. 

 

What I have been looking at is whether there is a way to avoid having to put the buttons inside an HTML form in the HTML code. 

 

I don't think there is.

 

That is why I said that PHP is limited by the inability of HTML to connect buttons with events.  It can't be done in HTML and HTML is the language that displays on the browser screen.  So...PHP is limited by HTML button processing limitations.  At least with respect to what I am doing. 

 

I'd also like to make my buttons selectable through hot keys.  Just like on regular Microsoft Windows programs that have such easily selectable buttons all over the place (like Microsoft Word).  But again...HTML is limited.  Firefox has some access keys that I can assign to buttons but it's nothing like regular C++ programming that creates an actual program for use on the desktop not to mention that Firefox access keys don't work in Internet Explorer and other browsers.  HTML being displayed through a browser is very limited in what it can do when compared to local running programs on the desktop. 

 

I am creating a web accessible application.  To run either locally or through a web browser off a remote host. 

 

But again...I am hampered by the limits of using a browser and HTML to create a nice looking, functional, and easy to use application that runs on both the local computer and over the Internet (through a browser). 

 

I mean I can do it and am doing it but the GUI is not as functional and not as nice looking as the GUI of Microsoft Word for example. 

 

Local languages such as Visual Basic and C++ can make calls to local API's which draw nice, clean GUI elements.  Elements which have all kinds of attributes I can play with to make an application great looking and very functional. 

 

PHP can't quite do that..at least very easily.  Or if it can...and I have read of some libraries whereby I can make such local API calls, then I am stuck with producing an application which will only run locally and not over the web through a browser. 

 

I want my application to run both locally (when not connected to the Internet) and over the Internet from off a web host.  And I don't want to create two versions of it...one for local and one for web. 

 

So I am looking for a GUI building language that I can use to create nice, clean, and very functional GUI elements running inside a browser.  I'm not sure there is such a thing for all such languages would again be limited by HTML's lack of display flexibility. 

 

Again the limits are imposed on me by HTML...which was never designed to be a GUI building language.  PHP is not the problem per se.  It's HTML's lack of flexibility in allowing me to create buttons that can be accessed using hot keys, that can be assigned events, and so forth. 

 

I don't want to use Javascript.  Javascript complicates my application even more in that Javascript does not run uniformly the same across different browsers.  So not only do I have to contend with browser differences in executing CSS and HTML but now a third thing...Javascript.  A bit much. 

 

But I may have to resort to using Javascript it at this point if I want to create a nicer, cleaner, and especially more functional GUI to run in a browser. 

 

I hope all that made sense. 

 

Carlos

Link to comment
Share on other sites

I don't want to use Javascript.  Javascript complicates my application even more in that Javascript does not run uniformly the same across different browsers.  So not only do I have to contend with browser differences in executing CSS and HTML but now a third thing...Javascript.  A bit much.

 

Indeed Javascript, CSS and html will do what you want.

Link to comment
Share on other sites

Thanks The Little Guy...but that is precisely the way I am doing it now.  In order to process the button selected the "form" which has the button must be POSTed to the PHP script that determines the action to take. 

 

But...such button processing is really not what forms were created to be.   I might have a page for example which has no form on it at all...well at least no visible data entry form.  But it has some buttons on the page encased in form HTML.  And when a user clicks on a button...the name of the button pressed is sent to the PHP script in the POST global variable. 

 

That just seems a bit clutzy and a workaround to there being no way to detect a button press other than to have that button inside a form.  At least no way that I know of. 

 

In regular computer programs written in C for example one has buttons, events, and can connect those events to buttons such that when a particular button is pressed it sets off the event code associated with that button.  There is no encasing the button in an HTML form to figure out which button was pressed. 

 

I am just wondering if there is some way to similarly work with buttons using PHP and HTML such that I don't have to fiddle with form processing to determine which button was pressed. 

 

Maybe PHP is not a good language to use.  I don't know. 

 

I am trying to create a web application that runs in a browser and using PHP as my coding language.  Maybe I need to use a different language that can interact with a browser to create an application. 

 

Any suggestions? 

 

I mean PHP is good as far as it goes but it's too tied to the limits of HTML it seems to me.

 

Carlos

 

My friend you are showing lack of knowledge in client server communications, php is not the language that can take JavaScript place, java script is not uni formal, but as an app developer you must create uniformity that is your job no one else that's why you code. you may use java script to create an application on the clients side out of client side components, these can then each be linked to functions that call server side scripts this is called AJAX, an application without ajax is considered out of date as it reflects the feel of a static application. If you use java script to fire functionality in order to fire server side functionality and take results to uopdate teh views then your application is a real application otherwise you are making doodles.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.