2017-04-10 6 views
0

Ich möchte wissen, wie kann ich den ausgewählten Wert vonden ausgewählten Wert aus einer Spring Get: wählen und es als href-Parameter verwenden

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

Und

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

Und verwenden Sie diese Werte erhalten in der folgenden href

<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> 

EDIT1:

<script type="text/JavaScript" language="JavaScript" src="${pageContext.request.contextPath}/js/jquery-2.1.4.min.js"></script> 

jQuery. noConflict(); 

jQuery("#btConfirma").on("click", function(e) { 
    e.preventDefault(); 

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

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

<a id="btConfirma" class="bt" href="#"><span>Confirmar migração de canais de venda</span></a> 

Antwort

0

Zuerst das Kopfelement in Ihrem jsp hinzufügen:

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

Danach versuchen, mit folgendem JavaScript-Code:

$(".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; 
}) 
+0

Ich brauche die href in entfernen? –

+0

hat nicht funktioniert, ich klicke und nichts passiert –

Verwandte Themen