Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/306.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何根据返回值重定向用户_Javascript_Jquery_Html - Fatal编程技术网

Javascript 如何根据返回值重定向用户

Javascript 如何根据返回值重定向用户,javascript,jquery,html,Javascript,Jquery,Html,我现在正在努力使用JavaScript。 有人写了这段代码,我正在努力理解它。 根据用户的位置重定向用户的最佳方式是什么 目前,我们通过在手机中使用areadcode来计算他们的区域,正如您在javaScript中看到的那样 这是表格 <div class="row"> <!-- Homework for Jason Begin --> <div class="col-md-6 col-md-offset-3"> <!-- Homew

我现在正在努力使用JavaScript。 有人写了这段代码,我正在努力理解它。 根据用户的位置重定向用户的最佳方式是什么

目前,我们通过在手机中使用areadcode来计算他们的区域,正如您在javaScript中看到的那样

这是表格

<div class="row"> 
  <!-- Homework for Jason Begin -->
  <div class="col-md-6 col-md-offset-3"> 
    <!-- Homework for Jason End -->
    <form id="sfDemoForm" action="https://webto.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8" method="POST" class="sky-form">
      <input name="captcha_settings" value="{&quot;keyname&quot;:&quot;IC_ClearDent_Main_Demo&quot;,&quot;fallback&quot;:&quot;true&quot;,&quot;orgId&quot;:&quot;00D1I0000002QyG&quot;,&quot;ts&quot;:&quot;&quot;}" type="hidden">
      <input name="oid" value="00D1I0000002QyG" type="hidden">
      <input name="retURL" value="https://test.cleardent.com/demo-thankyou-bc.html" type="hidden">

      <!--  ----------------------------------------------------------------------  --> 
      <!--  NOTE: These fields are optional debugging elements. Please uncomment    --> 
      <!--  these lines if you wish to test in debug mode.                          --> 
      <!--  <input type="hidden" name="debug" value=1>                              --> 
      <!--  <input type="hidden" name="debugEmail" value="ppli@cleardent.com">      --> 
      <!--  ----------------------------------------------------------------------  -->

      <fieldset>
        <!--<label class="label" for="first_name">First Name</label>-->
        <label class="input margin-bottom-15"><i class="icon-prepend fa fa-user"></i>
          <input  id="sffirst_name" maxlength="40" name="first_name" size="20" type="text" required placeholder="First name">
        </label>
        <!--<label class="label" for="last_name">Last Name</label>-->
        <label class="input margin-bottom-15"><i class="icon-prepend fa fa-user"></i>
          <input  id="sflast_name" maxlength="80" name="last_name" size="20" type="text" required placeholder="Last name">
        </label>
        <!--<label class="label" for="email">Email</label>-->
        <label class="input margin-bottom-15"><i class="icon-prepend fa fa-envelope"></i>
          <input id="sfemail" maxlength="80" name="email" size="20" type="email" required placeholder="Email address">
        </label>
        <!-- <label class="label" for="phone">Phone</label>-->
        <label class="input margin-bottom-25"><i class="icon-prepend fa fa-phone"></i>
          <input id="sfphone" maxlength="40" name="phone" size="20" type="text" required placeholder="Phone">
        </label>
        <!--<label class="label" for="description">Notes</label>-->
        <label class="textarea textarea-resizable margin-bottom-25">
          <textarea id="sfdescription" name="description" placeholder="Is there something specific you want to see from ClearDent?"></textarea>
        </label>
        <input id="sfstate" name="state" type="hidden">
        <input id="sflead_source" name="lead_source" type="hidden" value="Website">
        <input id="sfcompany" name="company" type="hidden">
        <input id="sfCampaign_ID" name="Campaign_ID" type="hidden" value="7011I000000d5auQAA">
      </fieldset>
      <div id="recaptcha" class="g-recaptcha" data-sitekey="6LeXmEAUAAAAAG7VJd6Z8YCVkP44AgAlqCUmpRAi" data-callback="submitDemoToLead" data-size="invisible"> </div>
      <footer>
        <button id="sfdemoPreSubmit" class="btn-u"><i class="fa fa-paper-plane fa-fw"></i> Get Your Free Demo</button>
        <button class="btn-u btn-brd" onclick="window.history.back();"><i class="fa fa-arrow-left fa-fw"></i> Back</button>
      </footer>
    </form>
  </div>
</div>
我简直是在拔头发

请帮帮我


谢谢

问题出在重定向函数中。是你编的

var province = document.getElementById('#sfstate').value;
如果希望将其保持为纯javascript,则应删除hashtag

var province = document.getElementById('sfstate').value;
或者用jQuery的方式来做

var province = $('#sfstate').val();

先生,不知什么原因它不起作用。你认为这是因为表格是如何提交的吗?或者在表格上重新填写?我很恐慌。我不知道要做什么doDemo请求IC.html:173未捕获语法错误:意外标记}所有page pack.min.js:4 JQMIGRATE:Migrate安装时日志记录处于活动状态,版本1.4.1所有page pack.min.js:4 JQMIGRATE:jQuery.fn.load()不推荐使用的e@all page pack.min.js:4 all page pack.min.js:4 console.trace e@all page pack.min.js:4我不知道这些实际上是什么意思。all-page-pack.min.js是您包含的javascript库吗?可能是Chrome或Firefox扩展导致的错误(我不知道您使用的是什么浏览器)。无论如何,如果它是一个扩展,你可能想禁用或卸载它。
var province = document.getElementById('sfstate').value;
var province = $('#sfstate').val();