473,883 Members | 2,601 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Form with 2 submit buttons...

Hi all!

I have a file where I'd have to submit buttons, and I need to differ
between those.

Step #1 - open html win with default selection

Step #2 - user may select some criteries for the list
Step 2 might be repeated, or not used at all. There is a button "apply
selection"

Step #3 - user selects a number of files/items, which are then handled.
There is a button for that.
Done.

The point is, that I need both the critearies for the SQL selection in
step 2, but also the selected files (list) in step 3. Actually the
selection for step 2 are needed for step 3 only.

Any good ideas on how I might have 2 buttons with submits data?

BR
Sonnich

Aug 7 '06 #1
15 8851

Sonnich wrote:
Hi all!

I have a file where I'd have to submit buttons, and I need to differ
between those.

Step #1 - open html win with default selection

Step #2 - user may select some criteries for the list
Step 2 might be repeated, or not used at all. There is a button "apply
selection"

Step #3 - user selects a number of files/items, which are then handled.
There is a button for that.
Done.

The point is, that I need both the critearies for the SQL selection in
step 2, but also the selected files (list) in step 3. Actually the
selection for step 2 are needed for step 3 only.

Any good ideas on how I might have 2 buttons with submits data?

BR
Sonnich
Not entirely sure what you're trying to do, but if you want two submit
buttons just give them different names:

<input type="submit" name="foo" value="First Button"/>
<input type="submit" name="bar" value="Second Button"/>

And on the target page:

if(isset($_REQU EST['foo'])) {
//first button was used
}
else if(isset($_REQU EST['bar'])) {
//second button was used
}

Aug 7 '06 #2

ZeldorBlat wrote:
Sonnich wrote:
Hi all!

I have a file where I'd have to submit buttons, and I need to differ
between those.

Step #1 - open html win with default selection

Step #2 - user may select some criteries for the list
Step 2 might be repeated, or not used at all. There is a button "apply
selection"

Step #3 - user selects a number of files/items, which are then handled.
There is a button for that.
Done.

The point is, that I need both the critearies for the SQL selection in
step 2, but also the selected files (list) in step 3. Actually the
selection for step 2 are needed for step 3 only.

Any good ideas on how I might have 2 buttons with submits data?

BR
Sonnich

Not entirely sure what you're trying to do, but if you want two submit
buttons just give them different names:

<input type="submit" name="foo" value="First Button"/>
<input type="submit" name="bar" value="Second Button"/>

And on the target page:

if(isset($_REQU EST['foo'])) {
//first button was used
}
else if(isset($_REQU EST['bar'])) {
//second button was used
}
That was exactly what I needed.

I found that it should work here too:

if( !(isset($_POST[$part1[$i]]) && ($_POST[$part1[$i]] ==
"")) )
echo " checked";
else
echo "";

Idea: checkbox is default checked, but only if set and set to nothing
it is not set.
Boolean algebra. Only if set, and set to nothing, then it is not set.

But by some reason it does not work. I have done this a 147533 times,
and here it does not work. Why?

Aug 7 '06 #3
Sonnich wrote:
ZeldorBlat wrote:
>Sonnich wrote:
>>Hi all!

I have a file where I'd have to submit buttons, and I need to differ
between those.

Step #1 - open html win with default selection

Step #2 - user may select some criteries for the list
Step 2 might be repeated, or not used at all. There is a button "apply
selection"

Step #3 - user selects a number of files/items, which are then handled.
There is a button for that.
Done.

The point is, that I need both the critearies for the SQL selection in
step 2, but also the selected files (list) in step 3. Actually the
selection for step 2 are needed for step 3 only.

Any good ideas on how I might have 2 buttons with submits data?

BR
Sonnich
Not entirely sure what you're trying to do, but if you want two submit
buttons just give them different names:

<input type="submit" name="foo" value="First Button"/>
<input type="submit" name="bar" value="Second Button"/>

And on the target page:

