Ver Mensaje Individual
  #1 (permalink)  
Antiguo 08/08/2008, 08:59
dmlopez
 
Fecha de Ingreso: agosto-2008
Mensajes: 5
Antigüedad: 15 años, 9 meses
Puntos: 0
Pregunta Ordenar Lista(Select) y Mantener el orden despues de Submit!

Hola a todos,

A ver si alguna mente brillante puede ayudarme con esto.... Tengo 2 dias pensando como hacerlo y no me sale

El sgt codigo lo baje de una pagina, lo que hace es ordenar con bootnes arriba y abajo, los elementos de una lista:

************************************************** ************************************************** *****<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<title>Untitled</title>
<script src="orden.js" type="text/javascript"></script>
<script language="JavaScript">

var elementos = new Array();

elementos[0]="Hola";
elementos[1]="L�ea";
elementos[2]="Cuadrado";
elementos[3]="Tri�gulo";
elementos[4]="El Sol";
elementos[5]="La Luna";


function imprime_listado_basico(){
texto="";
for (i=0;i<elementos.length;i++){
texto += elementos[i];
if (i!=0){
texto += " <a href='#' onclick='arriba(" + i + ")'>arriba</a>";
}
if (i!=elementos.length-1){
texto += " <a href='#' onclick='abajo(" + i + ")'>abajo</a>";
}
texto += "<br>";
}
xInnerHtml('listado_elementos',texto);
}

function imprime_listado(){
texto="<table>";
for (i=0;i<elementos.length;i++){
texto += "<tr bgcolor='#eeeeee'>";
texto += "<td>" + elementos[i] + "</td>";
if (i!=0){
texto += "<td><a href='#' onclick='arriba(" + i + ")'><img src='arriba.gif' width=9 height=9 border=0></a></td>";
}else{
texto += "<td></td>";
}
if (i!=elementos.length-1){
texto += "<td><a href='#' onclick='abajo(" + i + ")'><img src='abajo.gif' width=9 height=9 border=0></a></td>";
}else{
texto += "<td></td>";
}
texto += "</tr>";
}
texto += "</table>";
xInnerHtml('listado_elementos',texto);
}

function arriba(i){
temporal = elementos[i];
elementos[i]=elementos[i-1];
elementos[i-1]=temporal;
imprime_listado()
}

function abajo(i){
temporal = elementos[i];
elementos[i]=elementos[i+1];
elementos[i+1]=temporal;
imprime_listado()
}

</script>

</head>

<body onload="imprime_listado()">

<div id="listado_elementos">

</div>
</body>
</html>

************************************************** ************************************************** *****

Ok, el Js es :
************************************************** *********************
/* orden.js compiled from X 4.0 with XC 0.28b. Distributed under GNU LGPL. For copyrights, license, documentation and more visit Cross-Browser.com */
var xOp7Up,xOp6Dn,xIE4Up,xIE4,xIE5,xNN4,xUA=navigator. userAgent.toLowerCase();
if(window.opera){
var i=xUA.indexOf('opera');
if(i!=-1){
var v=parseInt(xUA.charAt(i+6));
xOp7Up=v>=7;
xOp6Dn=v<7;
}
}else if(navigator.vendor!='KDE' && document.all && xUA.indexOf('msie')!=-1){
xIE4Up=parseFloat(navigator.appVersion)>=4;
xIE4=xUA.indexOf('msie 4')!=-1;
xIE5=xUA.indexOf('msie 5')!=-1;
}else if(document.layers){
xNN4=true;
}
xMac=xUA.indexOf('mac')!=-1;

function xGetElementById(e){
if(typeof(e)!='string') return e;
if(document.getElementById) e=document.getElementById(e);
else if(document.all) e=document.all[e];
else e=null;return e;
}

function xInnerHtml(e,h){
if(!(e=xGetElementById(e)) || !xStr(e.innerHTML)) return null;
var s = e.innerHTML;
if (xStr(h)) {
e.innerHTML = h;
}
return s;
}

function xStr(s){
for(var i=0; i<arguments.length; ++i){
if(typeof(arguments[i])!='string')
return false;
}
return true;
}
************************************************** *********************

Ok, las imagenes q ven ashi son 2 imagenes de flechitas cualquiera ... Ok ahora el PROBLEMA, es que me ordena todo de maravilla, pero este codigo necesito usarlo en un sitio que tengo, el cual tiene un submit... cuando se hace submit a la pagina todo se daña :( es decir el orden NO se conserva y vuelve a quedarse tal como estaba al inicio por default :(

Alguien puede decirme como mantener el orden que he realizado(con lso botoncitos arriba y abajo) a pesar de que haga un submit en la pagina ?????????

Por favor help me