jquery onclick change image not working, Correct Code i think - onclick

I have a really simple onclick event to change the image of an image in a div, but for whatever reason i keep getting an undefined back instead of the image source.
iv tried every which way around and still had no luck.
can anyone see from the code below where i am going wrong please.
thank you.
$messageid=$row['id'];
<div class='Mimage3'>
<input type='file' class='INimage' id='input3{$messageid}' onClick='showFiles(this , \"image3{$messageid}\" , \"input3{$messageid}\" , {$messageid});' accept='image/*' >
<label for='input3' class='LMimage'>
<img id='image3{$messageid}' class='vimage' src='{$image3}'></img>
</label>
</div>
<script>
function showFiles(thisID, imageID , inputID , messageID ) {
var imageid=imageID; //passed imageID --onclick \"image3\"+{$messageid}
var messageid=messageID; //passed messageID --onclick {$messageid}
var ebm=document.getElementById('editSeller'+messageid+''); //passed messageID --onclick {$messageid}
var inputID=inputID; //passed inputID --onclick \"input3\"+{$messageid}
var input=thisID; //passed thisID --onclick this
console.log('imageid='+imageid); // shows the id correctly
// attempt 1 var imagesrc = $(imageid 'img').attr('src');
// attempt 2 var imagesrc = $('#'+imageid 'img').attr('src');
// attempt 3 var imagesrc = ($imageid).find('img').attr('src'));
// attempt 4 var imagesrc = $(imageid).attr('src');
// attempt 5 var imagesrc = $(imageid).find('img').attr('src');
// attempt 6 var imagesrc = $('#'+imageid).find('img').attr('src');
console.log(imagesrc); // but this returns undefined???
</script>

var imagesrc = $('#' + imageid).attr('src');
oops...
forget to try that 1..

Related

get cookie iframe per console.log

I need get cookie in iframes peer console command in script,
i need help with code:
I'll leave my code to help me if possible:
<div id="test"></div>
<script src="https://www.website.com">
<script>
var getCookies = function(){
var pairs = document.cookie.split(";");
var cookies = {};
for (var i=0; i<pairs.length; i++){
var pair = pairs[i].split("=");
cookies[(pair[0]+'').trim()] = unescape(pair.slice(1).join('='));
}
return cookies;
}
myCookies = getCookies();
console.log("x")
const x = (myCookies)
document.getElementById('test').innerHTML = x
</script>

Using multi filter datatables in asp.net MVC

I'm trying to implement the multiple filters in the datatables in asp.net, but the time I search a value, my table is not updated.
I followed the official example of the site, but it did not work. Here is the source code I'm using.
JS on VIEW
$('#students tfoot th').each( function () {
var title = $(this).text();
if (title !== "") {
$(this).html('<input type="text" class="form-control form-control-sm" style="width: 100%" placeholder="' + title + '" />');
} else {
$(this).html('<div class="text-center">-</div>');
}
} );
tabela.columns().every( function () {
var that = this;
$( 'input', this.header() ).on( 'keydown', function (ev) {
if (ev.keyCode == 13) { //only on enter keypress (code 13)
that
.search( this.value )
.draw();
}
} );
} );
ACTION on CONTROLLER
[HttpPost]
public JsonResult Listar2()
{
var search = Request.Form.GetValues("search[value]")?[0];
var list = db.Students;
if (!string.IsNullOrEmpty(search))
{
list = list.Where(m => m.name.ToLower().Contains(search.ToLower()) || m.class.ToLower().Contains(search.ToLower()));
}
var draw = Request.Form.GetValues("draw")?[0];
var start = Request.Form.GetValues("start")?[0];
var length = Request.Form.GetValues("length")?[0];
var width = length != null ? Convert.ToInt32(length) : 0;
var skip = start != null ? Convert.ToInt32(start) : 0;
var totalRecords = list.Count();
var resultFinal = list.Skip(skip).Take(width).ToList();
return Json(new
{
data = resultFinal,
draw,
recordsFiltered = totalRecords,
recordsTotal = totalRecords
});
}
I don't know what you want to accomplish. The official example uses JavaScript to sort the datatable which is inserted into HTML already. You should load all the entries first, pass them to the view and then this script should filter those entries

Pulling Docs List from Collection

I there a way to display specific collection files and URL in a spreadsheet?
I have already tried running a basic DocList Search script but I need something to be more direct. I would need the script to display File Name, Collections It belongs to, and URL.
The end goal of this project is to create a Google site that allows users to click a Image link launching a simple "Copy Function" this copy function will create a copy of that document for the user in there individual drive. However we will be doing this on a mass scale of over 1,000 documents. So pulling the information and having it more organized would be alot easier then copying the URL section out of each document and then pasting it into the scripts functions.
here is a script I wrote quite a while ago that does (a bit more than ) what you want... it shows the IDs but you can easily change it to show the urls instead.
// G. Variables
var sh = SpreadsheetApp.getActiveSheet();
var ss = SpreadsheetApp.getActiveSpreadsheet();
var lastrow = ss.getLastRow();
//
//
//
function onOpen() {
var menuEntries = [ {name: "generic doclist", functionName: "gendoclisttest"},
{name: "categorized list(spreadsheet/docs)", functionName: "doclistcat"},
{name: "Search DocList", functionName: "searchUI"},
];
ss.addMenu("Utilities", menuEntries);//
}
//
// Build a simple UI to enter search item and show results + activate result's row
function searchUI() {
var app = UiApp.createApplication().setHeight(130).setWidth(400);
app.setTitle("Search by name or folder name");
var panel = app.createVerticalPanel();
var txtBox = app.createTextBox().setFocus(true).setWidth("180");
var label=app.createLabel(" Eléments à rechercher :")
var label=app.createLabel(" Item to search for :")
panel.add(label);
txtBox.setId("item").setName("item");
var label0=app.createLabel("Row").setWidth("40");
var label1=app.createLabel("Doc Name").setWidth("180");
var label2=app.createLabel("Doc ID").setWidth("180");
var hpanel = app.createHorizontalPanel();
hpanel.add(label0).add(label1).add(label2);
//
var txt0=app.createTextBox().setId("lab0").setName("0").setWidth("40");
var txt1=app.createTextBox().setId("lab1").setName("txt1").setWidth("180");
var txt2=app.createTextBox().setId("lab2").setName("txt2").setWidth("180");
var hpanel2 = app.createHorizontalPanel();
hpanel2.add(txt0).add(txt1).add(txt2);
var hidden = app.createHidden().setName("hidden").setId("hidden");
var subbtn = app.createButton("next ?").setId("next").setWidth("250");
panel.add(txtBox);
panel.add(subbtn);
panel.add(hidden);
panel.add(hpanel);
panel.add(hpanel2);
var keyHandler = app.createServerHandler("click");
txtBox.addKeyUpHandler(keyHandler)
keyHandler.addCallbackElement(panel);
//
var submitHandler = app.createServerHandler("next");
subbtn.addClickHandler(submitHandler);
submitHandler.addCallbackElement(panel);
//
app.add(panel);
ss.show(app);
}
//
function click(e){
var row=ss.getActiveRange().getRowIndex();
var app = UiApp.getActiveApplication();
var txtBox = app.getElementById("item");
var subbtn = app.getElementById("next").setText("next ?")
var txt0=app.getElementById("lab0").setText('--');
var txt1=app.getElementById("lab1").setText('no match').setStyleAttribute("background", "white");// default value to start with
var txt2=app.getElementById("lab2").setText('');
var item=e.parameter.item.toLowerCase(); // item to search for
var hidden=app.getElementById("hidden")
var data = sh.getRange(2,1,lastrow,8).getValues();// get the 8 columns of data
for(nn=0;nn<data.length;++nn){ ;// iterate trough
if(data[nn].toString().toLowerCase().match(item.toString())==item.toString()&&item!=''){;// if a match is found in one of the 3 fields, break the loop and show results
var datarow=data[nn]
for(cc=0;cc<datarow.length;++cc){
if(datarow[cc].toString().toLowerCase().match(item.toString())==item.toString()&&item!=''){break}
}
var idx=cc
txt0.setText(nn+2);
txt1.setText(data[nn][idx]).setStyleAttribute("background", "cyan");
txt2.setText(data[nn][idx+1]);
sh.getRange(nn+2,idx+1).activate();
subbtn.setText("found '"+item+"' in row "+Number(nn+2)+", next ?");
hidden.setValue(nn.toString())
break
}
}
return app ;// update UI
}
function next(e){
var row=ss.getActiveRange().getRowIndex();
var app = UiApp.getActiveApplication();
var txtBox = app.getElementById("item");
var subbtn = app.getElementById("next").setText("no other match")
var hidden=app.getElementById("hidden");
var start=Number(e.parameter.hidden)+1;//returns the last search index stored in the UI
var item=e.parameter.item.toLowerCase(); // item to search for
var txt0=app.getElementById("lab0");
var txt1=app.getElementById("lab1").setStyleAttribute("background", "yellow");
var txt2=app.getElementById("lab2");
var data = sh.getRange(2,1,lastrow,8).getValues();// get the 3 columns of data
for(nn=start;nn<data.length;++nn){ ;// iterate trough
if(data[nn].toString().toLowerCase().match(item.toString())==item.toString()&&item!=''){;// if a match is found in one of the 3 fields, break the loop and show results
var datarow=data[nn]
for(cc=0;cc<datarow.length;++cc){
if(datarow[cc].toString().toLowerCase().match(item.toString())==item.toString()&&item!=''){break}
}
var idx=cc
txt0.setText(nn+2);
txt1.setText(data[nn][idx]).setStyleAttribute("background", "cyan");
txt2.setText(data[nn][idx+1]);
sh.getRange(nn+2,idx+1).activate();
subbtn.setText("found '"+item+"' in row "+Number(nn+2)+", next ?");
hidden.setValue(nn.toString())
break
}
}
return app ;// update UI
}
//
function gendoclisttest(){
sh.getRange(1,1).setValue('.');// usefull to allow for 'clear' if page is empty
sh.getRange(1,1,ss.getLastRow(),ss.getLastColumn()).clear().setWrap(false).setBorder(false,false,false,false,false,false);// clears whole sheet
var doclist=new Array();
var folders=DocsList.getFolders()
for(ff=0;ff<folders.length;++ff){
doclist=folders[ff].getFiles(0,2000)
var names = new Array();
for (nn=0;nn<doclist.length;++nn){
names.push([doclist[nn].getName(),doclist[nn].getId()]);
}
if (names.length>0){
names.sort();
var row=ss.getLastRow()+1;
sh.getRange(row,1,1,3).setValues([["Folders","Generic Doc Names","ID"]]).setBorder(false,true,true,true,true,true).setBackgroundColor("#dddddd");
sh.getRange(row+1,1).setValue(folders[ff].getName())
sh.getRange(row+1,2,names.length,2).setValues(names);
}
}
doclist=DocsList.getRootFolder().getFiles(0,2000)
var names = new Array();
for (nn=0;nn<doclist.length;++nn){
names.push([doclist[nn].getName(),doclist[nn].getId()]);
}
if (names.length>0){
names.sort();
var row=ss.getLastRow()+1;
sh.getRange(row,1,1,3).setValues([["Root","Generic Doc Names","ID"]]).setBorder(false,true,true,true,true,true).setBackgroundColor("#dddddd");
sh.getRange(row+1,2,names.length,2).setValues(names);
}
}
//
function doclistcat(){
var doclist=new Array();
var folders=DocsList.getFolders()
var zz=0;var nn=0
for(ff=0;ff<folders.length;++ff){
doclist=folders[ff].getFilesByType("spreadsheet",0,2000);
var names = new Array();
for (nn=0;nn<doclist.length;++nn){
names.push([doclist[nn].getName(),doclist[nn].getId()]);
}
if(names.length>0){
names.sort();
zz=zz+nn
var row=zz-nn+1
sh.getRange(row,4,1,3).setValues([["Folders","Spreadsheet Names","ID"]]).setBorder(true,true,true,true,true,true).setBackgroundColor("#dddddd");
sh.getRange(row+1,4).setValue(folders[ff].getName()).setB
sh.getRange(row+1,5,names.length,2).setValues(names);
}
}
doclist=DocsList.getRootFolder().getFilesByType("spreadsheet",0,2000);
var names = new Array();
for (nn=0;nn<doclist.length;++nn){
names.push([doclist[nn].getName(),doclist[nn].getId()]);
}
if(names.length>0){
names.sort();
zz=zz+nn
var row=zz-nn+1
sh.getRange(row,4,1,3).setValues([["Root","Spreadsheet Names","ID"]]).setBorder(true,true,true,true,true,true).setBackgroundColor("#dddddd");
sh.getRange(row+1,5,names.length,2).setValues(names);
}
//
var zz=0;var nn=0
for(ff=0;ff<folders.length;++ff){
doclist=folders[ff].getFilesByType("document",0,2000);
var names = new Array();
for (nn=0;nn<doclist.length;++nn){
names.push([doclist[nn].getName(),doclist[nn].getId()]);
}
if(names.length>0){
names.sort();
zz=zz+nn
var row=zz-nn+1
sh.getRange(row,7,1,3).setValues([["Folders","Text Document Names","ID"]]).setBorder(true,true,true,true,true,true).setBackgroundColor("#dddddd");
sh.getRange(row+1,7).setValue(folders[ff].getName()).setB
sh.getRange(row+1,8,names.length,2).setValues(names);
}
}
doclist=DocsList.getRootFolder().getFilesByType("document",0,2000);
var names = new Array();
for (nn=0;nn<doclist.length;++nn){
names.push([doclist[nn].getName(),doclist[nn].getId()]);
}
if(names.length>0){
names.sort();
zz=zz+nn
var row=zz-nn+1
sh.getRange(row,7,1,3).setValues([["Root","document Names","ID"]]).setBorder(true,true,true,true,true,true).setBackgroundColor("#dddddd");
sh.getRange(row+1,8,names.length,2).setValues(names);
}
}
//
//eof

load symbol of flash in flex at runtime

Hey people, I've this huge problem loading a symbol from a swf file in the application at runtime. I want to load it and pass it as a argument to another class where it could be used further. The symbol name is passed on from the array collection from the "o" object. Can anybody please tell me what's the right way to go about it.. Thanks in advance..!!
Following is the code for reference..
public override function Show(o:ObjectProxy):void
{
var _this:Weather;
var _super:ContentItem;
var item:WeatherItem;
var items:ArrayCollection;
var widgetCount:Number;
var headlineFontSize:int;
var conditionsIconThemeLoader:Loader;
this.m_weatherWidgetContainer = new HBox();
super.Show(o);
_this = this;
_super = super;
(undefined == o["HeadlineFontSize"]) ? headlineFontSize = 20 : headlineFontSize = o["HeadlineFontSize"];
if (undefined != o["direction"])
this.m_textDirection = o["direction"];
if (o.LargeUrl.Forecast is ArrayCollection)
items = ArrayCollection(o.LargeUrl.Forecast);
else
items = new ArrayCollection([o.LargeUrl.Forecast]);
widgetCount = this.m_computeWidgetSpace(items.length);
conditionsIconThemeLoader = new Loader();
conditionsIconThemeLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, function(e:Event):void
{
for(var i:uint = 0; i < widgetCount; i++)
{
var symbolClass:Class = e.currentTarget.loader.contentLoaderInfo.applicationDomain.currentDomain.getDefinition(int(items[i].condition)) as Class;
var symbolInstance:Sprite = new symbolClass();
item = new WeatherItem();
item.Show(items[i], headlineFontSize, symbolInstance, widgetCount);
_this.m_weatherWidgetContainer.addChild(item);
}
});
conditionsIconThemeLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, function(e:IOErrorEvent):void
{
Alert.show("Failure loading " + WidgetStylesheet.instance.Weather_Widget_Theme + ".swf");
});
// Attempt to load theme weather icon file
conditionsIconThemeLoader.load(new URLRequest("assets/animation/" + WidgetStylesheet.instance.Weather_Widget_Theme + ".swf"));
super.media.addChild(this.m_weatherWidgetContainer);
}
Heres the answer
public override function Show(o:ObjectProxy):void
{
var _this:Weather;
var _super:ContentItem;
var conditionsIconThemeLoader:Loader;
var loaderContext:LoaderContext;
this.m_weatherWidgetContainer = new HBox();
this.m_weatherWidgetContainer.percentHeight = 100;
this.m_weatherWidgetContainer.percentWidth = 100;
super.Show(o);
_this = this;
(undefined == o["HeadlineFontSize"]) ? this.m_headlineFontSize = 20 : this.m_headlineFontSize = o["HeadlineFontSize"];
if (undefined != o["direction"])
this.m_textDirection = o["direction"];
if (o.LargeUrl.Forecast is ArrayCollection)
this.m_items = o.LargeUrl.Forecast;
else
this.m_items = new ArrayCollection([o.LargeUrl.Forecast]);
conditionsIconThemeLoader = new Loader();
loaderContext = new LoaderContext(false, ApplicationDomain.currentDomain);
conditionsIconThemeLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, this.m_loaderSuccess);
conditionsIconThemeLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, this.m_loaderFail);
// Attempt to load theme weather icon file
conditionsIconThemeLoader.load(new URLRequest("assets/animation/" + WidgetStylesheet.instance.Weather_Widget_Theme + ".swf"), loaderContext);
this.m_weatherWidgetContainer.addEventListener(FlexEvent.CREATION_COMPLETE, this.m_drawHorizontalLine);
super.media.addChild(this.m_weatherWidgetContainer);
}

How to Convert Input Type=Text to Span

Is there a way to convert Input type=text to Span in ASP.Net
You really should provide more information about the scenario you'd want to do this for, but here's a couple of generic ones.
Doing it server side
if(ChangeTextToSpan) { //some condition to check, could be a query string or what ever
this.Label1.Text = this.TextBox1.Text;
this.Label1.Visible = !this.TextBox1.Visibile = false;
}
Doing it client side
function swapTextBox(changeTextToSpan) {
if(changeTextToSpan) { //again, do a condition
var span = document.getElementById('<%= this.Label1.ClientID %>');
var txt = document.getElementById('<%= this.TextBox1.ClientID %>');
span.innerHTML = txt.value;
span.style.display = 'inline';
txt.style.display = 'none';
}
}
setTimeout(10000, swapTextBox(true)); //after 10 seconds it'll swap

Resources