Jump to content

Help required for adding the correct amount of input fields from drop down box

- - - - -

  • Please log in to reply
1 reply to this topic

#1
anurags1932

anurags1932

    Newbie

  • Members
  • Pip
  • 1 posts
Hey guys so what im trying to achieve here is that the user will enter a page where they can add tracks to an album. The first half of the page is set with 3 text boxes, the album name , year and record company. Now what i want to do is have a drop down box underneath this that will allow the
user the choose the number for tracks they want to add. When they choose for example 5 . Then the page will add 5 input fields with the names
Track 1 , track 2 ect . Im assuming some sort of refresh function should be used or something. Also the one thing i was thinking about is how will the input boxes "name' be stored eg t1? because im going to have to send this info to a second page and insert into a database.Im having difficulty
coming up with the logic to do so.

Any help would be greatly appreciated

Regards


Anu

#2
amrosama

amrosama

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 8,674 posts
What have you done so far?
Maybe we can help you more if you post the code you have till now.

You can add elements to a page using something like
var howManyToAdd=parseInt(document.getElementById("songsNumber").value);
for(var i=0;i<howManyToAdd;i++)
     document.getElementById("songsContainer").innerHTML+="<label>Song No "+(i+1)+"</label><input name='song[]' type='file' />";
Using jQuery you can do:
var howManyToAdd=parseInt(jQuery("#songsNumber").val());
for(var i=0;i<howManyToAdd;i++)
   jQuery("<label>Song No "+(i+1)+"</label><input name='song[]' type='file' />").appendTo("songsContainer");


Using input name that ends with "[]" means that data will be sent in an array, you can also specify a key for that element in the array by adding a key like "file[1]"
yo homie i heard you like one-line codes so i put a one line code that evals a decrypted one line code that prints "i love one line codes"
eval(base64_decode("cHJpbnQgJ2kgbG92ZSBvbmUtbGluZSBjb2Rlcyc7"));
www.amrosama.com | the unholy methods of javascript




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users