Jump to content

How can I make this Script to work

- - - - -

  • Please log in to reply
No replies to this topic

#1
Sality63

Sality63

    Newbie

  • Members
  • Pip
  • 1 posts
I have 3 HTML form inputs fields that is dynamically generated by a "add more" button, with naming for the fields name as fieldName, fieldName1, fieldName2, fieldName3... and so on.

Now, I'm trying to retrieve the value from this fields with javascript, using the script below.
var bookingForm = document.forms['formName'];
var qty = bookingForm.fieldName +'i'.value;

with the 'i' been a generated numeric number by a for loop
when I use alert(qty), it returns NaN, when I'm expecting the value for fieldName1, fieldName2.. and so on.

But when I use;
var qty = bookingForm.fieldName.value
I can get the value in that field but get NaN when I try to concantenate 1,2,3... with the fieldName.

I need help to resolve this problem. I'm very new to javscript ( I have not learnt it yet), but need to get this done so badly.

Your help will be very much appreciated.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users