Add buttons on the fly

This is a discussion on Add buttons on the fly within the PHP General forums, part of the PHP Programming Forums category; I would like to add two buttons on a page form infomation confirmation, however, the html code in php nest ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 10-31-2006
Wang Chen
 
Posts: n/a
Default Add buttons on the fly

I would like to add two buttons on a page form infomation confirmation,
however, the html code in php nest can not be known by browser if I put
<form xxxxxxx> <input xxxxxxxxxx> </form> into there.
Besically, there is a mail form to enter iterm infomaiton, if it exist
before, prompt its iterm id., if it is new, query a next available inerm id
for it, then, show a page to ask such as, "do you accept this id?", two
buttons below this question, yes and no.

Is there any fountion in php which can make it? Thanks.

Reply With Quote
  #2 (permalink)  
Old 10-31-2006
Chris
 
Posts: n/a
Default Re: [PHP] Add buttons on the fly

Wang Chen wrote:
> I would like to add two buttons on a page form infomation confirmation,
> however, the html code in php nest can not be known by browser if I put
> <form xxxxxxx> <input xxxxxxxxxx> </form> into there.
> Besically, there is a mail form to enter iterm infomaiton, if it exist
> before, prompt its iterm id., if it is new, query a next available inerm id
> for it, then, show a page to ask such as, "do you accept this id?", two
> buttons below this question, yes and no.


PHP only works server side. Once the page is generated, php's job is done.

To change anything once it's already there, you need javascript
(probably an AJAX type solution so you post a question, get the answer
back and decide what to do in javascript).

--
Postgresql & php tutorials
http://www.designmagick.com/
Reply With Quote
  #3 (permalink)  
Old 11-01-2006
Richard Lynch
 
Posts: n/a
Default Re: [PHP] Add buttons on the fly

On Tue, October 31, 2006 3:46 pm, Wang Chen wrote:
> I would like to add two buttons on a page form infomation
> confirmation,
> however, the html code in php nest can not be known by browser if I
> put
> <form xxxxxxx> <input xxxxxxxxxx> </form> into there.
> Besically, there is a mail form to enter iterm infomaiton, if it exist
> before, prompt its iterm id., if it is new, query a next available
> inerm id
> for it, then, show a page to ask such as, "do you accept this id?",
> two
> buttons below this question, yes and no.
>
> Is there any fountion in php which can make it? Thanks.


PHP lives and runs, eats and breathes, lives and dies, ONLY on your
web-server.

You want something to happen in real-time with the user interaction,
almost-for-sure PHP is not going to be involved, at least not for your
first attempt at this.

You may end up going down the AJAX-y route, and having PHP back in the
picture for suggesting the next potential iterm id (whatever that is)
but it will just be a tiny little PHP script to pick the next ID, not
anything to do with how it's presented to the user or showing/hiding
form elements in real-time -- that's all JavaScript. Or Java applet.
Or even Flash (blech).

--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?
Reply With Quote
  #4 (permalink)  
Old 11-03-2006
aaron.reese@tiscali.co.uk
 
Posts: n/a
Default Re: Add buttons on the fly

I think what he is trying to do is..

Prompt for some information and submit

Validate the information against the database and if it already exists,
return the record ID. If it does not exist, return the next available
ID and present another form to accept or decline.

If accepted write the record to the database with the ID
If declined do nothing.

You can do this using hidden fields in the form, so when prompting for
the information you would use

<FORM>
<SELECT type = 'hidden' name='formaction' value = 'firstform'>
......
</FORM>

In your php script called from the submit you can then check for

if ($_POST['formaction'] == 'firstform')
{
do whatever validation you need to do on the database
if (valid)
{
print "<FORM> whatever you need for an exising item</FORM>";
}
else
{
print ""<FORM>whatever you need for a new item <SELECT type =
'hidden' name='formaction' value = 'secondform'> </FORM>";
}
}

if ($_POST['formaction'] == 'secondform')
{
validate the answer to the question and then either insert the record
or abort
}

Obiron

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 09:01 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0