jquery - Radiobutton within the Popover not be checked via javascript -
i have query fill html table records database. in 1 of columns of each row, there options how edit, delete, add photos , option opens popover.
this popover bootstrap 3, when open popover line shows 3 radiobuttons , onclick run script in database without refreshing page. want selected radio checked without having refresh page, i'm not getting.
follow code:
<td class="col-small center"> <div class="action-buttons"> <a class="popover-dw" href="#" data-popover="true"> <i class="fa fa-cog bigger-130" data-toggle="tooltip"></i> </a> <div class="popover-content" style="display:none"> <form class="marcarcomovendidoalugado"> <div> <p> anúncio: <%=rsanuncios("id")%> </p> <p> <input <%=checknone%> type="radio" name="vendidoalugado" id="none<%=rsanuncios("id")%>" onclick="alugadovendido('src/rotinas/rotinas.asp?acao=vendido&id=<%=rsanuncios("id")%>&tipo=none&idinput=none<%=rsanuncios("id")%>', 'none<%=rsanuncios("id")%>');" /> nenhum </p> <p> <input <%=checkvendido%> type="radio" name="vendidoalugado" id="marcarcomovendido<%=rsanuncios("id")%>" onclick="alugadovendido('src/rotinas/rotinas.asp?acao=vendido&id=<%=rsanuncios("id")%>&tipo=vendido&idinput=marcarcomovendido<%=rsanuncios("id")%>', 'marcarcomovendido<%=rsanuncios("id")%>');" /> marcar anúncio como vendido </p> <p> <input <%=checkalugado%> type="radio" name="vendidoalugado" id="marcarcomoalugado<%=rsanuncios("id")%>" onclick="alugadovendido('src/rotinas/rotinas.asp?acao=vendido&id=<%=rsanuncios("id")%>&tipo=alugado&idinput=marcarcomoalugado<%=rsanuncios("id")%>', 'marcarcomoalugado<%=rsanuncios("id")%>');" /> marcar anúncio como alugado </p> </div> </form> </div> </div> </td>
and here javascript:
function alugadovendido(url, obj1){ //$(".marcarcomovendidoalugado").attr("checked", false); $(".marcarcomovendidoalugado").prop("checked", false); $("#"+obj1).prop("checked", true); window.rotinas.location.href = url; }
the issue trying make page go page command window.rotinas.location.href = url;
.
you have use ajax avoid making browser go page. jquery has excellent ajax framework can use. read here: https://api.jquery.com/jquery.ajax/
a simple example application.
function alugadovendido(url, obj1){ $(".marcarcomovendidoalugado").prop("checked", false); $("#"+obj1).prop("checked", true); $.ajax({ url: url }); }
even simpler $.get
.
function alugadovendido(url, obj1){ $(".marcarcomovendidoalugado").prop("checked", false); $("#"+obj1).prop("checked", true); $.get(url); }
since these examples above don't contain function callbacks can't verify server has received response. can follows.
function alugadovendido(url, obj1){ $(".marcarcomovendidoalugado").prop("checked", false); $("#"+obj1).prop("checked", true); $.ajax({ url: url, success: function() { // sent data server. }, error: function() { // failed sending data server. } }); }
i recommend looking rest , use post or put instead server configured receive requests.
to send request post follows.
function alugadovendido(url, obj1){ $(".marcarcomovendidoalugado").prop("checked", false); $("#"+obj1).prop("checked", true); $.ajax({ url: url, method: "post", success: function() { // sent data server. }, error: function() { // failed sending data server. } }); }
you should rewrite onclick
send query object function instead data can sent correctly post want it, this:
onclick="alugadovendido('src/rotinas/rotinas.asp', {acao: 'vendido', id: '<%=rsanuncios("id")%>', tipo: 'none', idinput: 'none<%=rsanuncios("id")%>'}, 'none<%=rsanuncios("id")%>');"
then javascript can be:
function alugadovendido(url, data, obj1){ $(".marcarcomovendidoalugado").prop("checked", false); $("#"+obj1).prop("checked", true); $.ajax({ url: url, method: "post", data: data, success: function() { // sent data server. }, error: function() { // failed sending data server. } }); }
Comments
Post a Comment