if(isset($_REQ UEST['foo'])) {
//first button was used
}
else if(isset($_REQU EST['bar'])) {
//second button was used
}

That was exactly what I needed.

I found that it should work here too:

if( !(isset($_POST[$part1[$i]]) && ($_POST[$part1[$i]] ==
"")) )
echo " checked";
else
echo "";

Idea: checkbox is default checked, but only if set and set to nothing
it is not set.
Boolean algebra. Only if set, and set to nothing, then it is not set.

But by some reason it does not work. I have done this a 147533 times,
and here it does not work. Why?
I think a misplaced closing parentheses:

if( !(isset($_POST[$part1[$i]])) && ($_POST[$part1[$i]] =="") ){
echo " checked";
}
else {
echo "";
}

--
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com
Aug 7 '06 #4
I found that it should work here too:

if( !(isset($_POST[$part1[$i]]) && ($_POST[$part1[$i]] ==
"")) )
echo " checked";
else
echo "";

Idea: checkbox is default checked, but only if set and set to nothing
it is not set.
Boolean algebra. Only if set, and set to nothing, then it is not set.

But by some reason it does not work. I have done this a 147533 times,
and here it does not work. Why?
I think a misplaced closing parentheses:
You were right. This is what I have now:

if( !(isset($_POST[$part1[$i]])) && ($_POST[$part1[$i]] ==
"") )
echo " checked";
else
echo "";

but is still does not work. It sets them first time as it should, but
after that it inverts the selection.
I dont get it.

Any ideas anyone?

Aug 7 '06 #5
"Sonnich" <so************ @elektrobit.com wrote:
I found that it should work here too:

if( !(isset($_POST[$part1[$i]]) && ($_POST[$part1[$i]] ==
"")) )
echo " checked";
else
echo "";

Idea: checkbox is default checked, but only if set and set to nothing
it is not set.
Boolean algebra. Only if set, and set to nothing, then it is not set.

But by some reason it does not work. I have done this a 147533 times,
and here it does not work. Why?
Are you sure you want $_POST[$part1[$i]] ? Maybe $_POST[$part1][$i] ?

Hard to know without understanding how your form and code look, but my
proposed alternative is more typical for dealing with checkboxes.

If I am correct in my theory, turning on E_ALL error reporting would
have drawn attention to the issue.

miguel
--
Photos from 40 countries on 5 continents: http://travel.u.nu
Latest photos: Malaysia; Thailand; Singapore; Spain; Morocco
Airports of the world: http://airport.u.nu
Aug 7 '06 #6

Miguel Cruz wrote:
"Sonnich" <so************ @elektrobit.com wrote:
I found that it should work here too:

if( !(isset($_POST[$part1[$i]]) && ($_POST[$part1[$i]] ==
"")) )
echo " checked";
else
echo "";

Idea: checkbox is default checked, but only if set and set to nothing
it is not set.
Boolean algebra. Only if set, and set to nothing, then it is not set.

But by some reason it does not work. I have done this a 147533 times,
and here it does not work. Why?

Are you sure you want $_POST[$part1[$i]] ? Maybe $_POST[$part1][$i] ?

Hard to know without understanding how your form and code look, but my
proposed alternative is more typical for dealing with checkboxes.

If I am correct in my theory, turning on E_ALL error reporting would
have drawn attention to the issue.
I have a number of checkboxes, which are created from a DB. I read a
number of codes into an array $part1[]= then I create the checkboxes
Name=\"$part1[$i]] \" and at the same time set them to checked or not.
At first they should be checked, but the user can select to uncheck
them. Then, when submitting the now present values should be in use.

BR
Sonnich

Aug 7 '06 #7
Sonnich wrote:

[You are improperly snipping who wrote what quote which can get quite
confusing, try to keep or replace quoted author notices which I have
restored to show you....]

>Sonnich wrote:
>>>
I found that it should work here too:

