0

Is there a way that I could pass 5 values of a field from a table as an array to javascript function on onchange event of a dropdown box.

The 5 values have to be fetched through sql query.

2
  • 1
    do not have to keep an eye revisit the questions you have asked in the past and select appropriate answers Commented Jul 26, 2011 at 21:12
  • will keep an eye what you have told too. Commented Jul 27, 2011 at 22:33

1 Answer 1

1

yes.. But like an array i dont know.. Give the id to each of your field and in onchange method just pass the value of each id using document.getElementById('id name').value

for giving the id use the div tag and put your fetched data between div tag.. So you can get the data using onchange function using above technique

Sign up to request clarification or add additional context in comments.

3 Comments

ok thanks, but if there are some 100 values then it is not possible to pass all those values on onchange right. This has to be dynamic, I will get the number of values(for now it is 5 but it will increase) and in for loop give that number of hidden fields with that values. But as an array? U understood right. Thanks
ya u r right, for this you dont pass any value to the onchange method.. And call the method simply in javascript and in script you just use the for loop and get the data from div tag.. For all this when you are fetching the data from databse you just make the div tag and id start with div1,div2..... And so on
which method i have to call in javascript u are telling what?

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.