Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to submit a form ? 2

Status
Not open for further replies.

TSch

Technical User
Jul 12, 2001
557
0
0
DE
Hello everyone,

I know this is kind of a basic question but no matter how much I google, I just can't figure out how to do it ... :-(

I have several forms. Each with a question you can answer checking one of the provided radio buttons. Like this:

Code:
<form action="radio.html" method="post">
<p>1. Question</p>
<fieldset>
<input type="radio" id="PG01S01" name="PG01" value="0">
<label for="PG01S01"> Answer 1</label>
<br>
<input type="radio" id="PG01S02" name="PG01" value="1">
<label for="PG01S02"> Answer 2</label>
</fieldset>
</form>

<form action="radio.html" method="post">
<p>2. Question</p>
<fieldset>
<input type="radio" id="PG02S02" name="PG02" value="0">
<label for="PG02S01"> Answer 1</label>
<br>
<input type="radio" id="PG02S02" name="PG02" value="1">
<label for="PG02S02"> Answer 2</label>
</fieldset>
</form>

... and so on

Now the first thing I fail to accomplish is to provide a button that's supposed to submit the answers into an evluation script. Something I tried was:

Code:
<form action="eval.php" method="POST" name="Evaluation" id="HP2">
<p align="center">
<input type="Submit" name="Engage2" id="E2" value="Submit Answers" />
</form>

But this isn't going to pass anything to eval.php and I have no idea how to make it do so.

Next problem:

The eval.php is supposed to check all the answers. I the value of an answer is "1" then a counter shall be increased by one and if the value is "0" then the counter shall not be increased.

At the end case the counter has a certain value another page with information is supposed to be displayed. If the counter is too low the Question form is supposed to be repeated.

Is there anyone who could help me out with that ?

Best Regards,
Thomas
 
But this isn't going to pass anything to eval.php and I have no idea how to make it do so.

No, that is EXACTLY what that code will do, provided that your form data input elements are placed in between the <form ... > opening tag and the </form> closing tag.

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum
 
You want to put all of the form elements within one form tag. Each acts as its own entity.

PHP:
<form action="eval.php" method="POST" name="Evaluation" id="HP2">
<p>1. Question</p>
<fieldset>
<input type="radio" id="PG01S01" name="PG01" value="0">
<label for="PG01S01"> Answer 1</label>
<br>
<input type="radio" id="PG01S02" name="PG01" value="1">
<label for="PG01S02"> Answer 2</label>
</fieldset>
<p>2. Question</p>
<fieldset>
<input type="radio" id="PG02S02" name="PG02" value="0">
<label for="PG02S01"> Answer 1</label>
<br>
<input type="radio" id="PG02S02" name="PG02" value="1">
<label for="PG02S02"> Answer 2</label>
</fieldset>
<p align="center">
<input type="Submit" name="Engage2" id="E2" value="Submit Answers" />

</form>

If you can't stand behind your troops, stand in front of them.
Semper Fidelis

Jim
 
The first thing to understand is how html forms work. An HTML form will submit any and all elements with in it. But will absolutely not submit elements from other forms on the same page at all.
Forms are independent of each other. Having several forms with no submit button, and then one form with a submit button, will only ever submit the form with the submit button.

So basically what you have is several pointless forms, and one form that will only ever submit the value for the submit button.

If you need to submit the radio boxes, either have them all in the same form with a submit button,. or give each of their forms a submit button and point them to correct script.

This however has pretty much nothing to do with PHP, its basic HTML at this point.

----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Web & Tech
 
Thanks a lot for all the Input.
Everything is working fine now !
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top