|
Now it works perfectly!
Thank you very sir for always coming to the rescue.
Much appreciated.
|
|
|
|
|
How to create edit button to table that is being created dynamically so as to edit the row of a table.
|
|
|
|
|
Create the button as part of the row and have within the buttons attributes appropriate references to it's particular content.
This is a very important technique and I suggest strongly you master the concept of creating references to items concurrently with creating the item.
Ravings en masse^ |
---|
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein | "If you are searching for perfection in others, then you seek disappointment. If you are seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010 |
|
|
|
|
|
You can use this code....
<html>
<head>
<meta charset="UTF-8">
</head>
<body id="body">
<div id="wrapper">
<table align='center' cellspacing=1 cellpadding=1 id="mytable" border=1>
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Action</th>
</tr>
</thead>
<tbody id="tbody">
</tbody>
</table>
</div>
<button onclick='display()'> Display</button>
<!--<script src="get-text.js"></script>-->
</body>
</html>
<script>
var myArray = [{ "name": "aaa", "level": "A" }, { "name": "bbb", "level": "B" }, { "name": "ccc", "level": "C" }];
function display() {
var length = myArray.length;
var htmltext = "";
for (var i = 0; i < length; i++) {
console.log(myArray[i]);
htmltext += "<tr id='table"+i+"'><td>"
+myArray[i].name+
"</td><td>"
+myArray[i].level+
"</td><td><button onclick='edit("+i+")'>Edit</button><button onclick='remove("+i+")'>Remove</button></td></tr>";
}
document.getElementById("tbody").innerHTML = htmltext;
}
function edit(indice) {
var htmltext = "<tr><td><input id='inputname"+indice+"' type='text' value='"
+myArray[indice].name+
"'></td><td><input id='inputlevel"+indice+"' type='text' value='"
+myArray[indice].level+
"'></td><td><button onclick='save("+indice+")'>Save</button><button onclick='remove("+indice+")'>Remove</button></td></tr>";
document.getElementById("table"+indice).innerHTML = htmltext;
}
function save(indice) {
myArray[indice].name = document.getElementById("inputname"+indice).value;
myArray[indice].level = document.getElementById("inputlevel"+indice).value;
var htmltext = "<tr id='table"+indice+"'><td>"
+myArray[indice].name+
"</td><td>"
+myArray[indice].level+
"</td><td><button onclick='edit("
+indice+")'>Edit</button><button onclick='remove("
+indice+")'>Remove</button></td></tr>";
document.getElementById("table"+indice).innerHTML = htmltext;
}
function remove(indice) {
console.log(myArray);
myArray.splice(indice, 1);
display();
}
</script>
modified 6-Nov-19 2:31am.
|
|
|
|
|
Hi there,
I need to insert blank pages in a large PDF doc only once after it finds a specific word on that page and is odd.
For eg: If the page has the word "Print this document" and the page number is 5, then insert a blank page only after it.
If the page has the word "Print this document" and the page number is 6, then insert a blank page before and after it.
If the page does not have the word "Print this document", do nothing.
The code sounds simple but I am just not sure.
Thanks if anyone could help would really appreciate it.
|
|
|
|
|
Are you sure you are going to do this in JavaScript?
|
|
|
|
|
Yes Richard. I am using the JavaScript function in Adobe. Its just that I am not too familiar with find the text in a document, and then insert pages.
|
|
|
|
|
In that case I would suggest studying the Adobe documentation.
|
|
|
|
|
Hi greeting to the comunity!!
I´m trying to display the info from a array json dinamically into an html table, but I'm dont really undertand what I`m doing wrong
so, I`m taking three columns from my MySql Table (Name,city and Provinz),so I need a row for each row of my sql table, if a obtain three rows , that is in total 9 cells,ordered in three rows, 3 each..
onload() on body calls the function
function verDetalleNegocio(){
var localidad=getLocalidad();
var negocio=getNegocio();
var datos={'loc':localidad,'neg':negocio};
var datosS=JSON.stringify(datos);
if(localidad!=="" && negocio!==""){
$.ajax({
type:"POST",
data:"datos="+datosS,
dataType:'json',
cache:false,
url:"<?=$this->basePath("web/negocios/detallenegocioajax")?>",
success:function(datos){
var celdas=datos.length;
var filas=celdas/3;
for(i=0;i<datos.length;i++)
{
$("#tabdat").append("<tr>");
$("#tabdat").append("<td>"+datos[i]+"</td>");
$("#tabdat").append("</tr>");
}
}
});
}else{
return null;
}
}
here, I habe my html table:
</head>
<body onload="verDetalleNegocio()">
<table id="tabdat" class="tablaNeg" border=1>
<thead>
<tr>
<th>Nombre</th>
<th>Localidad</th>
<th>Provincia</th>
</tr>
</thead>
<tbody></tbody>
</table>
</body>
and finally, thatt the way the results are display, I would like to show the rows, one on top of the other, and not one next to the other, hoy could say in the iteration, every three, a new row!!!
Thanks!!!
Nombre Localidad Provincia
Naviera Riazor La Coruña La Coruña Barcos Texeiro La Coruña La Coruña Barcos de Vela Riazor La Coruña La Coruña
|
|
|
|
|
It looks like you are creating a new row for each item in the code:
for(i=0;i<datos.length;i++)
{
$("#tabdat").append("<tr>");
$("#tabdat").append("<td>"+datos[i]+"</td>");
$("#tabdat").append("</tr>");
}
You should move the <tr> tags outside the loop thus:
$("#tabdat").append("<tr>");
for(i=0;i<datos.length;i++)
{
$("#tabdat").append("<td>"+datos[i]+"</td>");
}
$("#tabdat").append("</tr>");
|
|
|
|
|
Hi!!
thanks a lot for your reply!!
unfortunatelly, after the changes you proposed me, I get the same result
I`ll keep trying!!
|
|
|
|
|
It would help us if you showed the actual code you use, and the HTML that is produced when you run it. You can edit your question and add the update information.
|
|
|
|
|
Hi again!!
thanks for your reply, so I put it down the proposal of a colleage from stackoverflow...there I posted the same question..
so the json array comes from the controller, filtered with json_encode();, this is the copy paste from the Chome debugger..so as you can see, I want to display the array of 9 positions in three
rows one under other, and each with three cells..
0: "Naviera Riazor"
1: "La Coruña"
2: "La Coruña"
3: "Barcos Texeiro"
4: "La Coruña"
5: "La Coruña"
6: "Barcos de Vela Riazor"
7: "La Coruña"
8: "La Coruña"
length: 9
this is the table, with a script, that I dont know if is "key" so that everything goes good..
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<table id="tabdat" border=1 style="margin-top: 300px;">
<thead>
<tr>
<th>Nombre</th>
<th>Localidad</th>
<th>Provincia</th>
</tr>
</thead>
<tbody></tbody>
</table>
</body>
and here is the function verDetalleNegocio(), that I invoke on the body with the onload method, inside I do the
loop, and try to display on the #tabdat, under...
function verDetalleNegocio(){
var localidad=getLocalidad();
var negocio=getNegocio();
var datos={'loc':localidad,'neg':negocio};
var datosS=JSON.stringify(datos);
if(localidad!=="" && negocio!==""){
$.ajax({
type:"POST",
data:"datos="+datosS,
dataType:'json',
cache:false,
url:"<?=$this->basePath("web/negocios/detallenegocioajax")?>",
success:function(datos){
html = "";
for(i=0; i<datos.length; i++){
html += "<tr>"
html += "<td>"+datos[i]+"</td>";
html += "<td>"+datos[i]+"</td>";
html += "<td>"+datos[i]+"</td>";
html += "</tr>";
}
$("#tabdat tbody").append(html);
}
});
}else{
return null;
}
}
and finally the result that I obtain on the screen..as you can see, the information is displayed twice...please, tell me If i can put more infomation...thanks
Nombre Localidad Provincia
Naviera Riazor Naviera Riazor Naviera Riazor
La Coruña La Coruña La Coruña
La Coruña La Coruña La Coruña
Barcos Texeiro Barcos Texeiro Barcos Texeiro
La Coruña La Coruña La Coruña
La Coruña La Coruña La Coruña
Barcos de Vela Riazor Barcos de Vela Riazor Barcos de Vela Riazor
La Coruña La Coruña La Coruña
La Coruña La Coruña La Coruña
|
|
|
|
|
Look at your code, in the loop you are printing the same item html += "<td>"+datos[i]+"</td>"; three times. I showed you what the code should be in my original response.
|
|
|
|
|
Hi!!
thanks for your reply..you`re right...
now I changed the format of the array, and now its like this:
0: ["Naviera Riazor"]
1: {1: "La Coruña"}
2: {2: "La Coruña"}
3: ["Barcos Texeiro"]
4: {1: "La Coruña"}
5: {2: "La Coruña"}
6: ["Barcos de Vela Riazor"]
7: {1: "La Coruña"}
8: {2: "La Coruña"}
length: 9
The problem is, that I dont find the way to display properly the info in the html, table,I tryed with a double loop, first for, and secon inner do...while, and two for consecutives, thats mean one inside the other..but It doesn`t work...to ne honest, sometimes I think I'm doing it very complicated, maybe there is another way to do it more simple..
var html="";
var celdas=datos.length;
var filas=celdas/3;
var cont=0;
for(f=0;f<filas;f++)
{
do{
html+="<tr>";
html+="<td>"+datos[f][cont]+"</td>";
html+="</tr>";
cont++;
}while(cont<=2);
}
$("#tabdat tbody").append(html);
Thanks!!
|
|
|
|
|
Loo,k at the data and decide how many items you want in each row. You then can set the values for your loop. For each iteration of the loop:
1. Emit a <tr> element.
2. Emit a <td> followed by the first data item, followed by </td>
3. Repeat number 2 for each remaining data item.
4. Emit a </tr> item for the end of the row.
|
|
|
|
|
Every time I try to change the color for the text "You qualify for Free Shipping!
the script breaks.
can someone please write it in for me to show me where it goes?
Im trying to turn it Green
thank you
DEX
<br><script>
var freeship = 65;
var total = "[CARTTOTAL]";
var totalnum = total.replace("$", "");
if (totalnum < freeship){
rounded = Math.round((freeship - totalnum)*100)/100;
document.write(" <div align=left><h1><strong><span class=price-alt>Only $");
document.write(rounded.toFixed(2) + " ");
document.write("more and you qualify for Free Shipping! </span></div><br>");
} else { document.write("<div align=left><h1><strong> You qualify for Free Shipping! </strong></h1></div><br>");
}
</script>
|
|
|
|
|
In the first set you have unclosed <strong> and <h1> tags.
|
|
|
|
|
I don't understand why you sent me a private email with the same information. I have explained what looks incorrect so you need to fix that first.
|
|
|
|
|
I'm looking for documentation engine for API reference, tutorials and product blog with the following requirements:
- Implemented in JS and has JS API
- Generates static content
- Support themes
- Does not require accounts but Github, so Gitbook with their migration to his own commercial service is just a shame
- Well designed, created by developers for developers
- Has live community, tutorials and documentation
|
|
|
|
|
Hi,
I have a Pin Code verification field, in which I am using an invalid input regular Expression, but I want to have check for min of 4 characters in it. Here are my invalid characters:
Name: "InvalidCharacters", Expression: '([<>_={};|\\[\\]^])'
I want to have another Regular Expression validator which doesn't allow above characters and checks for min of 4 and max 40 characters, any help would be greatly helpful, thanks in advance.
modified 12-Mar-19 14:22pm.
|
|
|
|
|
|
Can I use two regular expressions on one field in html?
Some how I could able to put the below attribute in the input text, it shows red mark when the number of characters are less than 4 but it doesn't show me the message:
pattern=".{4,40}"
Any idea would be very very helpful, thanks
What I have to achieve is to display the message smartly depending upon the failing regex, there are two checks, 1 is invalid characters and when the focus is out of textbox, if length is less than 4 characters, then, it should display message saying, minimum length is 4 characters.
Currently its working for invalid characters as below:
<div class="field-validation-error" *ngIf="pinCodeInput.errors !== null && pinCodeInput.errors.regexValidator">
{{ 'OnlineRegistrationView.Validator.PinCodeInvalidCharacters' | Translate }}
</div>
modified 12-Mar-19 14:37pm.
|
|
|
|
|
I don't know what that pattern represents. Did you follow the link I gave you and look at some of the samples? The simplest patter would be \d\d\d\d .
|
|
|
|
|
Yes I did, but displaying the message depending upon the error that happens, like if invalid characters different error message, if not meeting the min length different message, any help buddy?
There is another question I have, I went into the link that you sent me, how can I get the regular expressions that I want, I tried to search using pin, pincode etc keywords, didn't help me, am I not using the link that you sent me properly buddy?
|
|
|
|
|