Frequently Asked Questions: page: 17
Page 17 of 21 · <1 ... 16 17 18 ... 21 >
-
1
How can a have one of those check lists where the person can select one answer only (radio buttons)?
Radio buttons allow the user to choose only one of a number of options. When you choose one option, any previously selected option is unselected. Radio buttons are grouped together by assigning them all the same NAME (but different VALUES).
<p>Which one of these old TV Shows do you miss the most? <br /><input type="radio" name="oldtv" value="madaboutyou" />Mad About You <br /><input type="radio" name="oldtv" value="fullhouse" />Full House <br /><input type="radio" name="oldtv" value="stepbystep" />Step by Step <br /><input type="radio" name="oldtv" value="partyof5" />Party of Five <br /><input type="radio" name="oldtv" value="dawsonscreek" />Dawson's Creek <br /><input type="radio" name="oldtv" value="buffy" />Buffy, the Vampire Slayer</p>
Like checkboxes, you can define a radio button to be checked by default, but unlike checkboxes you should only have one radio button in a group initially checked.
<p>Which one of these old TV Shows do you miss the most? <br /><input type="radio" name="oldtv" value="madaboutyou" checked="checked" />Mad About You <br /><input type="radio" name="oldtv" value="fullhouse" />Full House <br /><input type="radio" name="oldtv" value="stepbystep" />Step by Step <br /><input type="radio" name="oldtv" value="partyof5" />Party of Five <br /><input type="radio" name="oldtv" value="dawsonscreek" />Dawson's Creek <br /><input type="radio" name="oldtv" value="buffy" />Buffy, the Vampire Slayer</p>
Now you have Mad About You checked and set as default.
Remember: all the radio buttons in a group must have identical names (like in the example above - the name is set to "oldtv" for each option).
May 21, 2004 |
By Louise |
Filed under FAQ, NL-PHPMail, PHP, Scripts
-
2
How can I make a question with checkboxes to choose the answers?
Checkboxes are used to allow the user to select more than one item from a list. Here’s an example:
<p>Which of the following TV shows do you watch? (choose any combination) <br /><input type="checkbox" name="friends" value="Y" />Friends <br /><input type="checkbox" name="er" value="Y" />ER <br /><input type="checkbox" name="willandgrace" value="Y" />Will&Grace <br /><input type="checkbox" name="gilmoregirls" value="Y" />Gilmore Girls <br /><input type="checkbox" name="that70sshow" value="Y" />That 70's Show</p>
Now, the inital value of a checkbox can be defined to be checked or not. If you want any box to be already checked by default, you have to add ‘checked=”checked”‘ in their form definition, like so:
<p>Which of the following TV shows do you watch? (choose any combination) <br /><input type="checkbox" name="friends" value="Y" checked="checked" />Friends <br /><input type="checkbox" name="er" value="Y" />ER <br /><input type="checkbox" name="willandgrace" value="Y" />Will&Grace <br /><input type="checkbox" name="gilmoregirls" value="Y" checked="checked" />Gilmore Girls <br /><input type="checkbox" name="that70sshow" value="Y" />That 70's Show</p>
Now you have both Friends and Gilmore Girls checked as default.
May 21, 2004 |
By Louise |
Filed under FAQ, NL-PHPMail, Scripts
-
3
How can I make a textarea field on my form?
Use a code like this:
<textarea name="comments" rows="5" cols="40"></textarea>
All you have to do is change the name (in this case comments) so you know what this answer is about! You can, of course, change the rows number to reflect the height of your box, and the cols number to reflect the width of the box.
Please note: These tags don’t limit the length of a line someone can enter, or how many lines of text they can enter. They simply describe the appearance of the form.
If you want to supply some default text for the text area, you should place it before the </textarea> tag, like so:
<textarea name="comments" rows="5" cols="40">Text</textarea>
May 21, 2004 |
By Louise |
Filed under FAQ, NL-PHPMail, PHP, Scripts
-
4
How can I use a dropdown menu?
Here’s an example:
<p>What's your favorite color?<br /> <select name="color"> <option selected="selected">Please choose...</option> <option value="blue">blue</option> <option value="red">red</option> <option value="yellow">yellow</option> <option value="orange">orange</option> <option value="green">green</option> <option value="purple">purple</option> <option value="black">black</option> <option value="white">white</option> </select></p>
The name in the select tag is the name of the field, the value is what will get sent to you in the e-mail, the text in between the two option tags is what your visitors will see.
To make a certain option selected by default, add ’selected="selected"’ to the input tag, as shown above.
May 21, 2004 |
By Louise |
Filed under FAQ, NL-PHPMail, Scripts
-
5
Help! I’m trying to include a file with the following code: “include(”http://mydomain.com/file.php”);” but gives me an error. What’s wrong?
Instead of putting the full URL, put either a relative URL:
include "file.php";
or the absolute path:
include "/home/whatever/public_html/file.php";
The newest version of PHP doesn’t allow full URLs in includes. So stick to relative paths and absolute (server) paths and you should be ok.
One little tip: if you absolutely need to include a URL from a diferent server, put an @ in front of the include. That will hide the error message from the browser, however it doesn’t guarantee that your includes will work!