gorty 0 Newbie Poster

hi,


prepared two list boxes which both interchange data thru forward arrrow and backwardarrow images.
data is getting from database storing in avariable,have to assign var to array .
this is my code pls help thanks in advance.

<script language=javascript>
/* ************************* */
//	 Copy the code inside head portion of your HTML code
//   Created on : Nov 12,2007
//   List movement script
//   Moves the items between two HTML Select elements
//   it looks like a movement between two lists.
//
/* ************************* */
var from_array = new Array();  // this array has the values for the source list
var to_array = new Array('Red',3,5); 		  // this array has the values for the destination list(if any)
</script>
	<script language=javascript>
function moveoutid()
{
	var sda = document.getElementById('xxx');;
	var len = sda.length;
	var sda1 = document.getElementById('yyy');
	for(var j=0; j<len; j++)
	{
		if(sda[j].selected)
		{
			var tmp = sda.options[j].text;
			var tmp1 = sda.options[j].value;
			sda.remove(j);
			j--;
			var y=document.createElement('option');
			y.text=tmp;
			try
			{sda1.add(y,null);
			}
			catch(ex)
			{
			sda1.add(y);
			}
		}
	}
}


function moveinid()
{
	var sda = document.getElementById('xxx');
	var sda1 = document.getElementById('yyy');
	var len = sda1.length;
	for(var j=0; j<len; j++)
	{
		if(sda1[j].selected)
		{
			var tmp = sda1.options[j].text;
			var tmp1 = sda1.options[j].value;
			sda1.remove(j);
			j--;
			var y=document.createElement('option');
			y.text=tmp;
			try
			{
			sda.add(y,null);}
			catch(ex){
			sda.add(y);
			}

		}
	}
}



</script>
</head>

  <%@ page import="java.sql.*" %>
<%! Connection con;
        Statement st;
        ResultSet rs;
        String name;
        String clientname;
        String month;
        int day;
        int year;
        String date;

        String dur;
        String prodes;
		String mode,id;
 %>


 <%


   try
   {
       System.out.println("inside try  ");
     Class.forName("com.mysql.jdbc.Driver");
		con=DriverManager.getConnection("jdbc:mysql://localhost/register", "root",

                            "bio");
     st=con.createStatement();

			  System.out.println("after rs");

		  rs=st.executeQuery("select Empname from  members" );

     System.out.println("after selecting  ");



      %>



	  <div id="Layer1" style="position:absolute; width:154px; height:49px; z-index:2; left:370px; top: 400px;">
  <TABLE width="100%" BORDER="4" bordercolor=
  "lightblue">

	    <%

       while(rs.next())
       {


    var from_array=rs.getString(1);
	 System.out.println("***********"+from_array);

	   }

	 


	   %>


		<table border=1 align=center valign=center>
<tr>From Group<td></td><td>To Group</td></tr>
<tr><td>
<select id=xxx multiple size=7 style="width:100;">
<script language=javascript>
for(var i=0;i<from_array.length;i++)
{


	document.write('<option>'+from_array[i]+'</option>');
}

</script>
	 <%
	   System.out.println("SDFFFFFFFF");%>



</select>
</td>
<td>
<input type=button value=">>" onclick=moveoutid()>
<input type=button value="<<" onclick=moveinid()>
</td>
<td>
<select id=yyy multiple size=7 style="width:100;">
<script language=javascript>
for(var j=0;j<to_array.length;j++)
{
	document.write('<option>'+to_array[j]+'</option>');
}
</script>
</select>
</td></tr>
</table>











		 <%

		    }
    catch(Exception e)
    {
      System.out.println("error "+e);

    }
  %>

</TABLE>
	</div>
	   <p>&nbsp;</p>

						 		 </form>
  </body>
  </html>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.