Link to home
Create AccountLog in
Avatar of Eduardo Fuerte
Eduardo FuerteFlag for Brazil

asked on

Could you point what must be changed to make the 02 textboxes readable/ editable depending on the condition?

Hi Experts

Could you point what must be changed to make the 02 textboxes readable/ editable depending on the condition?

Accordingly to:

	<?php
	if ($id_identidade=9535) // Santa Casa Teste
	{
	?>						

			<!--  It must to readable/ editable -->

			<td id="div_data_missao_ida_1" style="visibility: <?=(isset($guia['missao'][0]['nMissaoPreMarcada']) && $guia['missao'][0]['nMissaoPreMarcada']==1 ?"visible":"visible")?>;">
			<label class="form_title">Data da Miss&atilde;o:</label><br/>
			<input type="text"  class="input" name="dpremarcada_ida" id="dpremarcada_ida" value="<?=(isset($guia['missao'][0]['dMissao'])?formataStamp($guia['missao'][0]['dMissao'],"stamp","dma"):date("d/m/Y"))?>" size="11" maxlength="10"  onchange="copiaDataMissaoTIT();">
			<img src="imagens/calendario.png" name="cal_trigger" id="cal_trigger" border="0" align="absmiddle" onmouseover="javascript: calendar_param('dpremarcada_ida', 'cal_trigger', isAnterior);" style="cursor: pointer;" >
			</td>


			<td id="div_data_missao_ida_2" style="visibility: <?=(isset($guia['missao'][0]['nMissaoPreMarcada']) && $guia['missao'][0]['nMissaoPreMarcada']==1 ?"visible":"visible")?>;">
			<label class="form_title">Hor&aacute;rio:</label><br/>
			<input type="text"  onkeypress="campo_hora(event); return validaDigNum(event);" value="<?=(isset($guia['missao'][0]['dMissao'])?formataStamp($guia['missao'][0]['dMissao'],"stamp","hm"):date("H:i"))?>" size="5" maxlength="5" name="horario_premarcada_ida" id="horario_premarcada_ida" class="input" >            
			</td>

	<?php
	}	
	else
	{		
	?>		

			<!--  It must to be readable/ not editable -->
			<td id="div_data_missao_ida_1" style="visibility: <?=(isset($guia['missao'][0]['nMissaoPreMarcada']) && $guia['missao'][0]['nMissaoPreMarcada']==1 ?"visible":"visible")?>;">
			<label class="form_title">Data da Miss&atilde;o:</label><br/>
			<input type="text"  class="input" name="dpremarcada_ida" id="dpremarcada_ida" value="<?=(isset($guia['missao'][0]['dMissao'])?formataStamp($guia['missao'][0]['dMissao'],"stamp","dma"):date("d/m/Y"))?>" size="11" maxlength="10" readonly onchange="copiaDataMissaoTIT();">
			<img src="imagens/calendario.png" name="cal_trigger" id="cal_trigger" border="0" align="absmiddle" onmouseover="javascript: calendar_param('dpremarcada_ida', 'cal_trigger', isAnterior);" style="cursor: pointer;" >
			</td>


			<td id="div_data_missao_ida_2" style="visibility: <?=(isset($guia['missao'][0]['nMissaoPreMarcada']) && $guia['missao'][0]['nMissaoPreMarcada']==1 ?"visible":"visible")?>;">
			<label class="form_title">Hor&aacute;rio:</label><br/>
			<input type="text"  onkeypress="campo_hora(event); return validaDigNum(event);" value="<?=(isset($guia['missao'][0]['dMissao'])?formataStamp($guia['missao'][0]['dMissao'],"stamp","hm"):date("H:i"))?>" size="5" maxlength="5" name="horario_premarcada_ida" id="horario_premarcada_ida" class="input" >            
			</td>

	<?php
	}
	?>

Open in new window


Thanks in advance!
ASKER CERTIFIED SOLUTION
Avatar of Chris Stanyon
Chris Stanyon
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of Eduardo Fuerte

ASKER

@Chris

Could you give a look at:

Another question

Your reply must to solve the initial problem but first I have to correctly obtain $id_identidade
You could just write the first block of code and, where it should appear the "readonly" part (if it's read only), you could just use a ternary operator. In your case:

<td id="div_data_missao_ida_1" style="visibility: <?=(isset($guia['missao'][0]['nMissaoPreMarcada']) && $guia['missao'][0]['nMissaoPreMarcada']==1 ?"visible":"visible")?>;">
<label class="form_title">Data da Miss&atilde;o:</label><br/>
<input type="text"  class="input" name="dpremarcada_ida" id="dpremarcada_ida" value="<?=(isset($guia['missao'][0]['dMissao'])?formataStamp($guia['missao'][0]['dMissao'],"stamp","dma"):date("d/m/Y"))?>" size="11" maxlength="10" <?= echo ($id_identidade != 9535 ? "readonly " : ""); ?>onchange="copiaDataMissaoTIT();">
<img src="imagens/calendario.png" name="cal_trigger" id="cal_trigger" border="0" align="absmiddle" onmouseover="javascript: calendar_param('dpremarcada_ida', 'cal_trigger', isAnterior);" style="cursor: pointer;" >
</td>

<td id="div_data_missao_ida_2" style="visibility: <?=(isset($guia['missao'][0]['nMissaoPreMarcada']) && $guia['missao'][0]['nMissaoPreMarcada']==1 ?"visible":"visible")?>;">
<label class="form_title">Hor&aacute;rio:</label><br/>
<input type="text"  onkeypress="campo_hora(event); return validaDigNum(event);" value="<?=(isset($guia['missao'][0]['dMissao'])?formataStamp($guia['missao'][0]['dMissao'],"stamp","hm"):date("H:i"))?>" size="5" maxlength="5" name="horario_premarcada_ida" id="horario_premarcada_ida" class="input" >            
</td>

Open in new window


And remember that when comparing (in this case, if the variable is not equal 9535) you need to use two equal signs, or the NOT EQUAL sign like I used (or any other comparator).

Ternary works like this: (IF SOMETHING IS TRUE ? THIS : IF NOT THIS) and because you used ECHO before it, it will echo "readonly" or nothing at all.
@Cesar

Pretty sure that's exactly what I've already posted.

In your example, you are using <?= echo

In PHP, the <?= is the shortcut for echo, so you don't need to repeat it. Have a look ay my code for the correct way to do it.
@Chris

Oh, you are right. Sorry about that. Didn't read it.
@Chris

Thank you for help.