Welcome to dbForumz.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

Two forms

 
Goto page 1, 2
   Database Forums (Home) -> PHP RSS
Next:  shopping cart  
Author Message
Shelly

External


Since: Jun 11, 2005
Posts: 56



(Msg. 1) Posted: Mon Oct 16, 2006 10:59 am
Post subject: Two forms
Archived from groups: comp>lang>php, others (more info?)

I have two forms on one page. In Form A I have drop-down list (single
selection). When I click a submit button in form B, I would like to pick up
the value showing in the drop down list of Form A. Can this be done?

The reason for separating the two forms is that Form A opens a new browser
window with selection in that form, whereas Form B keeps it in the same
browser window for its selections. The drop-down list value, however, is
used in both and I would not want to repeat that list in Form B.

Shelly

 >> Stay informed about: Two forms 
Back to top
Login to vote
NurAzije

External


Since: Feb 27, 2005
Posts: 15



(Msg. 2) Posted: Mon Oct 16, 2006 10:59 am
Post subject: Re: Two forms [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Shelly wrote:
> I have two forms on one page. In Form A I have drop-down list (single
> selection). When I click a submit button in form B, I would like to pick up
> the value showing in the drop down list of Form A. Can this be done?
>
> The reason for separating the two forms is that Form A opens a new browser
> window with selection in that form, whereas Form B keeps it in the same
> browser window for its selections. The drop-down list value, however, is
> used in both and I would not want to repeat that list in Form B.
>
> Shelly

You can do it by JavaScript or by AJAX, can you provide us with the
code, so I can explain to you eaisier ??
--------------------------------------------------------------------------------------

For php/ajax/javascript tutorials and tips, visit me on my blog at
http://www.nurazije.co.nr

 >> Stay informed about: Two forms 
Back to top
Login to vote
Shelly

External


Since: Jun 11, 2005
Posts: 56



(Msg. 3) Posted: Mon Oct 16, 2006 8:58 pm
Post subject: Re: Two forms [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

"NurAzije" wrote in message

>
> Shelly wrote:
>> I have two forms on one page. In Form A I have drop-down list (single
>> selection). When I click a submit button in form B, I would like to pick
>> up
>> the value showing in the drop down list of Form A. Can this be done?
>>
>> The reason for separating the two forms is that Form A opens a new
>> browser
>> window with selection in that form, whereas Form B keeps it in the same
>> browser window for its selections. The drop-down list value, however, is
>> used in both and I would not want to repeat that list in Form B.
>>
>> Shelly
>
> You can do it by JavaScript or by AJAX, can you provide us with the
> code, so I can explain to you eaisier ??

I don't know AJAX.

[ php code]
<?php
if (isset($_POST['A'])) {
$list = $_POST['theList'];
header('Location: A_target.php?list=' . $list);
exit();
}

<?php
if (isset($_POST['B'])) {
$list = $_POST['theList'];
header('Location: B_target.php?list=' . $list);
exit();
}
?>

[html area]
<form action="" method="POST" name="A" target="_blank">
<select name="theList">
<option value="First'">First </option>
<option value="Second'">Second </option>
</select>
....other stuff...
<input type="submit" value="Form A button" name="A">
</form>

<form action="" method="POST" name="B" target="_self">
<input type="submit" value="Form A button" name="B">
</form>
 >> Stay informed about: Two forms 
Back to top
Login to vote
Shelly

External


Since: Jun 11, 2005
Posts: 56



(Msg. 4) Posted: Mon Oct 16, 2006 10:10 pm
Post subject: Re: Two forms [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

"Shelly" wrote in message

>
> "NurAzije" wrote in message
>
>>
>> Shelly wrote:
>>> I have two forms on one page. In Form A I have drop-down list (single
>>> selection). When I click a submit button in form B, I would like to
>>> pick up
>>> the value showing in the drop down list of Form A. Can this be done?
>>>
>>> The reason for separating the two forms is that Form A opens a new
>>> browser
>>> window with selection in that form, whereas Form B keeps it in the same
>>> browser window for its selections. The drop-down list value, however,
>>> is
>>> used in both and I would not want to repeat that list in Form B.
>>>
>>> Shelly
>>
>> You can do it by JavaScript or by AJAX, can you provide us with the
>> code, so I can explain to you eaisier ??
>
> I don't know AJAX.
>
> [ php code]
> <?php
> if (isset($_POST['A'])) {
> $list = $_POST['theList'];
> header('Location: A_target.php?list=' . $list);
> exit();
> }
>
> <?php
> if (isset($_POST['B'])) {
> $list = $_POST['theList'];
> header('Location: B_target.php?list=' . $list);
> exit();
> }
> ?>
>
> [html area]
> <form action="" method="POST" name="A" target="_blank">
> <select name="theList">
> <option value="First'">First </option>
> <option value="Second'">Second </option>
> </select>
> ....other stuff...
> <input type="submit" value="Form A button" name="A">
> </form>
>
> <form action="" method="POST" name="B" target="_self">
> <input type="submit" value="Form A button" name="B">
> </form>


That second one should be "Form B button" and the second <?php was a cut
and paste error.
 >> Stay informed about: Two forms 
Back to top
Login to vote
Gleep

External


Since: May 29, 2004
Posts: 4



(Msg. 5) Posted: Mon Oct 16, 2006 10:10 pm
Post subject: Re: Two forms [Login to view extended thread Info.]
Archived from groups: alt>comp>lang>php (more info?)

On Mon, 16 Oct 2006 22:10:36 GMT, "Shelly" wrote:

>
>"Shelly" wrote in message
>
>>
>> "NurAzije" wrote in message
>>
>>>
>>> Shelly wrote:
>>>> I have two forms on one page. In Form A I have drop-down list (single
>>>> selection). When I click a submit button in form B, I would like to
>>>> pick up
>>>> the value showing in the drop down list of Form A. Can this be done?
>>>>
>>>> The reason for separating the two forms is that Form A opens a new
>>>> browser
>>>> window with selection in that form, whereas Form B keeps it in the same
>>>> browser window for its selections. The drop-down list value, however,
>>>> is
>>>> used in both and I would not want to repeat that list in Form B.
>>>>
>>>> Shelly
>>>
>>> You can do it by JavaScript or by AJAX, can you provide us with the
>>> code, so I can explain to you eaisier ??
>>
>> I don't know AJAX.
>>
>> [ php code]
>> <?php
>> if (isset($_POST['A'])) {
>> $list = $_POST['theList'];
>> header('Location: A_target.php?list=' . $list);
>> exit();
>> }
>>
>> <?php
>> if (isset($_POST['B'])) {
>> $list = $_POST['theList'];
>> header('Location: B_target.php?list=' . $list);
>> exit();
>> }
>> ?>
>>
>> [html area]
>> <form action="" method="POST" name="A" target="_blank">
>> <select name="theList">
>> <option value="First'">First </option>
>> <option value="Second'">Second </option>
>> </select>
>> ....other stuff...
>> <input type="submit" value="Form A button" name="A">
>> </form>
>>
>> <form action="" method="POST" name="B" target="_self">
>> <input type="submit" value="Form A button" name="B">
>> </form>
>
>
>That second one should be "Form B button" and the second <?php was a cut
>and paste error.
>



on form A you would add this...
<select name="theList"
onchange="window.document.FormB.Bval.value=(this.options[this.selectedIndex].text)" >

modify form B...
<form action="" method="POST" name="FormB" target="_self">
<input type="submit" value="" name="Bval">
</form>

the idea is, on a change to form A drop down, that value is grabbed and assigned to the value on the
input submit button on form B.
 >> Stay informed about: Two forms 
Back to top
Login to vote
NurAzije

External


Since: Feb 27, 2005
Posts: 15



(Msg. 6) Posted: Mon Oct 16, 2006 11:45 pm
Post subject: Re: Two forms [Login to view extended thread Info.]
Archived from groups: comp>lang>php, others (more info?)

For AJAX it is so easy, you have a 5 minutes tutorial on this link :
http://www.nurazije.co.nr/2006/10/5-minutes-ajax-tutorial.html

You can put the second bottun in the first form, like this:
<form action="" method="POST" name="Aform" target="_blank">
<select name="theList">
<option value="First'">First </option>
<option value="Second'">Second </option>
</select>
....other stuff...
<input type="submit" value="Form A button" name="A">
<input type="button" value="Form B button" name="B"
onclick="document.Aform.submit();">
</form>
You will see I have added onclick="document.Aform.submit();", and the
type is button, put an action path for the form, and change the form
name as I did, every element must have a unique name.
The php code must look like this:
<?php
if (isset($_POST['A'])) {
$list = $_POST['theList'];
header('Location: A_target.php?list=' . $list);
exit();
}elseif(isset($_POST['B'])) {
$list = $_POST['theList'];
header('Location: B_target.php?list=' . $list);
exit();
}
?>
Thats it, hope you got the idea...
 >> Stay informed about: Two forms 
Back to top
Login to vote
Shelly

External


Since: Jun 11, 2005
Posts: 56



(Msg. 7) Posted: Tue Oct 17, 2006 8:37 pm
Post subject: Re: Two forms [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

It didn't work. Several things:
1 - I had the target for Aform be _self and for Bform be _blank since it is
in A form with the _self that the list exists.
1 - The action path is "", even though you said you put one in. I left it
that way.
2 - I assume you meant document.Bform.submit(); and not
document.Aform.submit();
3 - If I made the change to Bform (above), then it opened a new window
(according to Bform), but it didn't pass the value of theList, even though I
have the B button in A form, and the page that is brought up in that new
window is the current page, not the redirected one. Aform works fine.
4 - If I left it at Aform, it doesn't work either.

Here is the code:
junk.php
======
<?php
if (isset($_POST['A'])) {
$val = $_POST['theList'];
echo "A0=" . $val . "<br>";
} else if (isset($_POST['B'])) {
$val = $_POST['theList'];
header("Location: junk2.php?val=" . $val);
exit();
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html><head><meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<title>Untitled Document</title></head>

<form action="" method="post" target="_self" name="Aform">
<select name="theList">
<option value="First">First</option>
<option value="Second">Second</option>
</select>
<input type="submit" name="A" value="submit A">
<input type="button" name="B" value="submit B"
onClick="document.Bform.submit()">
</form>

<form action="" method="post" target="_blank" name="Bform">
</form>
<body></body></html>


junk2.php
=======
<?php
$val = $_GET['val'];
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>

<body>
The value of val is <?php echo $val . "<br>"; ?>
</body></html>




"NurAzije" wrote in message

> For AJAX it is so easy, you have a 5 minutes tutorial on this link :
> http://www.nurazije.co.nr/2006/10/5-minutes-ajax-tutorial.html
>
> You can put the second bottun in the first form, like this:
> <form action="" method="POST" name="Aform" target="_blank">
> <select name="theList">
> <option value="First'">First </option>
> <option value="Second'">Second </option>
> </select>
> ....other stuff...
> <input type="submit" value="Form A button" name="A">
> <input type="button" value="Form B button" name="B"
> onclick="document.Aform.submit();">
> </form>
> You will see I have added onclick="document.Aform.submit();", and the
> type is button, put an action path for the form, and change the form
> name as I did, every element must have a unique name.
> The php code must look like this:
> <?php
> if (isset($_POST['A'])) {
> $list = $_POST['theList'];
> header('Location: A_target.php?list=' . $list);
> exit();
> }elseif(isset($_POST['B'])) {
> $list = $_POST['theList'];
> header('Location: B_target.php?list=' . $list);
> exit();
> }
> ?>
> Thats it, hope you got the idea...
>
 >> Stay informed about: Two forms 
Back to top
Login to vote
Rik

External


Since: Oct 16, 2005
Posts: 92



(Msg. 8) Posted: Wed Oct 18, 2006 2:08 am
Post subject: Re: Two forms [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Shelly wrote:
> It didn't work. Several things:
> 1 - I had the target for Aform be _self and for Bform be _blank since
> it is in A form with the _self that the list exists.
> 1 - The action path is "", even though you said you put one in. I
> left it that way.
> 2 - I assume you meant document.Bform.submit(); and not
> document.Aform.submit();
> 3 - If I made the change to Bform (above), then it opened a new window
> (according to Bform), but it didn't pass the value of theList, even
> though I have the B button in A form, and the page that is brought up
> in that new window is the current page, not the redirected one.
> Aform works fine. 4 - If I left it at Aform, it doesn't work either.
>
> Here is the code:
> junk.php
> ======
> <?php
> if (isset($_POST['A'])) {
> $val = $_POST['theList'];
> echo "A0=" . $val . "<br>";
> } else if (isset($_POST['B'])) {
> $val = $_POST['theList'];
> header("Location: junk2.php?val=" . $val);
> exit();
> }

Well, first of all:
1. Allthough AJAX is a nice buzzword, this has nothing to do with
(a)synchronous calls with javascript to the server.
2. Are you absolutely sure you want to rely on javascript for this? In some
browsers/for some users it will simply not work.
3. This should actually be in comp.lang.javascript

But here you go:
What I'd do, is have the buttons in the SAME form. Either that, or
duplicate the selection list if you want a sturdy application.

junk.php
<?php

if(isset($_POST['B']||isset($_POST['A'])){
if(isset($_POST['B'])) echo 'You choose to open this a new window, but
this is not possible without javascript enabled';
$val = $_POST['theList'];
echo "A0=" . $val . "<br>";
}
?>
<script type="text/javascript">
function form_new_window(button){
var form = button.form;
form.action = './junk2.php';
form.method = 'GET'; //or keep it a post
form.target = '_blank'; //new window
return true; //just to make sure.
}
</script>
<form action="./junk.php" method="POST" target="_self">
<select name="theList">
<option value="First'">First </option>
<option value="Second'">Second </option>
</select>
<input type="submit" value="Same window" name="A">
<input type="submit" value="New window" name="B"
onclick="form_new_window(this)">
</form>

--
Rik Wasmus
 >> Stay informed about: Two forms 
Back to top
Login to vote
Shelly

External


Since: Jun 11, 2005
Posts: 56



(Msg. 9) Posted: Wed Oct 18, 2006 2:32 am
Post subject: Re: Two forms [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Thank you, Rik, very much. This worked.

Shelly

"Rik" wrote in message

> Shelly wrote:
>> It didn't work. Several things:
>> 1 - I had the target for Aform be _self and for Bform be _blank since
>> it is in A form with the _self that the list exists.
>> 1 - The action path is "", even though you said you put one in. I
>> left it that way.
>> 2 - I assume you meant document.Bform.submit(); and not
>> document.Aform.submit();
>> 3 - If I made the change to Bform (above), then it opened a new window
>> (according to Bform), but it didn't pass the value of theList, even
>> though I have the B button in A form, and the page that is brought up
>> in that new window is the current page, not the redirected one.
>> Aform works fine. 4 - If I left it at Aform, it doesn't work either.
>>
>> Here is the code:
>> junk.php
>> ======
>> <?php
>> if (isset($_POST['A'])) {
>> $val = $_POST['theList'];
>> echo "A0=" . $val . "<br>";
>> } else if (isset($_POST['B'])) {
>> $val = $_POST['theList'];
>> header("Location: junk2.php?val=" . $val);
>> exit();
>> }
>
> Well, first of all:
> 1. Allthough AJAX is a nice buzzword, this has nothing to do with
> (a)synchronous calls with javascript to the server.
> 2. Are you absolutely sure you want to rely on javascript for this? In
> some
> browsers/for some users it will simply not work.
> 3. This should actually be in comp.lang.javascript
>
> But here you go:
> What I'd do, is have the buttons in the SAME form. Either that, or
> duplicate the selection list if you want a sturdy application.
>
> junk.php
> <?php
>
> if(isset($_POST['B']||isset($_POST['A'])){
> if(isset($_POST['B'])) echo 'You choose to open this a new window, but
> this is not possible without javascript enabled';
> $val = $_POST['theList'];
> echo "A0=" . $val . "<br>";
> }
> ?>
> <script type="text/javascript">
> function form_new_window(button){
> var form = button.form;
> form.action = './junk2.php';
> form.method = 'GET'; //or keep it a post
> form.target = '_blank'; //new window
> return true; //just to make sure.
> }
> </script>
> <form action="./junk.php" method="POST" target="_self">
> <select name="theList">
> <option value="First'">First </option>
> <option value="Second'">Second </option>
> </select>
> <input type="submit" value="Same window" name="A">
> <input type="submit" value="New window" name="B"
> onclick="form_new_window(this)">
> </form>
>
> --
> Rik Wasmus
>
>
 >> Stay informed about: Two forms 
Back to top
Login to vote
Shelly

External


Since: Jun 11, 2005
Posts: 56



(Msg. 10) Posted: Wed Oct 18, 2006 2:53 am
Post subject: Re: Two forms [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

I was a little too quick in replying. I have four buttons that should not
open a new window and two that should. In my actual application I sent it
to redir.php in the Javascript. Once there in redir.php, I test on which of
the two buttons in the original page activated it and then send it to the
proper page.

The problem is that even though I only added the onclick to the two buttons
for a new page, ALL six buttons go to redir.php AND open a new window. (I
have the tests on the four other buttons in the original page.)

Can you think of any reason why the buttons that do not have the onclick
would execute the Javascript and go to redir.php? I placed the script just
inside <body> and before <form>.

Here is the actual code snippet for a button for a new page:

<input type="submit" value="Click Here To" name="health"
onclick="form_new_window(this)"
style="color: #E1D2AA; border: 2px solid; border-color:
#CD968F #610E08 #400906 #B14F46; background-color: #99160C; font-family:
Verdana; font-size: 12px; display: block; height: 25px; width: 148px;
font-weight: bold; margin: 3px; padding: 2px; padding-bottom: 5px;
vertical-align: middle;" />

and here is one for not a new page:

<input type="submit" value="Click Here To" name="shop"
style="color: #E1D2AA; border: 2px solid; border-color:
#CD968F #610E08 #400906 #B14F46; background-color: #99160C; font-family:
Verdana; font-size: 12px; display: block; height: 25px; width: 148px;
font-weight: bold; margin: 3px; padding: 2px; padding-bottom: 5px;
vertical-align: middle;" />

and the Javascript is:

<body>
<script type="text/javascript">
function form_new_window(button){
var form = button.form;
form.action = 'redir.php';
form.method = 'POST';
form.target = '_blank';
return true;
}
</script>
<form ....>
 >> Stay informed about: Two forms 
Back to top
Login to vote
Jerry Stuckle

External


Since: Aug 11, 2004
Posts: 1367



(Msg. 11) Posted: Wed Oct 18, 2006 2:53 am
Post subject: Re: Two forms [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Shelly wrote:
> I was a little too quick in replying. I have four buttons that should not
> open a new window and two that should. In my actual application I sent it
> to redir.php in the Javascript. Once there in redir.php, I test on which of
> the two buttons in the original page activated it and then send it to the
> proper page.
>
> The problem is that even though I only added the onclick to the two buttons
> for a new page, ALL six buttons go to redir.php AND open a new window. (I
> have the tests on the four other buttons in the original page.)
>
> Can you think of any reason why the buttons that do not have the onclick
> would execute the Javascript and go to redir.php? I placed the script just
> inside <body> and before <form>.
>
> Here is the actual code snippet for a button for a new page:
>
> <input type="submit" value="Click Here To" name="health"
> onclick="form_new_window(this)"
> style="color: #E1D2AA; border: 2px solid; border-color:
> #CD968F #610E08 #400906 #B14F46; background-color: #99160C; font-family:
> Verdana; font-size: 12px; display: block; height: 25px; width: 148px;
> font-weight: bold; margin: 3px; padding: 2px; padding-bottom: 5px;
> vertical-align: middle;" />
>
> and here is one for not a new page:
>
> <input type="submit" value="Click Here To" name="shop"
> style="color: #E1D2AA; border: 2px solid; border-color:
> #CD968F #610E08 #400906 #B14F46; background-color: #99160C; font-family:
> Verdana; font-size: 12px; display: block; height: 25px; width: 148px;
> font-weight: bold; margin: 3px; padding: 2px; padding-bottom: 5px;
> vertical-align: middle;" />
>
> and the Javascript is:
>
> <body>
> <script type="text/javascript">
> function form_new_window(button){
> var form = button.form;
> form.action = 'redir.php';
> form.method = 'POST';
> form.target = '_blank';
> return true;
> }
> </script>
> <form ....>
>
>

Shelly,

You're probably better off asking javascript questions in a javascript
newsgroup, don't you think? Smile

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex.RemoveThis@attglobal.net
==================
 >> Stay informed about: Two forms 
Back to top
Login to vote
Rik

External


Since: Oct 16, 2005
Posts: 92



(Msg. 12) Posted: Wed Oct 18, 2006 5:25 am
Post subject: Re: Two forms [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Shelly wrote:
> I was a little too quick in replying. I have four buttons that
> should not open a new window and two that should. In my actual
> application I sent it to redir.php in the Javascript. Once there in
> redir.php, I test on which of the two buttons in the original page
> activated it and then send it to the proper page.
>
> The problem is that even though I only added the onclick to the two
> buttons for a new page, ALL six buttons go to redir.php AND open a
> new window. (I have the tests on the four other buttons in the
> original page.)
>
> Can you think of any reason why the buttons that do not have the
> onclick would execute the Javascript and go to redir.php? I placed
> the script just inside <body> and before <form>.

Ahum, please, pleas, do not use css inline like this. Give the buttons a
class and put the layout in an external css-file....

> <form ....>

I'm very curious what your <form> tag actually sais, because I've switched
them around, defaulting to _self instead of _blank.... That would be the
easy solution Smile

If not, could you provide a link of the form in action perhaps? (or the
exact file)

Grtz,
--
Rik Wasmus
 >> Stay informed about: Two forms 
Back to top
Login to vote
Shelly

External


Since: Jun 11, 2005
Posts: 56



(Msg. 13) Posted: Wed Oct 18, 2006 5:25 am
Post subject: Re: Two forms [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

"Rik" wrote in message

> Shelly wrote:
>> I was a little too quick in replying. I have four buttons that
>> should not open a new window and two that should. In my actual
>> application I sent it to redir.php in the Javascript. Once there in
>> redir.php, I test on which of the two buttons in the original page
>> activated it and then send it to the proper page.
>>
>> The problem is that even though I only added the onclick to the two
>> buttons for a new page, ALL six buttons go to redir.php AND open a
>> new window. (I have the tests on the four other buttons in the
>> original page.)
>>
>> Can you think of any reason why the buttons that do not have the
>> onclick would execute the Javascript and go to redir.php? I placed
>> the script just inside <body> and before <form>.
>
> Ahum, please, pleas, do not use css inline like this. Give the buttons a
> class and put the layout in an external css-file....
>
>> <form ....>


Will do. right now, I just wanted to get ti to work.


>
> I'm very curious what your <form> tag actually sais, because I've switched
> them around, defaulting to _self instead of _blank.... That would be the
> easy solution Smile

It defaults to "_self"

<form action="" method="POST" name="pets" target="_self">

Shelly
 >> Stay informed about: Two forms 
Back to top
Login to vote
Shelly

External


Since: Jun 11, 2005
Posts: 56



(Msg. 14) Posted: Wed Oct 18, 2006 9:40 am
Post subject: Re: Two forms [Login to view extended thread Info.]
Archived from groups: alt>comp>lang>php (more info?)

That worked fine. Thank you.

"Gleep" wrote in message

> On Mon, 16 Oct 2006 22:10:36 GMT, "Shelly"
> wrote:
>
>>
>>"Shelly" wrote in message
>>
>>>
>>> "NurAzije" wrote in message
>>>
>>>>
>>>> Shelly wrote:
>>>>> I have two forms on one page. In Form A I have drop-down list (single
>>>>> selection). When I click a submit button in form B, I would like to
>>>>> pick up
>>>>> the value showing in the drop down list of Form A. Can this be done?
>>>>>
>>>>> The reason for separating the two forms is that Form A opens a new
>>>>> browser
>>>>> window with selection in that form, whereas Form B keeps it in the
>>>>> same
>>>>> browser window for its selections. The drop-down list value, however,
>>>>> is
>>>>> used in both and I would not want to repeat that list in Form B.
>>>>>
>>>>> Shelly
>>>>
>>>> You can do it by JavaScript or by AJAX, can you provide us with the
>>>> code, so I can explain to you eaisier ??
>>>
>>> I don't know AJAX.
>>>
>>> [ php code]
>>> <?php
>>> if (isset($_POST['A'])) {
>>> $list = $_POST['theList'];
>>> header('Location: A_target.php?list=' . $list);
>>> exit();
>>> }
>>>
>>> <?php
>>> if (isset($_POST['B'])) {
>>> $list = $_POST['theList'];
>>> header('Location: B_target.php?list=' . $list);
>>> exit();
>>> }
>>> ?>
>>>
>>> [html area]
>>> <form action="" method="POST" name="A" target="_blank">
>>> <select name="theList">
>>> <option value="First'">First </option>
>>> <option value="Second'">Second </option>
>>> </select>
>>> ....other stuff...
>>> <input type="submit" value="Form A button" name="A">
>>> </form>
>>>
>>> <form action="" method="POST" name="B" target="_self">
>>> <input type="submit" value="Form A button" name="B">
>>> </form>
>>
>>
>>That second one should be "Form B button" and the second <?php was a cut
>>and paste error.
>>
>
>
>
> on form A you would add this...
> <select name="theList"
> onchange="window.document.FormB.Bval.value=(this.options[this.selectedIndex].text)"
> >
>
> modify form B...
> <form action="" method="POST" name="FormB" target="_self">
> <input type="submit" value="" name="Bval">
> </form>
>
> the idea is, on a change to form A drop down, that value is grabbed and
> assigned to the value on the
> input submit button on form B.
>
 >> Stay informed about: Two forms 
Back to top
Login to vote
Shelly

External


Since: Jun 11, 2005
Posts: 56



(Msg. 15) Posted: Wed Oct 18, 2006 11:01 am
Post subject: Re: Two forms [Login to view extended thread Info.]
Archived from groups: alt>comp>lang>php, others (more info?)

The solution that worked (thanks to Gleep) was to add:

onchange="window.document.formB.theListH.value=(this.options[this.selectedIndex].text)"

to a change in the drop-down list (theList in formA). I set theListH as a
hidden variable in the other form (formB).

I test on all the buttons and the ones that were from formB I use the value
from theListH and the ones from the first form I use the value from theList.
Of course, I initially set theListH to be the first one on the drop-down
list.

Shelly
 >> Stay informed about: Two forms 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
Is it possible to submit two forms at a time - Hi All, I need a small clarification in submitting the forms, Ur suggestions please. In a page I have two form and also two submit butons. (ie) <form name="myform" action="test.php" method="post" > ...

Problems with email forms and IE - i have tried this submiting this for with IE7 and IE6 and it doesn't work, but it does with firefox. any help will be really appreciated. //process.php <?php if (isset($_POST['submit'])){ $name=trim($_POST['name']); $company=trim($_POST['company']...

Using 'Mouse Up' Click in Forms in Queries - Is it possible to use a 'mouse up' click in forms where if you have for example, a drop down menu where you might click as the top selection, an equipment area (hard coded into the form), the type of equipment (a selection of 3 items again hard coded int...

recommendations for spell check for web forms - I have tried and tried and can not get aspell to install since my host will not allow me to compile programs. Without telling me to get a new host - which I plan - please recommend a web form spell checker that can easily be installed and check with..

newbie: saving meta data entered in forms (html forms) - php 4 If i create a simple form in xhtml/php and users saves the data they entered in the form to a database. Then meta data (hidden characters describing how the text shall be displayed - ie <br>, <bold> etc) in the form isn't saved.... ...
   Database Forums (Home) -> PHP All times are: Pacific Time (US & Canada)
Goto page 1, 2
Page 1 of 2

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]