Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

Coding Forum


You are currently viewing our Coding Forum as a guest. Please register to participate.
Login



Reply
html forms and javascript.
Old 08-03-2004, 09:24 AM html forms and javascript.
Novice Talker

Posts: 11
Trades: 0
I am trying to write a piece of code whereby a user inputs a number into a form. then, upon submission, the page will be refreshed to now contain the input number of new fields to be filled in.
eg - Please enter a number : 3
submit - page refreshed

Please enter a number : 3

- Please enter a new number : blank
- Please enter a new number : blank
- Please enter a new number : blank

any simple ideas ?
hodgy is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 08-03-2004, 11:02 AM
Kyrnt's Avatar
The Post-Mod Years

Posts: 2,536
Location: Western Maryland
Trades: 0
hodgy,

This might not necessarily be JavaScript, but perhaps PHP. On the first page, a form would exist allowing the user to select a number, 3 for example. Hit Submit which is directed either back to itself or another PHP file.

That PHP file would read the parameter from the form then use a FOR loop to create the specified number of inputs required.
__________________
—Kyrnt
Kyrnt is offline
Reply With Quote
View Public Profile Visit Kyrnt's homepage!
 
Old 08-03-2004, 11:22 AM
Novice Talker

Posts: 11
Trades: 0
yeah, i am starting to think along those lines as well, is it then possible to assign a php variable to the value of each new field created. i mean i would be creating fields in a loop so how can i give each field a different variable name ? is that possible ?
hodgy is offline
Reply With Quote
View Public Profile
 
Old 08-03-2004, 02:58 PM
Kyrnt's Avatar
The Post-Mod Years

Posts: 2,536
Location: Western Maryland
Trades: 0
Sure. Here is an example creating text inputs but you can substitute for anything you want. I'm assuming that the number of controls to create (designated by the user from the previous screen) is called "userSelect."


PHP Code:

$num = $_POST[userSelect];

for( $i = 0;($i < $num); $i++ )
{
?>
    <input type="text" name="myinput<?= $i ?>" />

<?php

}
__________________
—Kyrnt
Kyrnt is offline
Reply With Quote
View Public Profile Visit Kyrnt's homepage!
 
Old 08-05-2004, 11:55 AM
Novice Talker

Posts: 11
Trades: 0
great ! thanks
hodgy is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to html forms and javascript.
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

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





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.42551 seconds with 12 queries