IF THEN for button?

IF THEN for button?

am 15.11.2007 14:20:14 von paul814

Is it possible in PHP to do the following?

I've got a php page with a form, that form has radio buttons group and
an option group list. It also have a button, Continue.

When the continue button is presed I want it to look at: this:
If Radiobutton1 is pressed and option group lsteditorial is selected,
goto write-editorial.php
if Radiobutton1 is pressed and option group lstpres is selected, goto
write-press.php

and etc... for other combinations, so based on the selections of the
radio buttons and option groups goto a specific page:

here is my code:

www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">



Production Report



height="30" />


 


What would you like to
do?:









Please also select the
department:






value="Continue" />








thanks for any help as to the code or where to put it so it works with
the button.

Re: IF THEN for button?

am 15.11.2007 14:24:51 von Courtney

paul814@excite.com wrote:
> so based on the selections of the
> radio buttons and option groups goto a specific page:

If you do this in php alone you have to submit what you pressed and then
go to yet another page after analsying it all.

This seems to be to be a case for javascript.

Re: IF THEN for button?

am 15.11.2007 14:26:09 von Captain Paralytic

On Nov 15, 1:20 pm, paul...@excite.com wrote:
> Is it possible in PHP to do the following?
>
> I've got a php page with a form, that form has radio buttons group and
> an option group list. It also have a button, Continue.
>
> When the continue button is presed I want it to look at: this:
> If Radiobutton1 is pressed and option group lsteditorial is selected,
> goto write-editorial.php
> if Radiobutton1 is pressed and option group lstpres is selected, goto
> write-press.php
>
> and etc... for other combinations, so based on the selections of the
> radio buttons and option groups goto a specific page:
>
> here is my code:
>
>
>
>
>
> Production Report
>
>
>


>

> height="30" />


>

 


>

What would you like to
> do?:


>

>


>
>

>
>


>

Please also select the
> department:


>


>
>


>


> > value="Continue" />
>

>


>

>

>
>
>
> thanks for any help as to the code or where to put it so it works with
> the button.

Look at the header() function.

Re: IF THEN for button?

am 15.11.2007 14:51:09 von Jerry Stuckle

paul814@excite.com wrote:
> Is it possible in PHP to do the following?
>
> I've got a php page with a form, that form has radio buttons group and
> an option group list. It also have a button, Continue.
>
> When the continue button is presed I want it to look at: this:
> If Radiobutton1 is pressed and option group lsteditorial is selected,
> goto write-editorial.php
> if Radiobutton1 is pressed and option group lstpres is selected, goto
> write-press.php
>
> and etc... for other combinations, so based on the selections of the
> radio buttons and option groups goto a specific page:
>
> here is my code:
>
> > www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
>
>
>
> Production Report
>
>
>


>

> height="30" />


>

 


>

What would you like to
> do?:


>

>


>
>

>
>


>

Please also select the
> department:


>


>
>


>


> > value="Continue" />
>

>


>

>

>
>
>
> thanks for any help as to the code or where to put it so it works with
> the button.
>

Paul,

The first thing to remember is that PHP code is all executed before the
page is sent to the browser. You have no direct interaction with the
PHP code; all you can do is submit HTML requests (i.e. GET, POST) to the
server and have that execute the code.

So, with this in mind, in your select.php (the target for your form),
your $_POST array will have an element with the index 'radReadWrite' (if
a button is selected). This will contain 1 or 2, depending on the radio
button selected.

It will also contain an element with the index 'lstdepartment' for your
SELECT box, and value of the element will be the value of the option.

Based on these values, determine which page you want to go to, and use
the header() function to redirect the browser to the page you wish.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Re: IF THEN for button?

am 15.11.2007 15:00:12 von Lars Eighner

In our last episode,
<5a860b31-c624-4f3f-a74d-59a507c3075e@f3g2000hsg.googlegroups.com>, the
lovely and talented paul814@excite.com broadcast on comp.lang.php:

> Is it possible in PHP to do the following?

> I've got a php page with a form, that form has radio buttons group and
> an option group list. It also have a button, Continue.

> When the continue button is presed I want it to look at: this:
> If Radiobutton1 is pressed and option group lsteditorial is selected,
> goto write-editorial.php
> if Radiobutton1 is pressed and option group lstpres is selected, goto
> write-press.php

