Current location: Hot Scripts Forums » General Web Coding » JavaScript » Enter number and copy form (X)


Enter number and copy form (X)

Reply
  #1 (permalink)  
Old 03-30-06, 03:38 PM
sharijl's Avatar
sharijl sharijl is offline
Newbie Coder
 
Join Date: Nov 2005
Location: North Carolina
Posts: 86
Thanks: 1
Thanked 1 Time in 1 Post
Question Add another (additional field/group) for form

I am looking for a javascript that for a form I am creating. The form should have a box that requires the person to enter in a number between 1-50. Once done, the forum will duplicate that number of field boxes. For example field box is for the fname, lname, and number. I have three people so I enter the number 3 - press enter. Then three groups will appear prompting me to enter the name and number for each person. Then they can submit the info.

If that is not an option then maybe some type of (add) button to add another group of fields. Something like this. I have been checking around and have yet to find anything quite like this but I know it should be possible with java. Any ideas or links/data that I should review?

Last edited by sharijl; 03-30-06 at 03:47 PM. Reason: change title
Reply With Quote
  #2 (permalink)  
Old 03-30-06, 07:05 PM
TwoD TwoD is offline
Community VIP
 
Join Date: Sep 2003
Location: 404
Posts: 1,813
Thanks: 0
Thanked 0 Times in 0 Posts
I've seen a script like this around here somewhere.
Have you tried searching for "adding field" or "insert field" etc?

Btw, Java isn't JavaScript, there's a big difference.
__________________
[W3Schools - learn all about the standards.] [QuirksMode - Browser Quirks] [MS's Online Reference Docs] [DOM in Gecko.]
Please pay attention to stickys, announcements and forum rules, thank you.
Please also remember Code Wrappers and [SOLVED] Marking, this helps everyone.
Reply With Quote
  #3 (permalink)  
Old 03-30-06, 07:20 PM
sharijl's Avatar
sharijl sharijl is offline
Newbie Coder
 
Join Date: Nov 2005
Location: North Carolina
Posts: 86
Thanks: 1
Thanked 1 Time in 1 Post
ok

Thanks. I did try but I will look a little harder.
Reply With Quote
  #4 (permalink)  
Old 03-30-06, 08:17 PM
sharijl's Avatar
sharijl sharijl is offline
Newbie Coder
 
Join Date: Nov 2005
Location: North Carolina
Posts: 86
Thanks: 1
Thanked 1 Time in 1 Post
No luck -- any advice

Still can not find the java script to do this. I know your probably right about seeing it but I could not find anything. Any Suggestions.
Reply With Quote
  #5 (permalink)  
Old 03-31-06, 04:56 AM
TwoD TwoD is offline
Community VIP
 
Join Date: Sep 2003
Location: 404
Posts: 1,813
Thanks: 0
Thanked 0 Times in 0 Posts
The code at
http://www.programmingtalk.com/showthread.php?t=17660
gives you an example of how to do this.
You could make the script look for the value in a textfield and use that as the limit in the loop creating the new fields. Just make sure you use parseInt() on the value to get it in numbers. Then use isNan() after parse int to find out if it could be converted to a number, this is to avoid getting an error if the user enters text instead.
__________________
[W3Schools - learn all about the standards.] [QuirksMode - Browser Quirks] [MS's Online Reference Docs] [DOM in Gecko.]
Please pay attention to stickys, announcements and forum rules, thank you.
Please also remember Code Wrappers and [SOLVED] Marking, this helps everyone.
Reply With Quote
  #6 (permalink)  
Old 03-31-06, 07:10 AM
sharijl's Avatar
sharijl sharijl is offline
Newbie Coder
 
Join Date: Nov 2005
Location: North Carolina
Posts: 86
Thanks: 1
Thanked 1 Time in 1 Post
add button

Thanks for the link. I did see that but that is really not at all what I am looking for. I know this is probably confusing and I do appriciate the help. I will keep looking.
Reply With Quote
  #7 (permalink)  
Old 03-31-06, 08:40 AM
sharijl's Avatar
sharijl sharijl is offline
Newbie Coder
 
Join Date: Nov 2005
Location: North Carolina
Posts: 86
Thanks: 1
Thanked 1 Time in 1 Post
Lightbulb A little more info

Here is the form as it is now. http://home.triad.rr.com/sharijl/test4.htm

What I am looking for specifically is a function that will duplicate the "Number" and "Type of Change" depending on the number that is selected from the drop down box. By default the number is one and those two fields specified are only shown once, but that should change depending on the number selected.

The Enduser name and FAN fields are going to be hidden and a condition only to show if end user name is chosen from the type drop down. I will work on that later.

Thanks for any help you can provide.
Reply With Quote
  #8 (permalink)  
Old 03-31-06, 07:25 PM
TwoD TwoD is offline
Community VIP
 
Join Date: Sep 2003
Location: 404
Posts: 1,813
Thanks: 0
Thanked 0 Times in 0 Posts
Actually, the basic idea is the same. You print out the "Number" and "Type of Change" fields with JavaScript x number of times using a loop. All this is wrapped up in a function and executed when the user changes the number of field "sets" to display.
If you want to have an End User and FAN field for each set, and have them displayed if the corresponding option is selected, that's possible too by creating a show/hide function. That function would take an argument specifying in which set to display/hide the End User and FAN fields, as well as an argument specifying if it should be hidden or visible (the value of the dropdown box Type of Change in that set.)

Btw, you should try having a <style> tag in the header with all the styles defined, and only set the class attribute for each element on the page. It would make the source much less cluttered up and easier to generate using a script.
__________________
[W3Schools - learn all about the standards.] [QuirksMode - Browser Quirks] [MS's Online Reference Docs] [DOM in Gecko.]
Please pay attention to stickys, announcements and forum rules, thank you.
Please also remember Code Wrappers and [SOLVED] Marking, this helps everyone.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
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

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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
CGI problem - Script only allows a small number of digits in my customers site url??? Ireland Perl 6 10-09-05 07:09 PM
How to copy value to before zeroing it out ajs PHP 4 01-11-05 06:00 PM
CHMOD to 777 hbfriends PHP 10 10-27-04 09:43 PM


All times are GMT -5. The time now is 11:08 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.