Jump to content

Recommended Posts

Hello,

 

I'd like to know how could I make a form with infinite elements and send it to mysql.

 

 

Example:

<div class="templatemo-input-icon-container">
     <i class="fa fa-info-circle"></i>
     <input type="text" class="form-control" id="name" name="sname" value="<? echo $dataname; ?>" placeholder="Person name">
</div>

I have this code which I can very easily put to work and send the sname value to a mysql database. My problem now is that I don't know how many persons the user whats to add, for that reason I'd like to add a button called Add Person, and if the user clicks it, it will appear like a new copy of this div. I've seen on the google that I can use HTML DOM createElement() to create this textboxes, but, if I do, how can I get their values if I don't know their name's or id's etc? and also how could I create an Element with classes?

 

 

PS: I'd like to make this without having to reload the page.

 

Thanks,

Joao Lourenco.

Link to comment
https://forums.phpfreaks.com/topic/292279-form-question/
Share on other sites

Assuming that you don't want the page to reload every time the "Add Person" button is clicked, this is more of a JavaScript question. Are you familiar with JavaScript...or something like jQuery?

 

Here is a quick jQuery script which seems to do what you are asking:

http://jsfiddle.net/jaredwilli/tZPg4/4/

 

In case it helps, here is the Google search I used to find the above code:

https://www.google.com/search?q=javascript%20add%20more%20input%20fields

Link to comment
https://forums.phpfreaks.com/topic/292279-form-question/#findComment-1495781
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.