gpt4 book ai didi

javascript - JQuery获取formaction和formmethod

转载 作者:行者123 更新时间:2023-12-01 01:59:11 26 4
gpt4 key购买 nike

我有一个像这样的

<form id="popisgolubova_form">
<input name="pregledaj" type="button" formaction="uredigoluba.php" formmethod="post" formtarget="_self" value="pregledaj" class="button" onclick="popisgolubova_radiobutton(this)">
<input name="rodovnik" type="button" formaction="rodovnik.php" formmethod="post" formtarget="_blank" value="rodovnik" class="button" onclick="popisgolubova_radiobutton()">
<input name="podaci" type="button" value="poodaci" formaction="podaciogolubu.php" formmethod="post" formtarget="_blank" class="button" onclick="popisgolubova_radiobutton()">
</form>

和 JavaScript

function popisgolubova_radiobutton(element)
{
alert($(element).find("[formaction]").val());
var popisgolubova_radiobutton=$("input[name=RadioGroup1]").is(":checked");
if(popisgolubova_radiobutton==false)
{
alert("nop");
}
else
{
$("form#popisgolubova_form").submit();
}
}

首先,我检查是否选中了任何复选框,如果是,我可以提交表单。但问题是formaction、formmethod和formtarget。如何获取并提交它们

最佳答案

要获取表单的操作或方法属性,您可以尝试如下操作:

$(function() { 
var action = $("#formid").attr('action'),
method = $("#formid").attr('method');
});

关于javascript - JQuery获取formaction和formmethod,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17214943/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com