Advertisement
Guest User

Untitled

a guest
Nov 26th, 2014
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.72 KB | None | 0 0
  1. @model FindRecipeProject.Models.Recipe
  2.  
  3. @{
  4.     ViewBag.Title = "Create";
  5. }
  6.  
  7. <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
  8. <script type="text/javascript">
  9.     $(document).ready(function () {
  10.  
  11.         var counter = 2;
  12.  
  13.         $("#addbtn").click(function () {
  14.  
  15.             if (counter > 10) {
  16.                 alert("You can Select Only 10  Subjects \n In one Session ");
  17.                 return false;
  18.             }
  19.  
  20.             var newTextBoxDiv = $(document.createElement('div')).attr("id", 'TextBoxDiv' + counter);
  21.             newTextBoxDiv.after().html('<label>Field #' + counter + ' : </label>' +
  22.                 '<input type="text" name="TextBox A ' + counter +
  23.                 ' value="" id="subj' + counter + '">' + '&nbsp;' + '<input type="text" name="TextBox B ' + counter +
  24.                 ' value="" size="5"  id="fee' + counter + '">'
  25.  
  26.  
  27.  
  28.                                       );
  29.  
  30.  
  31.             newTextBoxDiv.appendTo("#TextBoxesGroup");
  32.  
  33.             counter++;
  34.         });
  35.  
  36.         $("#removeButton").click(function () {
  37.             if (counter == 1) {
  38.                 alert("No more textbox to remove");
  39.                 return false;
  40.             }
  41.             counter--;
  42.  
  43.             $("#TextBoxDiv" + counter).remove();
  44.         });
  45.  
  46.         $("#getButtonValue").click(function () {
  47.  
  48.             var msg = '';
  49.             for (i = 1; i < counter; i++) {
  50.                 msg += "subj" + i + " : " + $('#subj' + i).val();
  51.                 msg += " ";
  52.                 msg += "fee" + i + " : " + $('#fee' + i).val();
  53.                 msg += ", ";
  54.             }
  55.             alert(msg);
  56.         });
  57.  
  58.     });
  59. </script>
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67. <h2>Create</h2>
  68.  
  69.  
  70.  
  71.  
  72.  
  73. @using (Html.BeginForm("Create", "Recipe", FormMethod.Post, new { enctype = "multipart/form-data"}))
  74. {
  75.     @Html.AntiForgeryToken()
  76.     @Html.ValidationSummary(true)
  77.  
  78.     <fieldset>
  79.         <legend>Recipe</legend>
  80.  
  81.         <div class="editor-label">
  82.             @Html.LabelFor(model => model.RecipeName)
  83.         </div>
  84.         <div class="editor-field">
  85.             @Html.EditorFor(model => model.RecipeName)
  86.             @Html.ValidationMessageFor(model => model.RecipeName)
  87.         </div>
  88.  
  89.         <div class="editor-label">
  90.             @Html.LabelFor(model => model.RecipeTime)
  91.         </div>
  92.         <div class="editor-field">
  93.             @Html.EditorFor(model => model.RecipeTime)
  94.             @Html.ValidationMessageFor(model => model.RecipeTime)
  95.         </div>
  96.  
  97.         <div class="editor-label">
  98.             @Html.LabelFor(model => model.UserId, "userProfile")
  99.         </div>
  100.         <div class="editor-field">
  101.             @Html.DropDownList("UserId", String.Empty)
  102.             @Html.ValidationMessageFor(model => model.UserId)
  103.         </div>
  104.  
  105.         <div class="editor-label">
  106.             @Html.LabelFor(model => model.Picture)
  107.         </div>
  108.         <div class="editor-field">
  109.             <input name="ImageFile" type="file" />
  110.             @Html.ValidationMessageFor(model => model.Picture)
  111.         </div>
  112.  
  113.         <p>
  114.             <input type="submit" value="Create" />
  115.         </p>
  116.     </fieldset>
  117.  
  118. }
  119.  
  120. <div>
  121.     @Html.ActionLink("Back to List", "Index")
  122. </div>
  123.  
  124.  
  125. <input type='button' value='Add Subject' id='addbtn'>
  126. <input type='button' value='Remove Subject' id='removeButton'>
  127. <input type="button" id="getButtonValue" value="Get TextBox Value">
  128. <div id='TextBoxesGroup'>
  129.     <div id="TextBoxDiv1">
  130.         <label>Subject 1 :</label>
  131.         <input class="textbox" type='text' name="subj1" id="subj1" />&nbsp;
  132.         <input class="textbox" type='text' size="5" name="fee1" id="fee1" />
  133.     </div>
  134. </div>
  135.  
  136.  
  137. @section Scripts {
  138.     @Scripts.Render("~/bundles/jqueryval")
  139. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement