Hi, this is my first post here,
I would like to create x fields with name email age sex and the subscribe question, this is just an example page.

If i would select the number 5,4, or any number then i would like to see 5 fields with names and emails, etc.

What should I do ? It's a php matter ?

Thank you,
Szabi Zs.

<html>
<head>
<title>option</title>

</head>
<body>
<table>
<tr>
		<td>
        
<form action="" method="get">

<p> How many people? </p>
    <select name="select" class="form">
    	<option value="1">1</option>
    	<option value="2">2</option>        
    	<option value="3">3</option>   
        <option value="4">4</option>
        <option value="5">5</option>     
    </select>
    
<br /><br />	   
name:<br /><input type="text" name="name" class="form"/>
<br />
email:<br /><input type="text" name="mail" class="form"/>
<br />
age:<br /><input type="text" name="age" class="form" maxlength="2" />
<br /><br />
<div>
Sex: M<input name="sex" type="radio"  value="male"> F<input name="sex" type="radio" value="female" />
</div>
<br /><br />
<div>
<p class=" p2">Would you like to be informed all the time there is something new? By this we add you in our database: </p>
Yes<input name="inform" type="radio"  value="yes"> No<input name="inform" type="radio" value="no" />
</div>
<br />
<div align="right">
<input type="submit" value="Subscribe »" onClick="return verify();" class="bt">
</div>
    
</form>
        
        
		</td>
</tr>
</table>
</body>
</html>

Recommended Answers

All 3 Replies

This could be a PHP or Javascript question, depending on how your application works.

If you're using PHP, you'd have to have a page which sends the information to the example page you gave above (as POST or GET data), or you could set the form action to be empty or refer to itself; this receiving page would then loop through x number of times to create multiple copies of the HTML form tags.

You can also do this using Javascript if you want to avoid having to reload the page. I found a couple of good resources about doing this here and here.

A final consideration is that you'll want to use HTML arrays for these form fields, since there will be multiple copies of form elements with the same name. Here's a good reference in the PHP manual about making HTML arrays and accessing the data using PHP.

An aside, something unrelated to the question

radio buttons,
label tag makes the radio button title/name clickable as well as the checkbox, matches common user interfaces

<div>
<p class=" p2">Would you like to be informed all the time there is something new? By this we add you in our database: </p>
<label for='b1'>Yes </label><input name='inform' id='b1' type='radio'  value='yes' /> 
<label for='b2'> No </label><input name='inform' id='b2' type='radio' value='no' />
</div>

edit:: ->xhtml or html ?
some tags are self closed, some arent, browser quirks mode(s) really make code results difficult to predict

It was a php matter, I found the solution.

*almostbob - Thank you, this is a much better way, thank you :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.