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
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.
Link to comment
Share on other sites

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?
Link to comment
Share on other sites

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.
Link to comment
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.