if( !(isset($_POST[$part1[$i]]) && ($_POST[$part1[$i]] ==
"")) )
echo " checked";
else
echo "";

Idea: checkbox is default checked, but only if set and set to nothing
it is not set.
Boolean algebra. Only if set, and set to nothing, then it is not set.

But by some reason it does not work. I have done this a 147533 times,
and here it does not work. Why?
Jonathan wrote:
>>
I think a misplaced closing parentheses:

You were right. This is what I have now:

if( !(isset($_POST[$part1[$i]])) && ($_POST[$part1[$i]] ==
"") )
echo " checked";
else
echo "";

but is still does not work. It sets them first time as it should, but
after that it inverts the selection.
I dont get it.

Any ideas anyone?
Not enough info to determine, need URL and your source code. What you
you me by 'sets them'? Sets what? And 'after the first time'? Are your
reposting to the same script?

--
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com
Aug 7 '06 #8

Jonathan N. Little wrote:
Sonnich wrote:

[You are improperly snipping who wrote what quote which can get quite
confusing, try to keep or replace quoted author notices which I have
restored to show you....]

>Sonnich wrote:
>>>
I found that it should work here too:

if( !(isset($_POST[$part1[$i]]) && ($_POST[$part1[$i]] ==
"")) )
echo " checked";
else
echo "";

Idea: checkbox is default checked, but only if set and set to nothing
it is not set.
Boolean algebra. Only if set, and set to nothing, then it is not set.

But by some reason it does not work. I have done this a 147533 times,
and here it does not work. Why?
Jonathan wrote:
>>
I think a misplaced closing parentheses:
You were right. This is what I have now:

if( !(isset($_POST[$part1[$i]])) && ($_POST[$part1[$i]] ==
"") )
echo " checked";
else
echo "";

but is still does not work. It sets them first time as it should, but
after that it inverts the selection.
I dont get it.

Any ideas anyone?

Not enough info to determine, need URL and your source code. What you
you me by 'sets them'? Sets what? And 'after the first time'? Are your
reposting to the same script?
Yes, I am reposting to the same script. An example:
<html>
<form method=post name='myform' action='sjjtest .php'><!-- same file -->
<table>
<?
$part1[]="a";
$part1[]="b";
$part1[]="c";
for($i=0; $i<count($part1 ); $i++)
{
echo "<td><input name=\"".$part1[$i]."\" type=\"checkbox \"
value=\"true\"" ;
if( !(isset($_POST[$part1[$i]])) && ($_POST[$part1[$i]] == "") )
echo " checked";
echo ">". isset($_POST[$part1[$i]])."-".$_POST[$part1[$i]]
.."</td></tr>";
}
?>
<tr><td><inpu t class="box" name="apply_sel ection" type="submit" value="
Apply selection "></td></tr>
</table>
</form>
</html>

Try it and you will see

Aug 7 '06 #9
Rik
Sonnich wrote:
<?
$part1[]="a";
$part1[]="b";
$part1[]="c";
for($i=0; $i<count($part1 ); $i++)
{
echo "<td><input name=\"".$part1[$i]."\" type=\"checkbox \"
value=\"true\"" ;
if( !(isset($_POST[$part1[$i]])) && ($_POST[$part1[$i]] == "") )
echo " checked";
echo ">". isset($_POST[$part1[$i]])."-".$_POST[$part1[$i]]
Euhm, what it this last bit
'isset($_POST[$part1[$i]])."-".$_POST[$part1[$i]]' actually supposed to do?
It will either print '1-true' or ''(nothing)?
."</td></tr>";
}

You've got a submit button, it's name is in the POST array, so it should be
present if the form is posted. Before posting, everything should be checked.
After the posting only the previously left checked values should be checked,
the rest unchecked. Is that how it should work? in that case:

So let's say checked when:
- $_POST['submit'] is not set
OR
- $_POST[$key] is in the array AND the value isn't empty

