I have database like this:
How I can set all row into label or hiddenfield, ?
if I use code like this, i just get last data from row database.
While (result.Read())
Label1.Text = result.Item("StartDateBlock")
Label2.Text = result.Item("StartDateBlock")
Label3.Text = result.Item("StartDateBlock")
Label4.Text = result.Item("StartDateBlock")
End While
please don't suggest me to use repeater
Related
I am creating admin panel in website and I am using firebase as a database in backend.I am able to display listing but when I click on the particular listing there status should change from 'pending' to 'accept' but it doesnt.I dont know where I did mistake.Please give suggestion and I attach js file and database screenshot
pl.js
var firebaseheadingRef = firebase.database().ref().child("user");
firebaseheadingRef.on('child_added',datasnapshot=>{
var title= datasnapshot.child("listing").child("title").val();
var userid= datasnapshot.child("username").val();
var type= datasnapshot.child("listing").child("title").val();
var publisheddate= datasnapshot.child("listing").child("publish").val();
var expirydate= datasnapshot.child("listing").child("expire").val();
$("#tablebody").append("<tr><td>"+title+"</td><td>"+userid+"</td><td>"+type+"</td><td>"+publisheddate+"</td><td><button type=button id=accept onclick=accept()>Accept</button><button type=button>Reject</button></td></tr>");
});
function accept()
{
firebaseheadingRef.on('child_changed',datasnapshot=>{
datasnapshot.child("listing").child("status").update({"status":"accept"});
setCommentValues(postElement, data.key, data.val().text, data.val().author);
});
}
database
listing display picture where I click on accept button then update of status should done
There are two places where you need to change your code:
First, in the code that generates the table, you have to pass the id of the node to the function call, as follows. You get the node id with the key property of the DataSnapshot.
.....
$("#tablebody").append("<tr><td>"+title+"</td><td>"+userid+"</td><td>"+type+"</td><td>"+publisheddate+"</td><td><button type=button id=accept onclick=accept('" + datasnapshot.key + "')>Accept</button><button type=button>Reject</button></td></tr>");
...
And secondly you have to write your accept() function in such a way it updates the database value, with the set() method. Like the following
function accept(userId) {
var nodeRef = firebase.database().ref("/user/" + userId + "/listing/status");
return nodeRef.set('accept');
}
I'm working in asp mvc c#
Now in my acp panel I have a dropdownlist:
#Html.DropDownList("id", new SelectList(ViewBag.DruhyOdznaku, "Id", "Name"), new {#onchange = "functionChange()", #class = "form-control", id = "ddlViewBy"})
I can access the name value of selected item from JS like:
function functionChange() {
var e = document.getElementById("ddlViewBy");
var finalData = e.options[e.selectedIndex];
}
Now the problem is I want to keep displaying name in the dropdown but obtain another value - in this case "Text" (from db).
How can I attach this data to the dropdown (ideally keep the way it's created) and then get them from js? Spent a day on this, my sanity going low.
Thanks a milion for help.
You can add a "data-" attribute on options. Have a look at this to see how to SelectListItem with data-attributes
But that "ideally keep the way it's created" is not going to hold.
Then you can have something like this:
$(document).ready(function(){
$("#sel").change(function(){
var selectedOption = $(this).find("option:selected");
alert(selectedOption.attr("value") + "/" +
selectedOption.data("text") + "/" +
selectedOption.html() );
})
})
I have user editable table at front end. when user click process button, i am doing form validation in jquery from there i am passing flow to servlet, So i have to pass the bunch of table data to servlet. Some one please suggest me on how to pass all table data in ajax call. Currenly i have a piece of code which contains table data in array where i can get as each cell values. instead of that i wanna pass it in row manner
var InspTableArray = [];
$("#tab_logic tr.data").map(function (index, tr) {
$(this).find('td').each(function(){
var $data = $(this).html();
if($(this).find("select").length > 0) {
var $x = $(this).find("select").val();
}else{
var $x = $(this).find("input[type='text']").val();
}
InspTableArray.push($x);
});
});
I'd suggest using jQuery post method https://api.jquery.com/jquery.post/:
$.post('/url/to/page', {'arrayFieldName': InspTableArray} );
In my view I have this Javascript code that gets the data from a selected row from a table, puts it in a localStorage then display the data on the page.
For visualization here is what it looks like
By default, the "Assign Grade" section is hidden and it will be only show when the user clicks the edit button on the table rows. The data from the row would then be showed on the left side of the "Assign Grade" panel. On the background what I did was when the user clicked edit I stored the Record ID inside a localstorge
My Javascript code:
$("#gPanel").slideDown(350);
var index = x.rowIndex;
var tbl = document.getElementById("detailTable");
var ri = tbl.rows[index].cells[0].innerHTML;
var sy = tbl.rows[index].cells[1].innerHTML;
var sq = tbl.rows[index].cells[2].innerHTML;
var si = tbl.rows[index].cells[3].innerHTML;
var sn = tbl.rows[index].cells[4].innerHTML;
localStorage.recid = ri;
//more
document.getElementById("rid").innerHTML = ri;
//more
Because I need that Record ID when the "record grade" button on the "Assign Grade" panel is clicked.
Is there a way to access localStorage inside Laravel 4.2 controller? Or is there a better way to do it?
I'm using chap links library https://github.com/almende/chap-links-library/tree/master/js/src/network for drawing an area of objects.
I want to be able to use the id that I have set to an object upon click, I have this code
function onselect() {
var sel = network.getSelection();
console.log("selected "+sel[0].row);
}
It works fine, only it retrieves the row number from the dynamically created table. I want to retrieve a value from that row (an object id that I set) but I don't know how to access it.
I have tired things like
sel[0].row.id
sel[0].row.getId()
sel[0].row[0]
But I don't know how they structure the data in their thing...
Anyonw run into this before and solved it?
This is the way I set the data
nodesTable.addRow([45, "myObjectName", "image", "images/container_icons/icon.png"]);
For my app I solved it by creating a parallel array...
//rendera objekt
window.clickHelper = []; //keep track of container id in conjunction with hierarchy-canvas-object's id
var i = 0; //counter for above
Populating it upon every node creation...
nodesTable.addRow([{{ c.id }}, "{{ c.name }}", "image", "{{ asset('images/container_icons/'~c.icon~'.png') }}"]);
clickHelper[i]={{c.id}};
i++;
Then calling in data from that array on my onSelect event...
function onselect() {
//get selected node from network
var sel = network.getSelection();
sel = sel[0].row;
//get path base structure
var path = '{{ path('editGroup') }}';
//fix path with the DB id of the clicked object
path = path+clickHelper[sel];
window.location.href = path;
}
The double {{ }} are TWIG templating for those unfamiliar with that. Mixed javascript and TWIG ServerSide code here, sorry.