Jump to content

Recommended Posts

Hi my friends,

I'm trying to set a value of one field based on another field, if the analyst set a determinated value to one field, I need to set automatically the value of another.

I've created this function, but it isn't working yet. What I'm doing wrong?

 

 

function zIncident_test(value) {
 var ztype2 = document.main_form.elements["SET.ztype2"];
	if (value == "400338" ) {
		// set the value to field ztype2
		ztype2=='I';
	} else {
		ztype2=='R';
	}
}




#################################################


<PDM_MACRO name=dtlDropdown hdr="Código de resolução" attr=resolution_code evt="onchange='zIncident_test(this.value);'">

Share this post


Link to post
Share on other sites

hi,

try this one:

function zIncident_test(value) {
	// Change ztype2 to your attr name
	switch (value) {
		case "400338":
			jq("[pdmqa=ztype2]").val("I");
			break;
		default:
			jq("[pdmqa=ztype2]").val("R");
	}
}

 

Share this post


Link to post
Share on other sites

Hi @cdtj

I change to this code, but doesn't work.

 

function zIncident_test(value) {
	// Change ztype2 to your attr name
	switch (value) {
		case "400338":
			jq("[pdmqa=ztype2]").val("I");
			break;
		default:
			jq("[pdmqa=ztype2]").val("R");
	}
}


<PDM_MACRO name=dtlDropdown hdr="Código de resolução" attr=resolution_code evt="onchange='zIncident_test(this.value);'">

 

Share this post


Link to post
Share on other sites

try to add this one before switch statements and check console (F12) then:

console.log("value: " + value + ", current ztype2: " + jq("[pdmqa=ztype2]").val());

 

Share this post


Link to post
Share on other sites

I did this change, take a look at the result:

 

<select id="df_3_1" pdmqa="resolution_code" tabindex="100" onfocus="return detailFocus(this);" onblur="return detailBlur(this);" onchange="zIncident_validation(this.value);" title="Código de resolução" name="SET.resolution_code" class="">
<option value="">&lt;vazio&gt;
</option><option value="400052">Atualização
</option><option value="400388">Checagem rotineira
</option><option value="400389">Conceder acesso
</option><option value="400117">Configuração
</option><option value="400391">Criar / Alterar / Excluir E-mail
</option><option value="400390">Criar / Alterar usuário
</option><option value="400323">Criar/Gerar Relatório
</option><option value="400065">Emprestimo de equipamento
</option><option value="400325">Excluir Acesso
</option><option value="400331">Falha de Infra
</option><option value="400330">Falha de sistema
</option><option value="400054">Instalação
</option><option value="400053">Orientação
</option><option value="400051">Remanejamento
</option><option value="400392">Reset de senha
</option><option value="400337">Restauração de arquivos
</option><option value="400057">Substituição de equipamento
</option><option value="400338">Verificar falhas
</option></select>

Share this post


Link to post
Share on other sites

g/.
send @ jquery-1.9.0.min.js:3
:8080/CAisd/pdmweb.exe?SID=1631936641+FID=430611102+OP=UPDATE+FACTORY=cr+SET.id=1335752+SET.tenant=F36DF13B416F2B448384F55AD8EAF841+KEEP.POPUP_NAME=USD1562695973656+KEEP.use_role=1:651 value: 400338, current ztype2: REQUEST
:8080/CAisd/pdmweb.exe?SID=1631936641+FID=1787192312+OP=UPDATE+FACTORY=cr+SET.id=1335752+SET.tenant=F36DF13B416F2B448384F55AD8EAF841+KEEP.POPUP_NAME=USD1562695973656+KEEP.use_role=1:651 value: 400338, current ztype2: REQUEST
:8080/CAisd/pdmweb.exe?SID=1631936641+FID=1787192312+OP=UPDATE+FACTORY=cr+SET.id=1335752+SET.tenant=F36DF13B416F2B448384F55AD8EAF841+KEEP.POPUP_NAME=USD1562695973656+KEEP.use_role=1:651 value: 400057, current ztype2: REQUEST
:8080/CAisd/pdmweb.exe?SID=1631936641+FID=1787192312+OP=UPDATE+FACTORY=cr+SET.id=1335752+SET.tenant=F36DF13B416F2B448384F55AD8EAF841+KEEP.POPUP_NAME=USD1562695973656+KEEP.use_role=1:651 value: 400338, current ztype2: REQUEST
:8080/CAisd/pdmweb.exe?SID=1631936641+FID=1692206314+OP=UPDATE+FACTORY=cr+SET.id=1335752+SET.tenant=F36DF13B416F2B448384F55AD8EAF841+KEEP.POPUP_NAME=USD1562695973656+KEEP.use_role=1:651 value: 400338, current ztype2: REQUEST
:8080/CAisd/pdmweb.exe?SID=1631936641+FID=266538564+OP=UPDATE+FACTORY=cr+SET.id=1335752+SET.tenant=F36DF13B416F2B448384F55AD8EAF841+KEEP.POPUP_NAME=USD1562695973656+KEEP.use_role=1:651 value: 400338, current ztype2: REQUEST
pdmweb.exe?SID=1631936641+FID=819547142+OP=UPDATE+FACTORY=cr+SET.id=1335752+SET.tenant=F36DF13B416F2B448384F55AD8EAF841+KEEP.POPUP_NAME=USD1562695973656+KEEP.use_role=1:651 value: 400338, current ztype2: REQUEST
pdmweb.exe?SID=1631936641+FID=819547142+OP=UPDATE+FACTORY=cr+SET.id=1335752+SET.tenant=F36DF13B416F2B448384F55AD8EAF841+KEEP.POPUP_NAME=USD1562695973656+KEEP.use_role=1:651 value: , current ztype2: REQUEST
pdmweb.exe?SID=1631936641+FID=819547142+OP=UPDATE+FACTORY=cr+SET.id=1335752+SET.tenant=F36DF13B416F2B448384F55AD8EAF841+KEEP.POPUP_NAME=USD1562695973656+KEEP.use_role=1:651 value: 400338, current ztype2: REQUEST

Share this post


Link to post
Share on other sites

This way here works:

 

function zIncident_validation(value) {
console.log("value: " + value + ", current ztype2: " + jq("[pdmqa=ztype2]").val());
	// Change ztype2 to your attr name
	switch (value) {
		case "400338":
			jq("[pdmqa=ztype2]").val("INCIDENT");
			break;
		default:
			jq("[pdmqa=ztype2]").val("REQUEST");
	}
}

 

Thank you so much for your help @cdtj

Share this post


Link to post
Share on other sites

you are welcome!

dont forget to remove console.log from your code because it doesn't work (causes script crash) in IE while console is closed.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...