/    Sign up×
Community /Pin to ProfileBookmark

I have a form which has a text box. The user needs to enter a number in the text box, say the user enters the number n , then I further dynamically generate n number of textboxes. The form actions to result.php page where I need the values of these n textboxes. But as I don’t know how many inputs are there how can I predefine the variables that I need to get. I tried doing something like $_GET[‘var’+1]; (the name of the n textboxes being var1,var2,var3… varn) but it doesnot work.

I tried creatind the elements in an array but it doesnot work. The code I used was

var input = new Array();
for(var i=0; i<n; i++)
{
input[i] = document.createElement(‘input’);
input[i].id = ‘input1_’+ i;
input[i].setAttribute(‘name’,’input’+i);
input[i].style.position = ‘absolute’;
input[i].style.top = 50*i+300+’px’;
document.getElementById(‘Form’).appendChild(input[i]);

}

Could you please suggest any better way to get the values ?

Thanks in advance

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@callumdOct 31.2007 — That looks like javascript, this is the PHP forum.
×

Success!

Help @ruchi_bhindwale spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.15,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...