5
Reply

Disable "Previous button" if I'm at the first page and "Next

Anjali Khan

Anjali Khan

8 years ago
304
hi frnds
 
I am sending to you my code ..
 
m in stuck in this ,Disable "Previous button" if I'm at the first page and "Next button" if I'm at the last page ??
 
please chk and if u hv possible ,so correct this
 
 

<html>

<head>

<meta name="viewport" content="width=device-width" />

<title>BasicDetails</title>

</head>

<body>

<div>

<input type="text" class="details-dialog" disabled="disabled" value="Input Seeting" style="color:red" />

<input type="text" class="details-dialog" disabled="disabled" value="Design Seeting" />

<input type="text" class="details-dialog" disabled="disabled" value="Publish" />

@*<label id="lbl1" class="details-dialog" disabled="disabled" style="color:Red ; width:100%">INPUT SEETING</label>&nbsp;&nbsp;

<label id="lbl2" style="color:maroon ; width:100%">DESIGN SEETING</label>*@

@*<label id="lbl3" style="color:maroon ; width:100%">PUBLISH</label>*@*

</div>

@using (Html.BeginForm())

{

<fieldset>

@*<legend></legend>*@

<div id="label1" style="width:100% ; height:100%">

<div id="div1">

<h4>Basic Details</h4>

@Html.LabelFor(m => m.FirstName)

@Html.TextBoxFor(m => m.FirstName)

@Html.ValidationMessageFor(m => m.FirstName)

<br /><br />

@Html.LabelFor(m => m.LastName)

@Html.TextBoxFor(m => m.LastName)

@Html.ValidationMessageFor(m => m.LastName)

</div>

<div id="div2">

<h4>Address Details</h4>

@Html.LabelFor(m => m.Address)

@Html.TextBoxFor(m => m.Address)

@Html.ValidationMessageFor(m => m.Address)

<br /><br />

@Html.LabelFor(m => m.City)

@Html.TextBoxFor(m => m.City)

@Html.ValidationMessageFor(m => m.City)

</div>

<div id="div3">

<h4>Contact Details</h4>

@Html.LabelFor(m => m.Phone)

@Html.TextBoxFor(m => m.Phone)

@Html.ValidationMessageFor(m => m.Phone)

<br /><br />

@Html.LabelFor(m => m.Mobile)

@Html.TextBoxFor(m => m.Mobile)

@Html.ValidationMessageFor(m => m.Mobile)

<input type="button" value="submit" />

</div>

</div>

</fieldset>

<br />

<input type="button" id="prev" value="PREV" />

<input type="button" id="next" value="NEXT" />

@section Script{

Scripts.Render("~/bundles/jqueryval")

}

}

<script type="text/javascript">

$(document).ready(function () {

// Hide all div

//$("#div2").hide();

//$("#div3").hide();

//$("#div1").hide();

//$("#next").hide();

//$("#prev").hide();

//rough//

// Hide all div

$("#div2").hide();

$("#div3").hide();

$("#div1").show();

$("#next").show();

$("#prev").hide();

// Hide all div

$("#next").click(function () {

$("#div1").show();

$("#next").show();

$("#prev").show();

});

// Hide all div

//$("#spnEmp").click(function () {

// $("#div1").show();

// $("#next").show();

// $("#prev").show();

// });

$("#next").click(function () {

//if ($("#label1 div:visible").nextAll('div').length == 1)

// $("#next").hide();

if ($("#label1 div:visible").next().length != 0)

$("#label1 div:visible").next().show().prev().hide();

else {

$("#label1 div:visible").hide();

$("#label1 div:first").show();

}

return false;

});

$("#prev").click(function () {

if ($("#label1 div:visible").prev().length != 0)

$("#label1 div:visible").prev().show().next().hide();

else {

$("#label1 div:visible").hide();

$("#label1 div:last").show();

}

//if ($("#label1 div:visible").nextAll('div').length > 0)

// $("#next").show();

return false;

});

});

</script>

</body>

</html>


Answers (5)