Page 1 of 1

Dynamically add new entries to a form with buttons

Posted: Mon Mar 21, 2005 10:56 am
by illes
Hi,

I've searched the forum with different keywords and also googled an hour, but I coudn't find a solution.
Basically I would like to create a form, initially only with one textfield.

Code: Select all

<input type=&quote;text&quote; name=&quote;name1&quote; value=&quote;&quote;>
Is there a possibility to add new entry, a new textfield with an 'Add new' button? There is a max number of text boxes stored in a variable.

Code: Select all

<input type=&quote;text&quote; name=&quote;name1&quote; value=&quote;&quote;><input type=&quote;text&quote; name=&quote;name2&quote; value=&quote;&quote;>
Also I would like to have a 'Delete' button, which changes hides an entry and when the form is processed, it deletes the entry from the database.

Is this possible with client-side programming (Javascript) with layers (show, hide)?

Thanks for your help in advance.

BR,
Illes

Posted: Mon Mar 21, 2005 11:03 am
by feyd
there are no layers or any real trickery involved. You create a new HTMLFormElement and add it to the form you're dealing with.

DevGuru has some details about this.


Moved to Client-side. :roll:

Thanks

Posted: Tue Mar 22, 2005 1:16 pm
by illes
Dear Feyd,

thanks a lot for your reply, unfortunately this information wasn't enough for me "to show the path".

Could you give me a closer hint?

Thanks,
Illes :wink:

Posted: Sat Apr 23, 2005 2:10 am
by psychomachine
hi iles.

did you ever figure this out? i am looking for EXACTLY the same solution, but i'm still such a bozo that i can't do it...

all best,
tench

Posted: Sat Apr 23, 2005 8:28 am
by n00b Saibot
you guyz get yourself a good book/manual on JS/DOM scripting and try to sort it out yourself. this stuff is not so hard as you think :)

Posted: Sun Apr 24, 2005 3:43 am
by psychomachine
n00b Saibot -- do you really think that you advice to get a book/manual is helpful? :roll:

my experience with web forums is that there's usually somebody who is willing to share their knowledge, which is great. sometimes questions don't get any answers, which is also understandable. i would never start bitching if my question didn't get answered. that would be rude.

but i really don't think that "get a book", "we're too busy to deal with beginners" and "gee, you're question is so simple, you must be a lazy bastard" type of answer is necessary. unless you really want to rub it in our faces that you know something which we don't.

all best,
tench

Posted: Sun Apr 24, 2005 10:52 am
by phpScott
with out writing the code for you what you need to do is.

1)add an onClick event to your button to call some javascript.
2) in your javascript you need to do something like

Code: Select all

newInputBox = '<div id =&quote;some_sequential_number&quote;><input type=&quote;text&quote; name=&quote;somename&quote; id=&quote;someId&quote; value=&quote;&quote; />';</div>
tempStore = document.getElementById(id).innerHTML
document.getElementById(id).innerHTML = tempStore + newInputBox;
It will be a little tricky to keep unique id's but there are ways around this too.

This will hopefully get your started on what you need.

the key bit is the innerHTML and the running of the DOM, document object model.

phpScott

Posted: Sun Apr 24, 2005 10:54 am
by psychomachine
thanks a lot scott!

Posted: Mon Apr 25, 2005 3:12 am
by n00b Saibot
psychomachine wrote:n00b Saibot -- do you really think that you advice to get a book/manual is helpful?
Why 8O aren't the books supposed to teach you something :lol: I only suggested that so that you get a good understanding on the subject not rubbing in your face as ou put it :roll:
As Feyd has suggested you before... there are numerous sites out there that are more than willing to help you in all ways to sort your problems/understandings/grounding out. I think that 'getting a book' is an advice.. rest of your enumerations are but a sarcastic remarks and nothing else...
Hope you get my point...

Thanks for your help

Posted: Mon Jul 18, 2005 9:40 am
by illes
Thanks a lot, I will check it.