메인>>유머

input 이메일 선택 입력

2022-01-25 16:55:00 3522

 
<?php 
if($_POST){
$swr_email_1=$_POST['swr_email_1'];  
$swr_email_2=$_POST['swr_email_2'];
$swr_email_3=$_POST['swr_email_3'];

if($swr_email_2=="no"){
echo $user_mail="{$swr_email_1}@{$swr_email_3}";
}else{
echo $user_mail="{$swr_email_1}@{$swr_email_2}";
}

}
?>
<script src="//sir.kr/js/jquery-1.8.3.min.js"></script>
<form name="fwrite" id="fwrite" action="" onsubmit="return fwrite_submit(this);" method="post" enctype="multipart/form-data" autocomplete="off">
  <label style="text-align:right; padding-right:13px;">E-mail</label> 
  <input type="text" name="swr_email_1" id="swr_email_1" value="<?php echo $swr_email_1;?>" placeholder="" style="width:120px;"> @ 
  <input type="text" name="swr_email_3" id="swr_email_2" value="<?php echo $swr_email_2;?>" placeholder="" style="width:120px;"> 
    <select name="swr_email_2" id="selectEmail">
		<option value="no" <?php if ($swr_email_2 == "") { echo "selected";}?>>직접입력</option>
		<option value="naver.com" <?php if ($swr_email_2 == "naver.com") { echo "selected";}?>>naver.com</option>
		<option value="daum.net" <?php if ($swr_email_2 == "daum.net") { echo "selected";}?>>daum.net</option>
		<option value="hanmail.net" <?php if ($swr_email_2 == "hanmail.net") { echo "selected";}?>>hanmail.net</option>
		<option value="gmail.com" <?php if ($swr_email_2 == "gmail.com") { echo "selected";}?>>gmail.com</option>
		<option value="nate.com" <?php if ($swr_email_2 == "nate.com") { echo "selected";}?>>nate.com</option>
		<option value="hotmail.com" <?php if ($swr_email_2 == "hotmail.com") { echo "selected";}?>>hotmail.com</option>
		<option value="msn.com" <?php if ($swr_email_2 == "msn.com") { echo "selected";}?>>msn.com</option>
		<option value="icloud.com" <?php if ($swr_email_2 == "icloud.com") { echo "selected";}?>>icloud.com</option>
    </select>
    <input type="submit" value="발급신청" id="btn_submit" style="border:solid 1px #dddddd;padding:10px 40px;background-color:#eee;" accesskey="s">
    <script>
    //이메일 입력방식 선택
    $('#selectEmail').change(function(){
       $("#selectEmail option:selected").each(function () {
            
            if($(this).val()== 'no'){ //직접입력일 경우
                 $("#swr_email_2").val('');                        //값 초기화
                 $("#swr_email_2").attr("disabled",false); //활성화
            }else{ //직접입력이 아닐경우
                 $("#swr_email_2").val($(this).text());      //선택값 입력
                 $("#swr_email_2").attr("disabled",true); //비활성화
            }
       });
    });
    </script>
</form>