• 10-10-2019, 09:33:58
    #1
    Arkadaşlar elimde şöyle bir form var:

    <!-- Note :
       - You can modify the font style and form style to suit your website. 
       - Code lines with comments    Do not remove this code     are required for the form to work properly, make sure that you do not remove these lines of code. 
       - The Mandatory check script can modified as to suit your business needs. 
       - It is important that you test the modified form before going live.-->
    <div id='crmWebToEntityForm' style='width:600px;margin:auto;'>
       <META HTTP-EQUIV ='content-type' CONTENT='text/html;charset=UTF-8'>
       <form action='https://crm.zoho.com/crm/WebToLeadForm' name=WebToLeads3552547000002830419 method='POST' enctype='multipart/form-data' onSubmit='javascript:document.charset="UTF-8"; return checkMandatory3552547000002830419()' accept-charset='UTF-8'>
     <input type='text' style='display:none;' name='xnQsjsdp' value='8985be06a477676efbda83b0b4c715e4356ffe55589b29889350c8b593845f89'></input> 
     <input type='hidden' name='zc_gad' id='zc_gad' value=''></input> 
     <input type='text' style='display:none;' name='xmIwtLD' value='13f133a3f0dfa742f9b309ce7502ce66e441c929ef1a9ee46a46859605224f90'></input> 
     <input type='text'  style='display:none;' name='actionType' value='TGVhZHM='></input>
     <input type='text' style='display:none;' name='returnURL' value='/thanks/' > </input><br></br>
    	 <!-- Do not remove this code. -->
    	<style>
    		#crmWebToEntityForm tr , #crmWebToEntityForm td { 
    			padding:6px;
    			border-spacing:0px;
    			border-width:0px;
    			}
    	</style>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
    	<table style='width:600px;background-color:none;background-color:none;color:none'><tr><td colspan='2' align='left' style='color:none;font-family:Arial;font-size:14px;word-break: break-word;'><strong></strong></td></tr> <br></br><tr><td  style='word-break: break-word;text-align:left;font-size:12px;font-family:Arial;width:30%;'>Name<span style='color:red;'>*</span></td><td style='width:40%;' ><input type='text' style='width:100%;box-sizing:border-box;'  maxlength='80' name='Last Name' /></td><td style='width:30%;'></td></tr><tr><td  style='word-break: break-word;text-align:left;font-size:12px;font-family:Arial;width:30%;'>Email<span style='color:red;'>*</span></td><td style='width:40%;' ><input type='text' style='width:100%;box-sizing:border-box;'  maxlength='100' name='Email' /></td><td style='width:30%;'></td></tr><tr><td  style='word-break: break-word;text-align:left;font-size:12px;font-family:Arial;width:30%;'>Age<span style='color:red;'>*</span></td><td style='width:40%;' ><input type='text' style='width:100%;box-sizing:border-box;'  maxlength='9' name='LEADCF52' /></td><td style='width:30%;'></td></tr><tr><td  style='word-break: break-word;text-align:left;font-size:12px;font-family:Arial;width:30%;'>Country<span style='color:red;'>*</span></td><td style='width:40%;' ><span id="country"></span><input type='text' style='width:100%;box-sizing:border-box;'  maxlength='100' name='Country' /></td><td style='width:30%;'></td></tr><tr><td  style='word-break: break-word;text-align:left;font-size:12px;font-family:Arial;width:30%;'>City<span style='color:red;'>*</span></td><td style='width:40%;' ><input type='text' style='width:100%;box-sizing:border-box;'  maxlength='100' name='City' /></td><td style='width:30%;'></td></tr><tr><td  style='word-break: break-word;text-align:left;font-size:12px;font-family:Arial;width:30%;'>Phone<span style='color:red;'>*</span></td><td style='width:40%;' ><input type='text' style='width:100%;box-sizing:border-box;'  maxlength='30' name='Phone' /></td><td style='width:30%;'></td></tr><tr><td  style='word-break: break-word;text-align:left;font-size:12px;font-family:Arial;width:30%;'>Subject<span style='color:red;'>*</span></td><td style='width:40%;' ><input type='text' style='width:100%;box-sizing:border-box;'  maxlength='255' name='LEADCF44' /></td><td style='width:30%;'></td></tr><tr><td  style='word-break: break-word;text-align:left;font-size:12px;font-family:Arial;width:30%;'>Message </td><td style='width:40%;'> <textarea name='Description' maxlength='32000' style='width:100%;'>&nbsp;</textarea></td><td style='width:30%;'></td></tr><tr style='display:none;' ><td style='word-break: break-word;text-align:left;font-size:12px;font-family:Arial;width:30%'>Connection Language</td><td style='width:40%;'>
    		<select style='width:100%;box-sizing:border-box;' name='LEADCF5'>
    			<option value='-None-'>-None-</option>
    		<option selected value='English'>English</option>
    			<option value='Arabic'>Arabic</option>
    			<option value='Russian'>Russian</option>
    			<option value='Romanian'>Romanian</option>
    			<option value='French'>French</option>
    			<option value='German'>German</option>
    			<option value='Uzbek'>Uzbek</option>
    		</select></td><td style='width:30%;'></td></tr><tr><td style='nowrap:nowrap;text-align:left;font-size:12px;font-family:Arial;width:30%;box-sizing:border-box;'>Upload a File</td>
    	    <td style='padding-top: 10px;width:40%;box-sizing:border-box;'><input type='file' name='theFile' id='theFile' multiple style='width:100%;box-sizing:border-box;'/><p style='color:none;font-size:11px;padding-left:3px;'>File(s) size limit is 20MB.</p></td>
    	<td style='width:30%;vertical-align: bottom;'></td>
    	</tr>
    
    	<tr><td colspan='2' style='text-align:center; padding-top:15px;font-size:12px;'>
    		<input style='margin-right: 5px;cursor: pointer;font-size:12px;color:none' id='formsubmit' type='submit' value='Send' ></input> <input type='reset' name='reset' style='cursor: pointer;font-size:12px;color:none' value='Reset' ></input> </td></tr></table>
    	<script>
     	  var mndFileds=new Array('Last Name','LEADCF52','Country','City','Email','Phone','LEADCF44');
     	  var fldLangVal=new Array('Name','Age','Country','City','Email','Phone','Subject'); 
    		var name='';
    		var email='';
    
     	  function checkMandatory3552547000002830419() {
    		for(i=0;i<mndFileds.length;i++) {
    		  var fieldObj=document.forms['WebToLeads3552547000002830419'][mndFileds[i]];
    		  if(fieldObj) {
    			if (((fieldObj.value).replace(/^\s+|\s+$/g, '')).length==0) {
    			 if(fieldObj.type =='file')
    				{ 
    				 alert('Please select a file to upload.'); 
    				 fieldObj.focus(); 
    				 return false;
    				} 
    			alert(fldLangVal[i] +' cannot be empty.'); 
       	   	  	  fieldObj.focus();
       	   	  	  return false;
    			}  else if(fieldObj.nodeName=='SELECT') {
      	   	   	 if(fieldObj.options[fieldObj.selectedIndex].value=='-None-') {
    				alert(fldLangVal[i] +' cannot be none.'); 
    				fieldObj.focus();
    				return false;
    			   }
    			} else if(fieldObj.type =='checkbox'){
     	 	 	 if(fieldObj.checked == false){
    				alert('Please accept  '+fldLangVal[i]);
    				fieldObj.focus();
    				return false;
    			   } 
    			 } 
    			 try {
    			     if(fieldObj.name == 'Last Name') {
    				name = fieldObj.value;
     	 	 	    }
    			} catch (e) {}
    		    }
    		}
    		 return validateFileUpload();
    
    		document.getElementById('formsubmit').disabled=true;
    	}function validateFileUpload(){
    		 var uploadedFiles = document.getElementById('theFile'); 
    		 var totalFileSize =0; 
    		 if(uploadedFiles.files.length >3){ 
    			 alert('You can upload a maximum of three files at a time.'); 
    			 return false; 
    		 } 
    		 if ('files' in uploadedFiles) { 
    			 if (uploadedFiles.files.length != 0) { 
    				 for (var i = 0; i < uploadedFiles.files.length; i++) { 
    					 var file = uploadedFiles.files[i]; 
    					 if ('size' in file) { 
    						 totalFileSize = totalFileSize + file.size; 
    					 } 
    				 } 
    				 if(totalFileSize > 20971520){ 
    					 alert('Total file(s) size should not exceed 20MB.'); 
    					 return false; 
    				 } 
    			 } 
    		 } 
    	 }
    </script>
    
    	</form>
    </div>
    bu formdaki country ve city yazan alanları geolocation api ile otomatik doldurup filedleri hide yapmak istiyorum. Kullanmak istediğim api https://ipgeolocation.io/documentati...ation-api.html bilgileri burada, formu wordpress iletişim bölümüne raw html olarak ekleyeceğim.

    Ücretli ücretsiz yardım edermisiniz.
  • 10-10-2019, 10:17:12
    #2
    API ANAHTARI yazdığım yere ipgeolocation sitesinden üyelik sonrası aldığınız API KEY ini yazmanız gerekiyor.

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
    <script>
    $.getJSON("https://jsonip.com/?callback=?",function(ip){
    var ipadresim = ip.ip;    
    $.getJSON("https://api.ipgeolocation.io/ipgeo?apiKey=API ANAHTARI&ip="+ipadresim,function(veri){
             $("#Country").val(veri.country_name);
             $("#City").val(veri.city);
    
    });
    });
    </script>
    
    <!-- Note :
    - You can modify the font style and form style to suit your website.
    - Code lines with comments Do not remove this code are required for the form to work properly, make sure that you do not remove these lines of code.
    - The Mandatory check script can modified as to suit your business needs.
    - It is important that you test the modified form before going live.-->
    <div id='crmWebToEntityForm' style='width:600px;margin:auto;'>
    <META HTTP-EQUIV ='content-type' CONTENT='text/html;charset=UTF-8'>
    <form action='https://crm.zoho.com/crm/WebToLeadForm' name=WebToLeads3552547000002830419 method='POST' enctype='multipart/form-data' onSubmit='javascript<b></b>:document.charset="UTF-8"; return checkMandatory3552547000002830419()' accept-charset='UTF-8'>
    <input type='text' style='display:none;' name='xnQsjsdp' value='8985be06a477676efbda83b0b4c715e4356ffe55589b29889350c8b593845f89'></input>
    <input type='hidden' name='zc_gad' id='zc_gad' value=''></input>
    <input type='text' style='display:none;' name='xmIwtLD' value='13f133a3f0dfa742f9b309ce7502ce66e441c929ef1a9ee46a46859605224f90'></input>
    <input type='text' style='display:none;' name='actionType' value='TGVhZHM='></input>
    <input type='text' style='display:none;' name='returnURL' value='/thanks/' > </input><br></br>
    <!-- Do not remove this code. -->
    <style>
    #crmWebToEntityForm tr , #crmWebToEntityForm td {
    padding:6px;
    border-spacing:0px;
    border-width:0px;
    }
    </style>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
    <table style='width:600px;background-color:none;background-color:none;color:none'><tr><td colspan='2' align='left' style='color:none;font-family:Arial;font-size:14px;word-break: break-word;'><strong></strong></td></tr> <br></br><tr><td style='word-break: break-word;text-align:left;font-size:12px;font-family:Arial;width:30%;'>Name<span style='color:red;'>*</span></td><td style='width:40%;' ><input type='text' style='width:100%;box-sizing:border-box;' maxlength='80' name='Last Name' /></td><td style='width:30%;'></td></tr><tr><td style='word-break: break-word;text-align:left;font-size:12px;font-family:Arial;width:30%;'>Email<span style='color:red;'>*</span></td><td style='width:40%;' ><input type='text' style='width:100%;box-sizing:border-box;' maxlength='100' name='Email' /></td><td style='width:30%;'></td></tr><tr><td style='word-break: break-word;text-align:left;font-size:12px;font-family:Arial;width:30%;'>Age<span style='color:red;'>*</span></td><td style='width:40%;' ><input type='text' style='width:100%;box-sizing:border-box;' maxlength='9' name='LEADCF52' /></td><td style='width:30%;'></td></tr><tr><td style='word-break: break-word;text-align:left;font-size:12px;font-family:Arial;width:30%;'>Country<span style='color:red;'>*</span></td><td style='width:40%;' ><span id="country"></span><input type='text' style='width:100%;box-sizing:border-box;' maxlength='100' name='Country' id="Country" /></td><td style='width:30%;'></td></tr><tr><td style='word-break: break-word;text-align:left;font-size:12px;font-family:Arial;width:30%;'>City<span style='color:red;'>*</span></td><td style='width:40%;' ><input type='text' style='width:100%;box-sizing:border-box;' maxlength='100' name='City' id="City" /></td><td style='width:30%;'></td></tr><tr><td style='word-break: break-word;text-align:left;font-size:12px;font-family:Arial;width:30%;'>Phone<span style='color:red;'>*</span></td><td style='width:40%;' ><input type='text' style='width:100%;box-sizing:border-box;' maxlength='30' name='Phone' /></td><td style='width:30%;'></td></tr><tr><td style='word-break: break-word;text-align:left;font-size:12px;font-family:Arial;width:30%;'>Subject<span style='color:red;'>*</span></td><td style='width:40%;' ><input type='text' style='width:100%;box-sizing:border-box;' maxlength='255' name='LEADCF44' /></td><td style='width:30%;'></td></tr><tr><td style='word-break: break-word;text-align:left;font-size:12px;font-family:Arial;width:30%;'>Message </td><td style='width:40%;'> <textarea name='Description' maxlength='32000' style='width:100%;'>&nbsp;</textarea></td><td style='width:30%;'></td></tr><tr style='display:none;' ><td style='word-break: break-word;text-align:left;font-size:12px;font-family:Arial;width:30%'>Connection Language</td><td style='width:40%;'>
    <select style='width:100%;box-sizing:border-box;' name='LEADCF5'>
    <option value='-None-'>-None-</option>
    <option selected value='English'>English</option>
    <option value='Arabic'>Arabic</option>
    <option value='Russian'>Russian</option>
    <option value='Romanian'>Romanian</option>
    <option value='French'>French</option>
    <option value='German'>German</option>
    <option value='Uzbek'>Uzbek</option>
    </select></td><td style='width:30%;'></td></tr><tr><td style='nowrap:nowrap;text-align:left;font-size:12px;font-family:Arial;width:30%;box-sizing:border-box;'>Upload a File</td>
    <td style='padding-top: 10px;width:40%;box-sizing:border-box;'><input type='file' name='theFile' id='theFile' multiple style='width:100%;box-sizing:border-box;'/><p style='color:none;font-size:11px;padding-left:3px;'>File(s) size limit is 20MB.</p></td>
    <td style='width:30%;vertical-align: bottom;'></td>
    </tr>
    
    <tr><td colspan='2' style='text-align:center; padding-top:15px;font-size:12px;'>
    <input style='margin-right: 5px;cursor: pointer;font-size:12px;color:none' id='formsubmit' type='submit' value='Send' ></input> <input type='reset' name='reset' style='cursor: pointer;font-size:12px;color:none' value='Reset' ></input> </td></tr></table>
    <script>
    var mndFileds=new Array('Last Name','LEADCF52','Country','City','Email','Phone','LEADCF44');
    var fldLangVal=new Array('Name','Age','Country','City','Email','Phone','Subject');
    var name='';
    var email='';
    
    function checkMandatory3552547000002830419() {
    for(i=0;i<mndFileds.length;i++) {
    var fieldObj=document.forms['WebToLeads3552547000002830419'][mndFileds[i]];
    if(fieldObj) {
    if (((fieldObj.value).replace(/^s+|s+$/g, '')).length==0) {
    if(fieldObj.type =='file')
    {
    alert('Please select a file to upload.');
    fieldObj.focus();
    return false;
    }
    alert(fldLangVal[i] +' cannot be empty.');
    fieldObj.focus();
    return false;
    } else if(fieldObj.nodeName=='SELECT') {
    if(fieldObj.options[fieldObj.selectedIndex].value=='-None-') {
    alert(fldLangVal[i] +' cannot be none.');
    fieldObj.focus();
    return false;
    }
    } else if(fieldObj.type =='checkbox'){
    if(fieldObj.checked == false){
    alert('Please accept '+fldLangVal[i]);
    fieldObj.focus();
    return false;
    }
    }
    try {
    if(fieldObj.name == 'Last Name') {
    name = fieldObj.value;
    }
    } catch (e) {}
    }
    }
    return validateFileUpload();
    
    document.getElementById('formsubmit').disabled=true;
    }function validateFileUpload(){
    var uploadedFiles = document.getElementById('theFile');
    var totalFileSize =0;
    if(uploadedFiles.files.length >3){
    alert('You can upload a maximum of three files at a time.');
    return false;
    }
    if ('files' in uploadedFiles) {
    if (uploadedFiles.files.length != 0) {
    for (var i = 0; i < uploadedFiles.files.length; i++) {
    var file = uploadedFiles.files[i];
    if ('size' in file) {
    totalFileSize = totalFileSize + file.size;
    }
    }
    if(totalFileSize > 20971520){
    alert('Total file(s) size should not exceed 20MB.');
    return false;
    }
    }
    }
    }
    </script>
    
    </form>
    </div>
  • 10-10-2019, 10:33:17
    #3
    Çok teşekkür ederim sorunumu çözdü, elinize sağlık.