Retrieving the Drop Down menu selected items in a java script function.
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Laddu_Babu
Posted On:   Monday, January 27, 2003 04:06 PM

In the function "getAllParametersSelectedFromPage()" I am trying to retrieve the values of the firstMenu and secondMenu from all the forms in the page. I am doing this by getting the selected index first and then accessing the value. The JavaSCript alert prints the index of the selected item right but it does'nt give me the value of the selected item... U can put this page on your localhost and check ... Solution will be highly appreciated :) ... Thanks :) <%@ page language="java" %> function secondMenuGenerate(form, stringArrayOfMenu){ var resultArray = new Array(); secondMenu = new Array; form.secondMenu.length =stringArrayOfMenu.length; secondMenuArray    More>>

In the function "getAllParametersSelectedFromPage()" I am trying to retrieve the values of the firstMenu and secondMenu from all the forms in the page. I am doing this by getting the selected index first and then accessing the value. The JavaSCript alert prints the index of the selected item right but it does'nt give me the value of the selected item...

U can put this page on your localhost and check ...
Solution will be highly appreciated :) ...

Thanks :)




<%@ page language="java" %>




<%! String [] arrayOfMenuItems={"and","is","what","when","how"};
StringBuffer arrayToPass = new StringBuffer();
int lengthSecondMenuArray;

String [] panelListFromDatabase={"panel1","panel2","panel3","panel4","panel5"};
StringBuffer arrayOfPanelsToPass = new StringBuffer();
int originalPrimerPanelLength;
%>

<%
lengthSecondMenuArray = arrayOfMenuItems.length;
for(int res=0;res
arrayToPass = arrayToPass.append("'"+arrayOfMenuItems[res]+"',");
}
String arrayToPassAfterAppending = new String();
arrayToPassAfterAppending = arrayToPass.substring(0,arrayToPass.length()-1);
arrayToPass = arrayToPass.delete(0,arrayToPass.length());



//Panel code
originalPrimerPanelLength = panelListFromDatabase.length;
for(int res=0;res
arrayOfPanelsToPass = arrayOfPanelsToPass.append("'"+panelListFromDatabase[res]+"',");
}
String arrayOfPanelsAfterAppending = new String();
arrayOfPanelsAfterAppending = arrayOfPanelsToPass.substring(0,arrayOfPanelsToPass.length()-1);
arrayOfPanelsToPass = arrayOfPanelsToPass.delete(0,arrayOfPanelsToPass.length());

%>


arrayOfPanelsAfterAppending <%= arrayToPassAfterAppending %>
arrayOfPanelsToPass <%= arrayOfPanelsAfterAppending %>






Reset <%= arrayOfPanelsAfterAppending%>))">







Reset <%= arrayOfPanelsAfterAppending %>))">







Reset <%= arrayOfPanelsAfterAppending %>))">



   <<Less

Re: Retrieving the Drop Down menu selected items in a java script function.

Posted By:   Nitesh_Naveen  
Posted On:   Tuesday, January 28, 2003 03:20 AM

Well... very difficult to read the code from this unformatted code you have posted. Better if you could format your code with pre tags.

You could probably simplyfy you code as

function getAllParametersSelectedFromPage()
{
var primerSetArray = new Array();
var primerPanelArray = new Array();
var n = 0;
for(i<0;i {
if(document.forms[i].elements[i].type=="select-one")
{
var selectItemIndex = document.forms[i].elements[i].selectedIndex;
alert("set value" + document.forms[i].elements[i][selectItemIndex].value); // Will give you the value of the option as in
About | Sitemap | Contact