从弹簧形式中获取所选值:选择并将其用作参数href

时间:2017-04-10 18:42:42

标签: javascript java spring href

我想知道如何从

中获取所选值
(function (o, f) {
    return function () { return f.apply(o, arguments); };
}(myObj1, myObj1.name))

<springform:select id="novoPlastico" class="input" path="novoPlastico.codPlastico" value="${form.novoPlastico.codPlastico}">
                        <option value=-1>Selecione</option>
                    </springform:select>

并在以下href中使用这些值

<td><springform:select id="grupoAfinidade" class="input" path="grupoAfinidade.grp" value="${form.grupoAfinidade.grp}" onchange="carregarNovosPlasticos();">
                    <option value=-1>Selecione</option>
                </springform:select></td>       

EDIT1:

  <a href="${pageContext.request.contextPath}/parametros/migrCanais.do?plastNovo=${
    --HERE I WANT THE FIRST SELECTED VALUE -- }&grp=${ -- HERE I WANT THE SECOND SELECTED VALUE --}" class="bt"><span>Go!</span></a>

1 个答案:

答案 0 :(得分:0)

首先在你的jsp head元素中添加它:

<script type="text/javascript">var ctx = "${pageContext.request.contextPath}"</script>

之后尝试使用以下javascript代码:

$(".bt").on("click", function(e) {
    e.preventDefault();

    var value1 = $("#novoPlastico").val();
    var value2 = $("#grupoAfinidade").val();

    window.location.href = ctx + "/parametros/migrCanais.do?plastNovo=" + value1 + "&grp=" + value2;
})