> and etc... for other combinations, so based on the selections of the
> radio buttons and option groups goto a specific page:

HTML cannot do this. Once you have served your page, it is HTML and php has
nothing more to do with it. You can use client-side scripting to
accomplish something like what you want. You cannot have one set of radio
buttons with different actions because to get different actions, they would
have to belong to different forms. What you can do is have the one action
(select.php) generate different pages according to the radio button and
other controls.

Or to put it another way: HTML is markup. It is not a programming
language. It has no conditionals. If you want conditions you have
implement them with client-side scripting or server-side scripting;
but you cannot do it with HTML. An HTML form can only "goto" one place:
the url given for the action attribute. Client-side scripting can alter
that goto according to conditions, or server-side you can generate different
documents to return based on the POST or GET data, but in that case you get
the different returns when "goto" the one handler given in the action
attribute.

This would be abundantly clear if you learned HTML before trying to get php
to generate HTML for you.

--
Lars Eighner
Countdown: 432 days to go.
What do you do when you're debranded?

Re: IF THEN for button? (HTML Post)

am 15.11.2007 21:30:09 von Bucky Kaufman

This is a multi-part message in MIME format.

------=_NextPart_000_0764_01C82793.E851A640
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

wrote in message =
news:5a860b31-c624-4f3f-a74d-59a507c3075e@f3g2000hsg.googleg roups.com...
> Is it possible in PHP to do the following?
>=20
> I've got a php page with a form, that form has radio buttons group and
> an option group list. It also have a button, Continue.
>=20
> When the continue button is presed I want it to look at: this:
> If Radiobutton1 is pressed and option group lsteditorial is selected,
> goto write-editorial.php
> if Radiobutton1 is pressed and option group lstpres is selected, goto
> write-press.php

This is how I would do it:

if(is_set($_POST)){
switch ("on"){
case $_POST["RadioButton1"]:
if($_POST["1stpres"] == "checked"){
echo =
"";
}
break; =20
case $_POST["RadioButton2"]:
//doit again
break; =20
}
} else {
// Display HTML FORM.
}
?>

I should probably point out that "option group" was probably the wrong =
phrase to use here.
HTML Select's have something called option groups, but you didn't use =
them here.
You just used straight-options.

------=_NextPart_000_0764_01C82793.E851A640
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable



charset=3Diso-8859-1">




< href=3D"mailto:paul814@excite.com"> size=3D2>paul814@excite.com> =
wrote in=20
message
href=3D"news:5a860b31-c624-4f3f-a74d-59a507c3075e@f3g2000hsg .googlegroups=
..com"> face=3DArial=20
size=3D2>news:5a860b31-c624-4f3f-a74d-59a507c3075e@f3g2000hs g.googlegroup=
s.com face=3DArial size=3D2>...

> Is it possible in PHP to do the=20
following?
>
> I've got a php page with a form, that form =
has radio=20
buttons group and
> an option group list.  It also have a =
button,=20
Continue.
>
> When the continue button is presed I want it =
to look=20
at: this:
> If Radiobutton1 is pressed and option group =
lsteditorial is=20
selected,
> goto write-editorial.php
> if Radiobutton1 is =
pressed=20
and option group lstpres is selected, goto
> =
write-press.php

 

This is how I would do it:

 

<?php

if(is_set($_POST)){

    switch =
("on"){


        =
case=20
$_POST["RadioButton1"]:

size=3D2>          &nbs=
p;=20
if($_POST["1stpres"] == "checked"){

       =20
        echo=20
"<script>this.location=3D'write-press.php';</script>";
=

       =20
    }

       =20
    break;       =20

        =
case=20
$_POST["RadioButton2"]:

size=3D2>       =20
    //doit again

       =20
    break;       =20
    =
}

} else {

    // Display HTML=20
FORM.

}

?>

size=3D2> 

I should probably point out that =
"option group" was=20
probably the wrong phrase to use here.

HTML Select's have something called =
option groups,=20
but you didn't use them here.

You just used =
straight-options.

 


------=_NextPart_000_0764_01C82793.E851A640--

Re: IF THEN for button?

am 16.11.2007 10:57:10 von Rob

On Nov 15, 1:20 pm, paul...@excite.com wrote:
> Is it possible in PHP to do the following?
>

Paul, without a doubt, you should be doing this with JavaScript.

If you need any help with the code, let me know.

Rob.