0

I need to load multiple values from my database. I have used java to load these values then i pass them to a textbox in html so that i can load them in my javscript portion of the code.

Since there is no provision for array in html, I have appended 'i' in the following code to achieve my purpose.

input type=text name=lat<%=i%> value="<%=l1%>"

So I get values like lat1, lat2, lat3 and so on.

How do I call them from javascript without having to write for lat1,lat2 etc. seperately

//var a=document.f1.lat1.value;

Basically how can I replace '1' with 'i' in the above line

1
  • 2
    Java and javascript is pretty different, are u sure youre using java? Commented Apr 18, 2013 at 17:06

1 Answer 1

2

JavaScript bracket notation is what you are after

document.f1["lat" + i].value
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.