Jump to content

Adding items dynamically in a Form


senojeel

Recommended Posts

I am not sure what to search for so my searches for solutions haven't been helping me much.

I have a form that a user submits that is for mechanical rights to music for their recording.  Right now the form submits one song per form. So if they want the rights to 5 songs, they have to submit the form 5 times.  What I want is to have them be able to click a button that adds a line to add another song. So if they have 5 songs, they hit the add title button 4 times. 

So if anyone could point me in the right direction I waould appreciate it.

Thanks!
Shawn
Link to comment
https://forums.phpfreaks.com/topic/26460-adding-items-dynamically-in-a-form/
Share on other sites

So you want the form to physically change before the person presses the submit button? Sounds like a job for javascript which will save you having to keep going back to the server for each song. I don't totally understand what you're trying to do in terms what you are referring to as 'adds a line to add another song' but you might want to look into javascript's onChange function.
Yes, that is essentially what I want.  Basically right now the form is set up for a user to enter their information and then a single song title they want the rights to.  I want to include the ability for them to add more lines, more songs.

I was thinking javascript would be what I need to use.  Do you know of any examples?
This has nothing to do with PHP tho...

[code]
** in head section, between script tags
function dispMoreFiles() {
var upbox = "<input type='file' name='userfile'><br>";
var updiv = document.getElementById("morefiles");
var addhtml = updiv.innerHTML+upbox;
updiv.innerHTML = addhtml;
}
** Stop **

** The form, in body **
<form enctype="multipart/form-data" method="POST" action="upload.php">
<input type="file" name="userfile"><br>
<div id="morefiles"></div>
<br>
<input type="button" name="operation" id="operation" value="Add more files" onClick="javascript:dispMoreFiles();">
</form>
**Stop **
[/code]

Orio.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.