TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 10-16-2008, 02:15 AM   #1 (permalink)
The Addict
 
webtuto's Avatar
 
Join Date: Dec 2007
Location: morocco
Posts: 221
Thanks: 19
webtuto is on a distinguished road
Confused many input boxes that the user selects

hey
i want to give the visitor the ability to write in a TEXT FIELD the number of TEXT FIELDS he wants to generate
thanks
__________________
Send a message via MSN to webtuto Send a message via Yahoo to webtuto Send a message via Skype™ to webtuto
webtuto is offline  
Reply With Quote
Old 10-16-2008, 11:45 AM   #2 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
Wildhoney is on a distinguished road
Default

You can do either PHP way, which requires the page to reload, or the JavaScript way, which doesn't. I have shown you the PHP method below, as this is the easiest way, and the best way to understand how to do it:

html4strict Code:
<form enctype="multipart/form-data" method="post">

    How many text boxes shall we show?
    <input type="text" name="iTextboxes" value="<?php echo (int) @$_POST['iTextboxes']; ?>" />
    <input type="submit" value="Generate Textboxes" />
   
</form>

php Code:
<?php if (isset($_POST['iTextboxes'])): ?>

    <?php for ($iIndex = 0; $iIndex < (int) $_POST['iTextboxes']; $iIndex++): ?>
        <input type="text" name="szTextbox[]" /><br />
    <?php endfor; ?>

<?php endif; ?>
Attached Files
File Type: php Textboxes.php (462 Bytes, 161 views)
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
Old 10-17-2008, 05:35 PM   #3 (permalink)
The Addict
 
webtuto's Avatar
 
Join Date: Dec 2007
Location: morocco
Posts: 221
Thanks: 19
webtuto is on a distinguished road
Default

thanks :d
.....
__________________
Send a message via MSN to webtuto Send a message via Yahoo to webtuto Send a message via Skype™ to webtuto
webtuto is offline  
Reply With Quote
Old 10-17-2008, 11:06 PM   #4 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
Wildhoney is on a distinguished road
Default

Sorry, I didn't see that this thread was specifically in the JavaScript forum. I have amended the script and added JavaScript capabilities. However, it's always good practice to have both methods in for if the user has JavaScript disabled, or perhaps unsupported by an ancient browser.

Take a look at the code and see what you think. Although, if you're new to this way of doing things, I would stick to the PHP approach as organising JavaScript files is a whole new arena. I was that silly once, and whilst I don't regret it because I learnt well from it, it's not something I'd recommend people repeat. There are better ways to learn, and that is through organising only HTML, CSS and PHP files, at the moment, then slowly progressing to other types of files such as JavaScript. The gradual approach, I feel, is far better.
Attached Files
File Type: php Fields.php (1.6 KB, 174 views)
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 10:17 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design