Jump to content

wrb

Members
  • Posts

    40
  • Joined

  • Last visited

wrb's Achievements

Newbie

Newbie (1/7)

0

Reputation

  1. Anyone have any suggestions? In the code below returns with error when taking delete a table record: SCRIPT: $("#add").click(function () { $.ajax({ url: '@Url.Action("AddProduto", "Produto")', type: "POST", data: $('#formprod').serializeArray(), success: function (data) { if (data.success) { $('#tabelaproduto > tbody:last').append('<tr style="font-size:10px">' + '<td hidden>' + data.id + '</td>' + '<td>' + data.descricao + '</td>' + '<td>' + '<input type="image" src="/Images/excluir.png" onclick="clicado(this)">' + '</td>' + '</tr>'); $('#formprod')[0].reset(); $("#validacaoproduto").html(""); } else { $("#validacaoproduto").html(data.msg); } } }); return false; }); function clicado(a) { console.log($(a).closest('tr')[0].rowIndex); var linhaIndex = $(a).closest('tr')[0].rowIndex; var codigo = $(a).closest('tr').children('td')[0].innerText; $.ajax({ url: '@Url.Action("DelProduto", "Produto")', type: "POST", contentType: 'application/json; charset=utf-8', data: { codigo: codigo }, success: function (data) { document.getElementById("tabelaproduto").deleteRow(linhaIndex); console.log("ok"); } }); } ERROR: <!DOCTYPE html> <html> <head> <title>Invalid JSON primitive: codigo.</title> <meta name="viewport" content="width=device-width" /> <style> body {font-family:"Verdana";font-weight:normal;font-size: .7em;color:black;} p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px} b {font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px} H1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red } H2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon } pre {font-family:"Consolas","Lucida Console",Monospace;font-size:11pt;margin:0;padding:0.5em;line-height:14pt} .marker {font-weight: bold; color: black;text-decoration: none;} .version {color: gray;} .error {margin-bottom: 10px;} .expandable { text-decoration:underline; font-weight:bold; color:navy; cursor:hand; } @media screen and (max-width: 639px) { pre { width: 440px; overflow: auto; white-space: pre-wrap; word-wrap: break-word; } } @media screen and (max-width: 479px) { pre { width: 280px; } } </style> </head> <body bgcolor="white"> <span><H1>Server Error in '/' Application.<hr width=100% size=1 color=silver></H1> <h2> <i>Invalid JSON primitive: codigo.</i> </h2></span> <font face="Arial, Helvetica, Geneva, SunSans-Regular, sans-serif "> <b> Description: </b>An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. <br><br> <b> Exception Details: </b>System.ArgumentException: Invalid JSON primitive: codigo.<br><br> <b>Source Error:</b> <br><br> <table width=100% bgcolor="#ffffcc"> <tr> <td> <code> An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.</code> </td> </tr> </table> <br> <b>Stack Trace:</b> <br><br> <table width=100% bgcolor="#ffffcc"> <tr> <td> <code><pre> [ArgumentException: Invalid JSON primitive: codigo.]
  2. Anyone have any suggestions? In the code below returns with error when taking delete a table record: SCRIPT: $("#add").click(function () { $.ajax({ url: '@Url.Action("AddProduto", "Produto")', type: "POST", data: $('#formprod').serializeArray(), success: function (data) { if (data.success) { $('#tabelaproduto > tbody:last').append('<tr style="font-size:10px">' + '<td hidden>' + data.id + '</td>' + '<td>' + data.descricao + '</td>' + '<td>' + '<input type="image" src="/Images/excluir.png" onclick="clicado(this)">' + '</td>' + '</tr>'); $('#formprod')[0].reset(); $("#validacaoproduto").html(""); } else { $("#validacaoproduto").html(data.msg); } } }); return false; }); function clicado(a) { console.log($(a).closest('tr')[0].rowIndex); var linhaIndex = $(a).closest('tr')[0].rowIndex; var codigo = $(a).closest('tr').children('td')[0].innerText; $.ajax({ url: '@Url.Action("DelProduto", "Produto")', type: "POST", contentType: 'application/json; charset=utf-8', data: { codigo: codigo }, success: function (data) { document.getElementById("tabelaproduto").deleteRow(linhaIndex); console.log("ok"); } }); } ERROR: <!DOCTYPE html> <html> <head> <title>Invalid JSON primitive: codigo.</title> <meta name="viewport" content="width=device-width" /> <style> body {font-family:"Verdana";font-weight:normal;font-size: .7em;color:black;} p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px} b {font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px} H1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red } H2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon } pre {font-family:"Consolas","Lucida Console",Monospace;font-size:11pt;margin:0;padding:0.5em;line-height:14pt} .marker {font-weight: bold; color: black;text-decoration: none;} .version {color: gray;} .error {margin-bottom: 10px;} .expandable { text-decoration:underline; font-weight:bold; color:navy; cursor:hand; } @media screen and (max-width: 639px) { pre { width: 440px; overflow: auto; white-space: pre-wrap; word-wrap: break-word; } } @media screen and (max-width: 479px) { pre { width: 280px; } } </style> </head> <body bgcolor="white"> <span><H1>Server Error in '/' Application.<hr width=100% size=1 color=silver></H1> <h2> <i>Invalid JSON primitive: codigo.</i> </h2></span> <font face="Arial, Helvetica, Geneva, SunSans-Regular, sans-serif "> <b> Description: </b>An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. <br><br> <b> Exception Details: </b>System.ArgumentException: Invalid JSON primitive: codigo.<br><br> <b>Source Error:</b> <br><br> <table width=100% bgcolor="#ffffcc"> <tr> <td> <code> An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.</code> </td> </tr> </table> <br> <b>Stack Trace:</b> <br><br> <table width=100% bgcolor="#ffffcc"> <tr> <td> <code><pre> [ArgumentException: Invalid JSON primitive: codigo.]
  3. How do I get the selected datepicker below and populate a label? @Html.JQueryUI().Datepicker("data1", null, new { id = "data1", @class = "form-control" })
  4. wrb

    Return ages.

    From a textbox with the date of birth as return label in ages in weeks, months and years.
  5. How can I make the DropDownList appear only item from a particular id = Med_Produto? Controller: ViewBag.cod_Med= new SelectList(db.Prod_Med, "id", "descricao"); View: @Html.DropDownList("cod_Med", null, String.Empty, new { id = "Med_Produto", name = "cod_Med", @class = "form-control" }) Example: id> 38
  6. I need to return 2 places after the comma: $("#preco2").val(preco * percent); From: 57.15000000 for: 57.15
  7. How do I return with 2 places after the comma?
  8. Hi, how to calculate a percentage increase? I have 3 fields to when entering a value in the second the third returns with the result. I tried the code below, but nothing appears on preco2 field. <div class="editor-field col-md-7"> @Html.TextBoxFor(model => model.preco1, new { id = "preco1", name = "preco1", @class = "form-control" }) </div> <div class="editor-field col-md-7"> @Html.TextBoxFor(model => model.percentual, new { id = "percentual", name="percentual", @class = "form-control", placeholder = "1.00" }) </div> <div class="editor-field col-md-7"> @Html.TextBoxFor(model => model.preco2, new { id = "preco2", name = "preco2", @class = "form-control" }) </div> <script> $("#percentual").change(function () { preco= document.getElementById("#preco1").value; percent = document.getElementById("#percentual").value; document.getElementById("#preco2").innerHTML = preco * percent; }); </script>
  9. Yes, when the select has only one item.
  10. See It. The graph is right, the URL this right. The problem is the event when the select receives a graphic value must render. In fact I do not know if the path is with the post code. Lack knowledge in JavaScript...
  11. I changed the code because I did not find the error ... The "onchange" sends the value and renders the chart. The URL is correct, it is the place of animals I put 1 for example, the chart is rendered.
  12. I was with an event in select "onchange" as below, but in the select has only one item I not I the desired effect. I need to render the chart being the select filled. <form action=""> @Html.DropDownList("cod_animal", null, new { onchange = "drawchart(this.value)", Name = "cod_animal", id = "cod_animal", @class = "form-control" }) </form> <script type="text/javascript"> google.load('visualization', '1.1', { 'packages': ['corechart'] }); google.setOnLoadCallback(function(){drawchart('')}); function drawchart(cod_animal) { var url = '/Programa_Nutricao/Avaliacao/EvolucaoPeso/' + cod_animal; $.get(url, {}, function (data) { var tdata = new google.visualization.DataTable(); tdata.addColumn('date', 'data_semanal'); tdata.addColumn('number', 'peso_kg'); for (var i = 0; i < data.length; i++) { if (data.data_semanal != null) tdata.addRow([ToJavaScriptDate(data.data_semanal), parseFloat(data.peso_kg)]); } var options = { title: 'Evolução do peso corporal', width: 700, height: 500, vAxis: { title: "PESO (kg)", minValue: 1, maxValue: 6 }, hAxis: { title: "DATA", textStyle: { fontSize: 10 } }, legend: { position: "none" } }; var chart = new google.visualization.LineChart(document.getElementById('EvolucaoPeso')); chart.draw(tdata, options); }); } </script>
  13. In the code below I need to select an item in the "select" the graphic is rendered, how could implement this? @using (Html.BeginForm()){ @Html.AntiForgeryToken() @Html.ValidationSummary(true)<select id="animais" name="cod_animal" class="form-control"></select><script type="text/javascript"> //google.load('visualization', '1.1', { 'packages': ['corechart'] }); //google.setOnLoadCallback(drawChart); function drawChart() { var frm = document.getElementById('#animais'); var animais = frm.options[frm.selectedIndex].value; var url = '/Programa_Nutricao/Avaliacao/EvolucaoPeso/' + animais; $.get(url, {}, function (data) { var tdata = new google.visualization.DataTable(); tdata.addColumn('date', 'data_semanal'); tdata.addColumn('number', 'peso_kg'); for (var i = 0; i < data.length; i++) { if (data[i].data_semanal != null) tdata.addRow([ToJavaScriptDate(data[i].data_semanal), parseFloat(data[i].peso_kg)]); } var options = { title: 'Evolução do peso corporal', width: 700, height: 500, vAxis: { title: "PESO (kg)", minValue: 1, maxValue: 6 }, hAxis: { title: "DATA", textStyle: { fontSize: 10 } }, legend: { position: "none" } }; var chart = new google.visualization.LineChart(document.getElementById('EvolucaoPeso')); chart.draw(tdata, options); }); }</script> <div id="EvolucaoPeso" style="width: 900px; height: 500px;"></div>
×
×
  • Create New...