Jump to content
N3lson

Alternar imagem

Recommended Posts

N3lson

Boas, desculpem o incomodo mas já andei as voltas com o que pretendo, e como iniciante de javascript venho pedir esta ajuda


				 <ul id="xx" style="display:block;">					
				 </ul>
				 <script>
						 var liParent = document.getElementById('xx');

						 var opc_mola	 = parseInt(<%= opc_mola %>);
						 var opc_vliso	= parseInt(<%= opc_vliso %>);
						 var opc_faceta   = parseInt(<%= opc_faceta %>);
						 var opc_roscint  = parseInt(<%= opc_roscint %>);
						 var opc_roscext  = parseInt(<%= opc_roscext %>);
				 var principal	= "<%= objimg2 %>";

				 /** Imagens das variantes **/
				  var mola  = "<%= trim(obj2img2) %>".slice(0,6) + "M" + "<%= trim(obj2img2) %>".slice(6);
				  var vliso = "<%= trim(obj2img2) %>".slice(0,6) + "L" + "<%= trim(obj2img2) %>".slice(6);
				  var veioFacetado  = "<%= trim(obj2img2) %>".slice(0,6) + "F" + "<%= trim(obj2img2) %>".slice(6);
				  var roscaInterior = "<%= trim(obj2img2) %>".slice(0,6) + "R" + "<%= trim(obj2img2) %>".slice(6);
				  var roscaExterior = "<%= trim(obj2img2) %>".slice(0,6) + "RE" + "<%= trim(obj2img2) %>".slice(-5);

				   var liChild =" ";

							 if(opc_mola == 1){
							  <% mola = mid(obj2img2, 1 ,6) & "M"& mid(obj2img2, 7 ,5) %>
							   if(principal != mola){
								 liChild +="<li><a href=\"javascript:void(0);\" onclick=\"foto('<%= mola %>','M');\" title=\"Veio com Mola\"><img src=\"/internet/imagens/<%= Trim(objdir )%>/<%= mola %>\" onerror=\"noimg(this);\" id=\"mola\"/></a></li>";
									 if(document.getElementById('mola') !== null){
									   document.getElementById('mola').onclick = function(){alert("mola")};
								   }
							   }
							 }

							 if(opc_vliso == 1){
								   <% veioLiso = mid(obj2img2, 1 ,6) & "L"& mid(obj2img2, 7 ,5) %>
								   if(principal != vliso){
								  liChild +="<li><a href=\"javascript:void(0);\" onclick=\"foto('<%= veioLiso %>','L');\" title=\"Veio Liso\"><img src=\"/internet/imagens/<%= Trim(objdir )%>/<%= veioLiso %>\" onerror=\"noimg(this,true);\" id=\"liso\"/></a></li>";
								   if(document.getElementById('liso') !== null){
									  document.getElementById('liso').onclick = function(){alert("liso")};
								   }
								}
							 }

							 if(opc_faceta == 1){
							 <% veioFacetado = mid(obj2img2, 1 ,6) & "F"& mid(obj2img2, 7 ,5) %>
								if(principal != veioFacetado){
								   liChild +="<li><a href=\"javascript:void(0);\" onclick=\"foto('<%= veioFacetado %>','F');\" title=\"Espiga Facetada\"><img src=\"/internet/imagens/<%= Trim(objdir )%>/<%= veioFacetado %>\" onerror=\"noimg(this,true);\" id=\"faceta\"/></a></li>";
								   if(document.getElementById('faceta') !== null){
								   document.getElementById('faceta').onclick = function(){alert("faceta")};
								   }
								}
							 }

							 if(opc_roscint == 1){
								<% roscaInterior = mid(obj2img2, 1 ,6) & "R"& mid(obj2img2, 7 ,5) %>
								if(principal != roscaInterior){
								  liChild +="<li><a href=\"javascript:void(0);\" onclick=\"foto('<%= roscaInterior %>','R');\" title=\"Rosca Interior\"><img src=\"/internet/imagens/<%= Trim(objdir )%>/<%= roscaInterior %>\" onerror=\"noimg(this,true);\" id=\"roscint\" /></a></li>";
									if(document.getElementById('roscint')!== null){
									 document.getElementById('roscint').onclick = function(){alert("roscint")};
									}
								}
							 }

							 if(opc_roscext == 1){
								<% roscaExterior = mid(obj2img2, 1 ,6) & "RE"& mid(obj2img2, 7 ,5) %>
								if(principal != roscaExterior){
								  liChild +="<li><a href=\"javascript:void(0);\" onclick=\"foto('<%= roscaExterior %>','RE');\" title=\"Rosca Exterior\"><img src=\"/internet/imagens/<%= Trim(objdir )%>/<%= roscaExterior %>\" onerror=\"noimg(this,true);\" id=\"roscext\"/></a></li>";
								   if(document.getElementById('roscext') !== null){
									  document.getElementById('roscext').onclick = function(){alert("roscext")};
								   }
								}
							 }

						   liParent.innerHTML = liChild;

							document.getElementById('debug').innerHTML = document.getElementById('principal').src;

							function passaValor(xx){

							}

				 </script>	  

O que pretendo é quando o user clicar na imagem do ul > li a imagem principal trocar d elugar com a que foi clicada em baixo, o alert é para detectar o click, para teste apenas, pois pretendia passar algo para detectar a troca.

* Linguagem asp misturado

Obrigado

Edited by N3lson

You can't do it, kid. But don't worry, my boy. You're not the only one. No one else can do it.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.