使用javascript / html基于两个特定表单选项提交后表单重定向

时间:2015-05-07 18:23:20

标签: javascript html forms redirect

这是我的尝试,目前无效。我希望有人能够选择一个位置和一种事件。然后,这将确定他们被重定向到哪个网页。我不太确定我做错了什么。

<form name="signupForm" id="signupForm" target="_top" method="post" action="http://app.greenrope.com/j1.pl?9ec6ce8b4e17b30b7c2a75edc1c1a684716721de718b4187c3ac601cb070094b" onsubmit="get_action(this);">
<table>
  <tbody>
    <tr>
      <td> 
        <ul id="teamFields"> 
          <li class="formRow emailRow" id="field_Email">
            <label class="fieldName" for="signup_Email">Email<span class="reqMarker">*</span></label>
            <input type="text" name="Email" maxlength="64" value="" id="signup_Email" class="inputTextField" />
            <div id="emailEntryAlert"></div>
          </li> 
          <li class="formRow userFieldName" id="field_User5">
            <label class="fieldName" id="labelUser5" for="signup_User5">Please select the closest city to where you live from the list<span class="reqMarker">*</span></label>
            <select name="User5" id="signup_User5">
              <option value="">Choose</option>
              <option value="London">London</option>
              <option value="Birmingham">Birmingham</option>
              <option value="Manchester">Manchester</option>
            </select>
          </li>
          </li> 
          <li class="formRow userFieldName" id="field_User8">
            <label class="fieldName" id="labelUser8" for="signup_User8">Would you like to attend the workshop and/or audition?<span class="reqMarker">*</span></label>
            <select name="User8" id="signup_User8">
              <option value="">Choose</option>
              <option value="Workshop Only">Workshop Only</option>
              <option value="Workshop + Audition">Workshop + Audition</option>
              <option value="Audition Only">Audition Only</option>
            </select>
          </li>
        </ul>
        <ul id="teamSelection"> 
          <li class="formRow joinRow"><span id="confirmText"></span></li> 
          <input type="hidden" name="AutomaticTeamIDs" value="4" /> 
          <input type="hidden" name="AutomaticTeamIDs" value="3" /> 
          <input type="hidden" name="AutomaticTeamIDs" value="1" /> 
        </ul> 
      </td>
    </tr>
  </tbody>
</table> 
<div id="reqInfo">* required information</div> 
<input id="formSubmit" type="submit" name="formSubmit" style="font-weight: bold; font-size: 16px; color: #000000; border-style: solid; border-width: 8px !important; border-color: #d3d3d3 !important; border-radius: 0px !important; padding: 16px !important; background: #a9a9a9 !important; box-shadow: none !important;" value="Sign Me Up" />
<input type="hidden" name="Referrer" value="" /> 
<input type="hidden" name="qstring" value="9ec6ce8b4e17b30b7c2a75edc1c1a684716721de718b4187c3ac601cb070094b" /> 
<input type="hidden" name="formSubmitCheck" value="1" /> 

<script type="text/javascript">
    function get_action(form) {
        var optn = document.getElementById("signup_User5");
        var optn_value = e.options[e.selectedIndex].value;
        var option = document.getElementById("signup_User8");
        var option_value = e.options[e.selectedIndex].value;

        if ((option_value == "Workshop Only") && (optn_value=="London")) {
            window.location.href = "http://www.mscurvaceousuk.com/mcuklondonworkshop";
        } else if ((option_value == "Workshop Only") && (optn_value == "Birmingham")) {
            window.location.href = "http://www.mscurvaceousuk.com/mcukbirminghamworkshop";
        } else if ((option_value == "Workshop Only") && (optn_value == "Manchester")) {
            window.location.href = "http://www.mscurvaceousuk.com/mcukmanchesterworkshop";
        } else if ((option_value == "Audition Only") && (optn_value == "London")) {
            window.location.href = "http://www.mscurvaceousuk.com/mcuk-london-audition-confirmation";
        } else if ((option_value == "Audition Only") && (optn_value == "Birmingham")) {
            window.location.href = "http://www.mscurvaceousuk.com/mcuk-birmingham-audition-confirmation";
        } else if ((option_value == "Audition Only") && (optn_value == "Manchester")) {
            window.location.href = "http://www.mscurvaceousuk.com/mcuk-manchester-audition-confirmation"; 
        } else if ((option_value == "Audition + Workshop") && (optn_value == "London")) {
            window.location.href = "http://www.mscurvaceousuk.com/mcuk-london-audition-confirmation";
        } else if ((option_value == "Audition + Workshop") && (optn_value == "Birmingham")) {
            window.location.href = "http://www.mscurvaceousuk.com/mcuk-birmingham-audition-confirmation";
        } else if ((option_value == "AAudition + Workshop") && (optn_value == "Manchester"))
            window.location.href ="http://www.mscurvaceousuk.com/mcuk-manchester-audition-confirmation"; 
        }
    }
</script>
</form> 
<div id="formBottom">
</div> 
</div> 
</div> 
</body>
</html>

1 个答案:

答案 0 :(得分:0)

请检查alert()optn_value和option_value会带来什么值?

最好像...一样使用 var optn_value = document.getElementById(“signup_User5”)。value; var option_value = document.getElementById(“signup_User8”)。value;