2017-05-01 1 views
0

여기에는 양식에서 수많은 입력란이 있으며 완벽하게 작동합니다. 그리고 지금, 나는이 페이지에 이미 존재하는 property_type에 따라 새로운 입력 상자 및 해당 레이블을 추가하려고합니다.if else 조건에서 동적으로 필드를 추가/변경하는 방법은 무엇입니까?

이제 친절하게 저 양식에 어떻게 새 필드를 추가 할 수 있습니까? 여기

여기 내 양식 코드

 <div class="dashboard_price_left"> 

    <h3> 
     <?php 
     if ($this->lang->line('BasePrice') != '') { 
      echo stripslashes($this->lang->line('BasePrice')); 
     } else 
      echo "Base Price"; 

     ?> 
    </h3> 

    <p> 
     <?php 
     if ($this->lang->line('Atitleandsummary') != '') { 
      echo stripslashes($this->lang->line('Atitleandsummary')); 
     } else 
      echo "Set weekly or monthly price guests will see for your listing."; 

     ?> 
    </p> 

</div> 
<?php 
if ($listDetail->row()->home_type == 'Office') { 

} else if ($listDetail->row()->home_type == 'House') { 

} 

?> 
<form id="pricelist" name="pricelist" action="site/product/savePriceList" method="post"> 
    <div class="dashboard_price_right"> 

     <label><?php 
      if ($this->lang->line('Pernight') != '') { 
       echo stripslashes($this->lang->line('Pernight')); 
      } else 
       echo "Per night"; 

      ?> 
     </label> 

     <div class="amoutnt-container"> 
      <?php if ($currentCurrency == '') { ?> 
       <span class="WebRupee"><?php echo $currencyDetail->row()->currency_symbols; ?></span> 
      <?php } else { ?> 
       <span class="WebRupee"><?php echo $currentCurrency; ?></span> 
      <?php } ?> 
      <input type="text" id="price" value="<?php 
      if ($listDetail->row()->price != '0.00') { 
       echo intval($listDetail->row()->price); 
      } 

      ?>" class="per_amount_scroll" name="price" onkeypress="return onlyNumbersWithDot(event);" onchange="javascript:Detailview(this,<?php echo $listDetail->row()->id; ?>, 'price');" /> 
      <input type="hidden" id="id" name="id" value="<?php echo $listDetail->row()->id; ?>" /> 
     </div> 
     <div class="dashboard_currency"> 
      <label><?php 
       if ($this->lang->line('Currency') != '') { 
        echo stripslashes($this->lang->line('Currency')); 
       } else 
        echo "Currency"; 

       ?> 
      </label> 
      <div class="select select-large select-block"> 
       <select name="currency" id="currency" onchange="javascript:Detailview(this,<?php echo $listDetail->row()->id; ?>, 'currency');get_currency_symbol(this)" > 
        <!--<option value="">select</option>--> 

        <?php foreach ($currencyDetail->result() as $currency) { ?> 
         <option value="<?php echo $currency->currency_type; ?>" <?php if ($listDetail->row()->currency == $currency->currency_type) echo 'selected="selected"'; ?>><?php echo $currency->currency_type; ?></option> 
        <?php } ?> 
       </select> 
      </div> 
     </div> 
    </div> 
</form> 

내 부동산 가격의 그림이 형성이다

enter image description here

참고 :있는 재산의 두 가지 유형 있습니다 다음 :

1. 사무실

2 집이 재산의 기초

, 나는 내 양식에 더 많은 필드를 추가 할.

는 :) 사전에 감사합니다 날을 제안하십시오

+0

새 필드를 표시하는 데 javascript를 사용하는 것에 대해 생각해 보셨습니까? 이것에 대한 몇 가지 예가 있습니다. 이것은 백만 가지 중 하나입니다. http://stackoverflow.com/questions/23283613/display-other-field-onchange –

+0

아니요. 단순한 PHP를 다른 메커니즘으로 사용하고 싶습니다. –

+0

속성 유형에 속한 모든 입력란을 확인하거나 두 가지 양식을 사용할 수 있습니다. –

답변

0

당신은 실행 조건에 기초를 변경하고 당신에게 사무실이나 집을 나타내는 숨겨진 필드를 전달할 수 있습니다.

<?php 
if ($listDetail->row()->home_type == 'Office') 
{ 
<input type="hidden" name="home_type" value="Office" /> 
<input type="text" name="per_day" value="" /> 
<input type="text" name="half_day" value="" /> 
<input type="text" name="per_hour" value="" /> 
} 
else if ($listDetail->row()->home_type == 'House') 
{ 
<input type="hidden" name="home_type" value="House" /> 
<input type="text" name="per_night" value="" /> 
<input type="text" name="per_day" value="" /> 
<input type="text" name="per_hour" value="" /> 
} 
?> 
+0

고마워요.하지만 제게 제안 해 주시겠습니까? 내 코드에 코드를 어디에 둘 수 있습니까? 형태의 바로 위에 (외부)? –

+0

@AshishVyas (양식 태그 –

+0

) 확인해 보겠습니다. –

관련 문제