The two buttons on the page call different methods when submitting the form, but you must submit the query conditions on the page to the action

Source: Internet
Author: User

When you click query or export a report, the query is performed based on the query conditions, but the server side is definitely not an action. At this time, you need to submit a form and call different actions.

 

Jquery

$ (Document). Ready (function (){
$ ("# Btnsearch, # btnexport"). Click (function (){
$ ("# Issearch"). ATTR ("value", 1 );
VaR action = $ (this). Data ("action ");
$ ("Form") [0]. Action = action;
VaR selectname = $ ("# activelistname"). Find ("option: Selected"). Text ();
If (selectname = "select "){
Return alert ("select activity name ");
}
Else {
$ ("Form") [0]. Submit ();
}
});

 

HTML:

@ Using (html. beginform ())
{
@ Html. textboxfor (n => N. issearch, new {@ type = "hidden "})
<Table class = "Table-striped table-bordered displaytable" id = "displaytable">
<Tbody>
<Tr class = "odd">
<TD class = "right">
Activity time:
</TD>
<TD class = "Left" colspan = "3" style = "vertical-align: middle;">
From: @ HTML. textboxfor (model => model. begindate, new {@ class = "wdate", @ onclick = "wdatepicker ({LANG: 'zh-cn '})"})
To: @ HTML. textboxfor (model => model. enddate, new {@ class = "wdate", @ onclick = "wdatepicker ({LANG: 'zh-cn '})"})
</TD>
</Tr>
@{
Html. renderaction ("searchareausercontrol", "staff", model = NULL? Null: New areausercontrolviewmodel {areaid = model. areaid, clusterid = model. clusterid, filialeid = model. filialeid, salescode = model. salescode, channelid = model. channelid
});
}
<Tr>
<TD class = "right">
Activity name
</TD>
<TD class = "Left" style = "vertical-align: middle;">
@ Html. dropdownlistfor (M => M. activelistname, new [] {
New selectlistitem () {text = "f1", value = "f1 "},
New selectlistitem () {text = "Mu", value = "Mu "}

}, "Select ")
</TD>
<TD colspan = "2">
</TD>
</Tr>
<Tr>
<TD class = "right">
Site code/account
</TD>
<TD class = "Left" style = "vertical-align: middle;">
@ Html. textboxfor (model => model. sitecode, new {@ class = "input span3 number "})
</TD>
<TD colspan = "2">
</TD>
</Tr>
<Tr>
<TD class = "right">
Company Name
</TD>
<TD class = "Left" style = "vertical-align: middle;">
@ Html. textboxfor (model => model. Name, new {@ class = "input span3 number "})
</TD>
<TD colspan = "2">
</TD>
</Tr>
</Tbody>
</Table>
<Div class = "btn_usebox">
<Table>
<Tr>
<TD>
<Input type = "button" class = "btn_use" data-action = "@ URL. Action (" activelist ")" id = "btnsearch" value = ""/>
</TD>
<TD>
<Input type = "button" id = "reset" class = "btn_use" value = "Clear all"/>
</TD>
<TD>
<Input type = "button" class = "btn_use" data-action = "@ URL. Action (" exportforactive ")" id = "btnexport" value = "export report"/>
</TD>
</Tr>
</Table>
</Div>
}
</Div>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.