Jump to content
php.lv forumi

SELECT add remove


Neps

Recommended Posts

ir shaada rinda:

 

<select id=\"+selind+\" name=player\"+i+l+\" onchange='changepl(this.options[this.selectedIndex].value,\"+selind+\");'>\";

 

bet shii rinda nosuuta jaunizmainiito veertiibu no SELECT. Kaa lai nosuut to veertiibu kuru maina???

Link to comment
Share on other sites

Īsti nesapratu jautājumu, bet liekās ka Tu gribi nosūtīt vai ko tur vēl izdarīt arī ar vērtību kas bija selectam pirms nomainīšanas. Ja tā ir, tad, uz ātro domājot, ienāca prātā ka varētu selecta vērtību glabāt arī papildus mainīgajā, mainīgā vērtību inicializē un nomaina arī uz onchange, ja protams tas ir nepieciešams.

Edited by Maris-S
Link to comment
Share on other sites

iisaak sakot peec 4 stundu smadzenju kustinaashanas man sanaaca:

 

 

protams, ka padaliishos ar kodu (kursh nav tehniski LJOTI labi izpildiits bet mani apmierina) (PHP variants)

 

shis ir javascripts prieksh SELECT change

function changepl(x,y){
allParas = document.getElementsByTagName(\"SELECT\");
 num = allParas.length;
 old=[];
   for(i = 0; i < num; i++) {
	if (i == y && x == 'N/A'){
	  lnt=allParas[i].length;
	  for (s=0;s<lnt;s++){
		 old[s]=allParas[i].options[s].value;
	  }

	  for(k = 0; k < num; k++) {
		elSel = document.getElementById(k);
		  for (h=0;h<old.length;h++){
			elOptNew = document.createElement('option');
				 elOptNew.text =old[h];
				 elOptNew.value =old[h];
		   if (old[h]!='N/A'){
			 rt=0;
			 for (tt=0;tt<elSel.length;tt++){
			   if (elSel.options[tt].value==old[h]){
				rt=1;
			   }
			 }
			 if (rt==0){
			   elSel.add(elOptNew, null);

			 }
		   }
		 }
	  }
	}else if (i!=y && x != 'N/A'){
	 for (j=0;j<allParas[i].length;j++){
	  if(allParas[i].options[j].value == x && allParas[i].options[j].value!='N/A' && allParas[i].options[j].value!='Select Player') {
		allParas[i].remove(j);
	  }
	 }
	}
   }
}

 

 

un shis ir javaskripts prieksh tabulu radiishanas: (PHP variants)

 

 

function grupas(){
 texts='';
 grp=document.getElementById('groupas').value;
 pla=document.getElementById('play').value;
 a=parseInt(grp)+1;
 p=parseInt(pla)+1;
 texts+=\"<table border=0 cellspacing=0 cellpadding=0>\";
 texts+=\"			  <tr>\";
 texts+=\"				  <td>\";
 texts+=\"					<table border=0 cellspacing=0 cellpadding=6>\";
 texts+=\"						  <tr>\";


selind=0;
for (i=1;i<a;i++){
texts+=\"				<td>\";
texts+=\"<table border=0 cellspacing=0 cellpadding=0>\";
texts+=\"	   <tr>\";
texts+=\"		   <td colspan=\"+(p+2)+\">\";
texts+=\"		   Group\"+i;
texts+=\"		   </td>\";
texts+=\"	   </tr>\";
texts+=\"			<tr>\";
texts+=\"			<td>\";
texts+=\"<table border=1 cellspacing=0 cellpadding=0>\";
texts+=\"		   <tr>\";
for (t=1;t<(p+1);t++){
	  if (t==1){
	  texts+=\"		  <td>\";
	  texts+=\" \";
	  texts+=\"</td>\";
	  texts+=\"<td>Player</td>\";
	  }else{
	  texts+=\"<td width=20>\"+(t-1)+\"</td>\";
	  }
	}
	texts+=\"</tr>\";
for (l=1;l<p;l++){
  texts+=\"<tr>\";
for (j=0;j<(p+1);j++){
	tabul=\"<td>\";
	tabul+=\" \";
	tabul+=\"</td>\";
	if (j==0){
	tabul=\"<td>\";
	tabul+=l;
	tabul+=\"</td>\";
}
	if ((j-1)==l){
	 tabul=\"<td style='background-color: black;'>\";
	 tabul+=\"   \";
	 tabul+=\"</td>\";
	}
	if (j==1){
	tabul=\"		<td>\";
	tabul+=\"<select id=\"+selind+\" name=player\"+i+l+\"  onchange='changepl(this.options[this.selectedIndex].value,\"+selind+\");'>\";
	tabul+=\"<option value='N/A'>N/A</option>\";
	$opt   
	tabul+=\"</select>\";
	 selind++;
	tabul+=\"</td>\";
	}
	texts+=tabul;
  }
  texts+=\"</tr>\";
}
texts+=\"</table>\";
texts+=\"						</td>\";
texts+=\"						 </tr>\";
texts+=\"					</table>\";
texts+=\"					</td>\";
if (i==4){
  texts+=\"				</tr>\";
  texts+=\"		  <tr>\";

  }

}
texts+=\"						 </tr>\";
texts+=\"						</table>\";
texts+=\"				</td>\";
texts+=\"		  </tr>\";
texts+=\"</table>\";
document.getElementById('cells').innerHTML=texts;
}

 

 

kam tas vajadziigs? - nu teiksim biljardaa grupas sastaadiit.

Edited by Neps
Link to comment
Share on other sites

×
×
  • Create New...