function calculateEnd() {
var dateval = new Date();
dateval.setYear($('#<%=ddlFSYear.ClientID %>').val()); // value is not going to be set on dateval dateval.setMonth($('#<%=ddlfsmonth.ClientID %>').val()); // value is not going to be set on dateval dateval.setDate($('#<%=ddlfsdate.ClientID %>').val()); // value is not going to be set on dateval
var val = 0;
if ($('#<%=cb1year.ClientID %>')[0].checked)
val = 1;
else if ($('#<%=cb2year.ClientID %>')[0].checked)
val = 2;
else if ($('#<%=cb3year.ClientID %>')[0].checked)
val = 3;
else if ($('#<%=cballyear.ClientID %>')[0].checked)
val = 10;
dateval.setYear(dateval.getFullYear()+ val);
dateval.setMonth(dateval.getMonth() - 1);
$('#<%=LblFSmonth.ClientID%>').html(dateval.getDate() + "/" + (dateval.getMonth() + 1) + "/" + dateval.getFullYear());
}
Greetings as i am new in jquery. i want to avoid post back while selecting on countryi have two dropdown one is country and another is stateif i select country other than india state dropdown should be disable.
Below Code is working but after select india state in not getting enable
<script type="text/javascript">
$(function() {
$('#<%=cmbCountry.ClientID %>').click(function(e) {
var ddlstate = $('#<%= cmbState.ClientID%>');
if ($(this).children("option").filter(":selected").text() == 'india') {
ddlstate.removeAttr('disabled');
} //...bind state dropdown code here }
else {
ddlstate.attr('disabled', true);
}
atul2430
Member
141 Points
557 Posts
Re: jquery for avoid postback
Jan 18, 2013 06:04 AM|LINK
Hi anup,
this is not working for serside control.
i want to impliment this on these control.
plz tell me how
asteranup
All-Star
30184 Points
4906 Posts
Re: jquery for avoid postback
Jan 18, 2013 06:29 AM|LINK
Hi,
I hope no more confusion after this code-
<html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function () { $("input[id*=year]").click(function () { calculateEnd(); }) $('#<%=date.ClientID %>, #<%=month.ClientID %>, #<%=year.ClientID %>').change(function () { calculateEnd(); }) }); function calculateEnd() { var dateval = new Date(); dateval.setYear($('#<%=year.ClientID %>').val()); dateval.setMonth($('#<%=month.ClientID %>').val()); dateval.setDate($('#<%=date.ClientID %>').val()); var val = 0; if ($('#<%=year1.ClientID %>')[0].checked) val = 1; else if ($('#<%=year2.ClientID %>')[0].checked) val = 2; else if ($('#<%=year3.ClientID %>')[0].checked) val = 3; dateval.setYear(dateval.getFullYear() + val); dateval.setMonth(dateval.getMonth() - 1); $("#enddate").html(dateval.getDate() + "/" + (dateval.getMonth() + 1) + "/" + dateval.getFullYear()); } </script> </head> <body> <form id="form1" runat="server"> <asp:CheckBox ID="year1" runat="server" />one year<br /> <asp:CheckBox ID="year2" runat="server" />one year<br /> <asp:CheckBox ID="year3" runat="server" />one year<br /> Date<asp:DropDownList id="date" runat="server"> <asp:ListItem>1</asp:ListItem> <asp:ListItem>2</asp:ListItem> <asp:ListItem>3</asp:ListItem> <asp:ListItem>4</asp:ListItem> <asp:ListItem>5</asp:ListItem> <asp:ListItem>6</asp:ListItem> <asp:ListItem>7</asp:ListItem> <asp:ListItem>8</asp:ListItem> <asp:ListItem>9</asp:ListItem> <asp:ListItem>10</asp:ListItem> <asp:ListItem>11</asp:ListItem> <asp:ListItem>12</asp:ListItem> <asp:ListItem>13</asp:ListItem> <asp:ListItem>14</asp:ListItem> <asp:ListItem>15</asp:ListItem> <asp:ListItem>16</asp:ListItem> <asp:ListItem>17</asp:ListItem> <asp:ListItem>18</asp:ListItem> <asp:ListItem>19</asp:ListItem> <asp:ListItem>20</asp:ListItem> <asp:ListItem>21</asp:ListItem> <asp:ListItem>22</asp:ListItem> <asp:ListItem>23</asp:ListItem> <asp:ListItem>24</asp:ListItem> <asp:ListItem>25</asp:ListItem> <asp:ListItem>26</asp:ListItem> <asp:ListItem>27</asp:ListItem> <asp:ListItem>28</asp:ListItem> <asp:ListItem>29</asp:ListItem> <asp:ListItem>30</asp:ListItem> <asp:ListItem>31</asp:ListItem> </asp:DropDownList> <asp:DropDownList id="month" runat="server"> <asp:ListItem Value="0">Jan</asp:ListItem> <asp:ListItem Value="1" >Feb</asp:ListItem> <asp:ListItem Value="2">Mar</asp:ListItem> <asp:ListItem Value="3">Apr</asp:ListItem> <asp:ListItem Value="4">may</asp:ListItem> <asp:ListItem Value="5">Jun</asp:ListItem> <asp:ListItem Value="6">Jul</asp:ListItem> <asp:ListItem Value="7">Aug</asp:ListItem> <asp:ListItem Value="8">Sep</asp:ListItem> <asp:ListItem Value="9">Oct</asp:ListItem> <asp:ListItem Value="10">Nov</asp:ListItem> <asp:ListItem Value="11">Dec</asp:ListItem> </asp:DropDownList> <asp:DropDownList id="year" runat="server" > <asp:ListItem>2013</asp:ListItem> <asp:ListItem>2014</asp:ListItem> <asp:ListItem>2015</asp:ListItem> <asp:ListItem>2016</asp:ListItem> <asp:ListItem>2017</asp:ListItem> <asp:ListItem>2018</asp:ListItem> <asp:ListItem>2019</asp:ListItem> </asp:DropDownList> subscription end on <label id="enddate"></label> </form> </body> </html>Anup Das Gupta
Mark as Answer if you feel so. Visit My Blog
atul2430
Member
141 Points
557 Posts
Re: jquery for avoid postback
Jan 18, 2013 07:47 AM|LINK
$("input[id*=year]")atul2430
Member
141 Points
557 Posts
Re: jquery for avoid postback
Jan 18, 2013 08:04 AM|LINK
Its not working.
date is not displaying in lable.
atul2430
Member
141 Points
557 Posts
Re: jquery for avoid postback
Jan 18, 2013 10:02 AM|LINK
hello anup,
i check the code which you provie me but calculate function is not working.
kindly lookinto this
plz
atul2430
Member
141 Points
557 Posts
Re: jquery for avoid postback
Jan 18, 2013 10:21 AM|LINK
in below function
function calculateEnd() {
var dateval = new Date();
dateval.setYear($('#<%=ddlFSYear.ClientID %>').val()); // value is not going to be set on dateval
dateval.setMonth($('#<%=ddlfsmonth.ClientID %>').val()); // value is not going to be set on dateval
dateval.setDate($('#<%=ddlfsdate.ClientID %>').val()); // value is not going to be set on dateval
var val = 0;
if ($('#<%=cb1year.ClientID %>')[0].checked)
val = 1;
else if ($('#<%=cb2year.ClientID %>')[0].checked)
val = 2;
else if ($('#<%=cb3year.ClientID %>')[0].checked)
val = 3;
else if ($('#<%=cballyear.ClientID %>')[0].checked)
val = 10;
dateval.setYear(dateval.getFullYear()+ val);
dateval.setMonth(dateval.getMonth() - 1);
$('#<%=LblFSmonth.ClientID%>').html(dateval.getDate() + "/" + (dateval.getMonth() + 1) + "/" + dateval.getFullYear());
}
atul2430
Member
141 Points
557 Posts
Re: jquery for avoid postback
Jan 19, 2013 04:01 AM|LINK
Hey Anup problem gets resolved. below is the func. which i modify. hrtly thanks
<%-- // date calculator--%>
<script type="text/javascript">
$(document).ready(function() {
$("input[id*=cb1year]").click(function() {
calculateEnd();
})
$("input[id*=cb2year]").click(function() {
calculateEnd();
})
$("input[id*=cb3year]").click(function() {
calculateEnd();
})
$("input[id*=cballyear]").click(function() {
calculateEnd();
})
$('#<%=ddlfsdate.ClientID %>, #<%=ddlfsmonth.ClientID %>, #<%=ddlFSYear.ClientID %>').change(function() {
calculateEnd();
})
});
function calculateEnd() {
var months = new Array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
var dateval = new Date();
dateval.setYear($('#<%=ddlFSYear.ClientID %>').val());
dateval.setMonth($('#<%=ddlfsmonth.ClientID %>').val());
var val = 0;
if ($('#<%=cb1year.ClientID %>')[0].checked)
val = 1;
else if ($('#<%=cb2year.ClientID %>')[0].checked)
val = 2;
else if ($('#<%=cb3year.ClientID %>')[0].checked)
val = 3;
else if ($('#<%=cballyear.ClientID %>')[0].checked)
val = 10;
else
val = 0;
if (val > 0) {
dateval.setYear(dateval.getFullYear() + val);
dateval.setMonth(dateval.getMonth() - 1);
$('#<%=LblFSmonth.ClientID%>').html(months[(dateval.getMonth())] + " - " + dateval.getFullYear());
}
else
$('#<%=LblFSmonth.ClientID%>').html("");
}
</script>
atul2430
Member
141 Points
557 Posts
Re: jquery for avoid postback
Jan 19, 2013 07:01 AM|LINK
Hi all,
Greetings as i am new in jquery. i want to avoid post back while selecting on countryi have two dropdown one is country and another is stateif i select country other than india state dropdown should be disable.
Below Code is working but after select india state in not getting enable
<script type="text/javascript">
$(function() {
$('#<%=cmbCountry.ClientID %>').click(function(e) {
var ddlstate = $('#<%= cmbState.ClientID%>');
if ($(this).children("option").filter(":selected").text() == 'india') {
ddlstate.removeAttr('disabled');
} //...bind state dropdown code here }
else {
ddlstate.attr('disabled', true);
}
});
});
</script>