$part1 = array('a','b',' c'...........

foreach($part1 as $value){
$checked = (!isset($_POST['submit'] || (isset($_POST[$value]) &&
!empty($_POST[$value])) ? ' checked' : '';
printf('<td><in put type="checkbox" name="%1$s"
value="true"%2$ s>%1$s</td>',$value,$ch ecked');
}

Grtz,
--
Rik Wasmus
Aug 7 '06 #10

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

Similar topics

2
4810
by: jason | last post by:
Is it possible to POST a FORM to multiple URLS at the same time....OR.... Is the only workaround for this scenario to use response.redirect in the called ASP page and do a multi processing? - Jason
1
5759
by: monika | last post by:
hi ... I have an asp page which has 3 buttons. <p align="center"><input class="button" type="button" onClick="location='welStudent.asp';" value="Click to write a new story"></p> <p align="center"><input class="button" type="button" onClick="location='draftedStory.asp';" value="Click to complete the drafted story"></p> <p align="center"> <input class="button" type="submit" value="Click to view your grade sheet" name="submit"> </p>
2
1871
by: Matt | last post by:
The problem is I have 3 buttons that need to submit the form to different URL. My approach is to declare <input type="submit"> rather than <input type="button">. And put the following in the JavaScript: InputForm.action="URL LOCATION" InputForm.method="POST"; I think we don't need InputForm.submit(); because <input type="submit">.
15
6592
by: M Smith | last post by:
I have a form I want to submit to itself. I want to be able to type in a list of numbers and submit the form and have that list show up on the same form under the text box I typed them into and the buttons. The problem is when I post a form to itself, the Enter key will not submit the form, it only clears the contents of the text box. The only way I can submit is to click the submit button. Here is a simplified version of my code that I...
1
2805
by: Matt | last post by:
The problem is I have 3 buttons that need to submit the form to different URL. My approach is to declare <input type="submit"> rather than <input type="button">. And put the following in the JavaScript: InputForm.action="URL LOCATION" InputForm.method="POST"; I think we don't need InputForm.submit(); because <input type="submit">.
2
2117
by: Matt | last post by:
The ASP page has multiple buttons, and when the user clicks different buttons, it will submit the form data to different URLs. My first approach was to use BUTTON type, and triggers javascript function to submit the form data. However, it didn't work properly and I changed to use SUBMIT type. <INPUT TYPE="BUTTON" NAME="action1" VALUE="Return to Main Search Page" onClick="action1()">
1
6167
by: sman | last post by:
Hi, I recently read this article on About.com on how to create required fields for a form: http://javascript.about.com/library/scripts/blformvalidate.htm Everything works great except that there are no instructions on how to make checkboxes and radio buttons required. I've tried adding these to my form, but I'm having no luck. Anyone know how to add radio buttons and checkboxes using the existing code mentioned on the url? Thank you!
3
1931
by: M | last post by:
i am using submit buttons to send the user to different parts of a wizard. i am using if (if attribute.step1 exists) statements to send them to the appropriate section based on which submit button they pressed. well i would like to change these submit buttons into text links instead. however they do not pass form parameters like the submit button. any simple ways to accomplish this? this is what i have so far:
4
2301
by: wim taerwe | last post by:
Hello, I am looking for an easy way to have a delete button per subitem in 1 form. For example : a book can have many authors and when I edit the book details I want to have a list of the authors each with a separate delete-submitbutton next to it. Now I have the problem that I cannot know which exact author I want to delete when I click the delete button next to it.
5
1820
by: zoomcart.com | last post by:
Hello and thanks in advance for your help. I have code below that posts form data to a cgi scripted shopping cart and it works great on my mac/firefox browser, but it doesn't work on ibm/netscape machines. what gives? apparently the data isn't being recognized and so the cart defaults to it's home page. <form name='submit3' action='http://my.com/cart.cgi' method='post'> <input type='hidden' name='user' value='bighouse'> <input...
0
9933
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9786
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11125
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
7962
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7114
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5982
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4607
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4211
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3230
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.