2017-07-04 11 views
-6

私はこのようなことをしようとしています。大学の選択肢がドロップダウンリストにない場合、ユーザーは「その他」を選択します。他の人を選択すると、テキストボックスに移動して大学の名前を入力します。":"マッチングで使用

コードは、私が持っている今、チャレンジは、その任意のアイデアは、この

Parse error: syntax error, unexpected ':' in C:\xampp\htdocs\seekweb\brWeb.php on line 229 

のようにここでエラーを返すということです。この

     <?php 
         if(isset($_POST['work_exp'])){ 
         $inst_name = $_POST['inst_name']; 
         $inst_name2 = $_POST['inst_name2']; 

         if($inst_name =='Other') 
         { 
          $inst_name2:$inst_name; 
          echo $inst_name; 
         } 

          } 
         ?> 

のように見えますか?コードはここにあなたのワーキングコードはここに非常によく

​​
+1

'$ inst_name2:$ inst_name;'は有効なPHPではありません。実際の質問は何ですか? –

+0

とにかく '$ otherschool:$ school;'とは何ですか? – DarkBee

+0

@lalithkumar、2番目の例を見て、正確に私が何を意味するかを見てください – Pharell

答えて

-1

に動作します!サーバー内の


<script src="https://code.jquery.com/jquery.min.js"></script> 
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" type="text/css" /> 
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script> 


<form method="post" action="<?php echo $_SERVER["PHP_SELF"];?>"> 

<!-- Modal --> 


    <div class="form-group"> 

    <select name="school" id='type'> 
    <option selected="selected" disabled="disabled">Please Select School</option> 
    <option>Catania School of Medicine</option> 
    <option>J.M Hart University</option> 
    <option>Beulah College of Business</option> 
    <option>Crownay University</option> 
    <option value='Other'>Other</option> 
    </select> 


    <div id="myModal" class="modal fade" role="dialog"> 
     <div class="modal-dialog"> 

     <!-- Modal content--> 
     <div class="modal-content"> 
      <div class="modal-header"> 
      <button type="button" class="close" data-dismiss="modal">&times;</button> 
      <h4 class="modal-title">Please Enter Institution name : </h4> 
      </div> 
      <div class="modal-body"> 
      <input type="text" class="form-control" id="name" name="otherschool" placeholder="Enter Name"> 
      </div> 
      <div class="modal-footer"> 
      <button type="button" name="submit" class="btn btn-primary" data-dismiss="modal">Save</button> 
      <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> 
      </div> 
     </div> 
     <!-- Modal content--> 

     </div> 
    </div> 

    </div> 


<button type="submit" name="submit" class="btn btn-primary" data-dismiss="modal">Sumbit</button> 
</form> 


<?php 

if(isset($_POST['submit'])){ 
    $school = $_POST['school']; 
    $otherschool = $_POST['otherschool']; 

    if($school === "Other") 
    { 
     echo $otherschool; 
     // insert code of other 

    } 
    else{ 


     echo $school; 

    } 

} 

?> 





<script type="text/javascript"> 

    $("#type").on("change", function() {   
     $modal = $('#myModal'); 
     if($(this).val() === 'Other'){ 
     $modal.modal('show'); 
    } 
}); 

</script> 

ダウンロード作業ファイルと実行:https://ufile.io/taj8x

$("#type").on("change", function() {   
 
     $modal = $('#myModal'); 
 
     if($(this).val() === 'Other'){ 
 
     $modal.modal('show'); 
 
    } 
 
});
<script src="https://code.jquery.com/jquery.min.js"></script> 
 
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" type="text/css" /> 
 
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script> 
 

 

 
<form method="post" action="<?php echo $_SERVER["PHP_SELF"];?>"> 
 

 
<!-- Modal --> 
 

 
    
 
    <div class="form-group"> 
 
     
 
    <select name="school" id='type'> 
 
    <option selected="selected" disabled="disabled">Please Select School</option> 
 
    <option>Catania School of Medicine</option> 
 
    <option>J.M Hart University</option> 
 
    <option>Beulah College of Business</option> 
 
    <option>Crownay University</option> 
 
    <option value='Other'>Other</option> 
 
    </select> 
 

 

 
    <div id="myModal" class="modal fade" role="dialog"> 
 
     <div class="modal-dialog"> 
 

 
     <!-- Modal content--> 
 
     <div class="modal-content"> 
 
      <div class="modal-header"> 
 
      <button type="button" class="close" data-dismiss="modal">&times;</button> 
 
      <h4 class="modal-title">Please Enter Institution name : </h4> 
 
      </div> 
 
      <div class="modal-body"> 
 
      <input type="text" class="form-control" id="name" name="otherschool" placeholder="Enter Name"> 
 
      </div> 
 
      <div class="modal-footer"> 
 
      <button type="button" name="submit" class="btn btn-primary" data-dismiss="modal">Save</button> 
 
      <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> 
 
      </div> 
 
     </div> 
 
     <!-- Modal content--> 
 

 
     </div> 
 
    </div> 
 

 
    </div> 
 

 

 
<button type="submit" name="submit" class="btn btn-primary" data-dismiss="modal">Sumbit</button> 
 
</form> 
 

 

 
<?php 
 

 
if(isset($_POST['submit'])){ 
 
    $school = $_POST['school']; 
 
    $otherschool = $_POST['otherschool']; 
 

 
    if($school === "Other") 
 
    { 
 
     echo $otherschool; 
 
     // insert code of other 
 

 
    } 
 
    else{ 
 

 

 
     echo $school; 
 

 
    } 
 

 
} 
 

 
?>

関連する問題