Unnamed: 0
int64
302
6.03M
Id
int64
303
6.03M
Title
stringlengths
12
149
input
stringlengths
25
3.08k
output
stringclasses
181 values
Tag_Number
stringclasses
181 values
1,900,337
1,900,338
jQuery.extend and jQuery.fn.extend
<p>I am making some test with <code>extend</code> and I got a little puzzled after some observations I made. First observations:</p> <pre><code>console.log($.extend === $.fn.extend); // trure // and since $ === jQuery then ... console.log(jQuery.extend === jQuery.fn.extend); // true </code></pre> <p>So far so good, isn't it? Given the above results I then thought that doing this:</p> <pre><code>// SNIPPET 1 $.extend({ log: function(m) { console.log(m); } }); </code></pre> <p>and this:</p> <pre><code>// SNIPPET 2 $.fn.extend({ log: function(m) { console.log(m); } }); </code></pre> <p>was the same very thing. But in fact things stand in a very different way. In fact if you run SNIPPET 1 and then do:</p> <pre><code>$("body").log("whatever"); </code></pre> <p>you get an error (log is not defined). But you can do:</p> <pre><code>$.log("whatever"); </code></pre> <p>If you run instead SNIPPET 2 you get the opposite result, that is to say:</p> <pre><code>$("body").log("whatever"); // this will work $.log("whatever"); // this won't </code></pre> <p>What the heck? I appreciate the fact that <code>.extend</code> extends the object against which it is executed (<code>$</code> vs <code>$.prototype</code>) but what I do not get is how iit does it! Expecially given the fact that:</p> <pre><code>$.extend === $.fn.extend // true </code></pre> <p>The function is the same!! How can it produce 2 different results?</p>
javascript jquery
[3, 5]
3,128,435
3,128,436
How should i get some value from javascript object and check for null
<p>I am getting the element as</p> <pre><code> var minPricePerInputField = $("input#A"+indexNr); </code></pre> <p>The element can be present also or not also. I am getting some [object Object] thing. I have no idea what is this. I am receiving this [object Object] when the element is not there.</p>
javascript jquery
[3, 5]
1,649,805
1,649,806
How to assign all attributes of one div to another div
<p>I need to assign the position, top, left, height, width &amp; border of one div to another div. Since I have multiple div's that I need to operate upon, I am looking for an elegant solution to this using jQuery.</p> <p>Kindly keep in mind that the two div's have different ID's and I'd like to keep it that way.</p> <p>Thanks in advance &amp; best regards, sbguy</p>
javascript jquery
[3, 5]
1,624,297
1,624,298
how to send string value from php page to java script page
<p>I am storing a string value in one php variable.I want to send this value to a function on image click. Here is code</p> <pre><code>userfn.php $actvitycode = "AG001"; &lt;img src="phpimages/addicon.gif" onclick="showData('.$actvitycode.')"&gt;&lt;/img&gt; getdata.js function showData(actcode) { alert(actcode); document.getElementById("tasklist").value = actcode; } </code></pre> <p>Problem is, on image click the function is not calling. FYI: If I store integer value (ex:2342) in $actvitycode the function is successfully called and alert is showing the result. The problem with the string value only. I tried with several syntaxes like</p> <pre><code>onclick="showData("'.$actvitycode.'")" onclick="showData($actvitycode)" </code></pre> <p>but no one syntax is giving result. Please provide me correct syntax.</p>
php javascript
[2, 3]
4,953,935
4,953,936
ASP.NET security
<p>I'm currently converting our company database application from VB to ASP.NET. This is pretty much my first ASP.NET application, and I had a question about security. I would like some users to have the ability to add or edit data, while other users can only view and print reports. Now, as I understand it, in ASP.NET, I can use form-based authentication to restrict access to certain pages, but what I really would like to do is use the same web page for not only viewing the data, but also editing it (using a grid view). I don't see how I can do that using forms-based authentication without having separate (but similar) web pages in different folders, each with it's own level of security.</p> <p>I guess I could always use the same web page, then check the users roles to determine if I should enable the 'edit' button or not. Is that a good (and common) programming practice?</p> <p>Thanks</p>
c# asp.net
[0, 9]
3,670,142
3,670,143
Disable Browser's Minimize button using javascript
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/4754823/how-to-disable-minimize-maximize-button-in-the-browser">How to disable minimize, maximize button in the browser?</a> </p> </blockquote> <p>I am using php and javascript.I am using IE, Please tell me how can i disable the minimize button using javascript. I have used this</p> <pre> window.open('url','',"fullscreen=yes,scrollbars=yes,minimize=no",true);</pre> <p>But only<pre>minimize=no</pre>or<pre>minimize=0</pre> is not working. I do not want to use open a box.can we call a function on minimize the browser ? </p>
php javascript
[2, 3]
3,585,888
3,585,889
How to put dropdownlistbox in GridView column when user push "Edit" Link?
<p>When user start editing row in gridview he see next: <img src="http://i.stack.imgur.com/EzIIu.png" alt="enter image description here"></p> <p>Is it possible to put dropdownlistbox with data from db in editbox?</p> <p>GridView get data from DB. Autogeneratecolumns = true. My GridView take data from different tables.</p>
c# asp.net
[0, 9]
1,987,504
1,987,505
How can I get a username from LDAP?
<p>I'd like to ask you how can i dinamically get a username from ldap. As you can see below, i entered the username 'smith2'</p> <pre><code>$_SERVER["REMOTE_USER"] = 'smith2'; $param = $_SERVER["REMOTE_USER"] </code></pre> <p>And I can get his first name, like this:</p> <pre><code> $ldap1 = new ldapl; $fname=$ldap1-&gt;getFname($param); </code></pre> <p>This is useful because I have some forms with some fields which are filled by default (name, first name, etc).</p> <p>It must be dynamic. Each person has a PC, so the person Y should see his name, first name, etc The person X his name, first name, etc.</p> <p>But i don't know how to get the username dinamically. Can you explain it to me?</p> <p>Thanks</p>
php javascript jquery
[2, 3, 5]
4,924,702
4,924,703
How to pass data from Java applet to client side python script?
<p>I have a python script which does various number-crunching jobs and now need to put a graphical front-end on it (a molecular editor in which a user draws a compound to pass to the script) to allow others in the lab to use it more easily. The available editors are Java applets, standalone Java or written in JavaScript. </p> <p>I would greatly appreciate any advice on the best strategy to put the editor and script together. I really don't want to get into client/server arrangement and envisage a self-contained install on each machine i.e. "client only". Is it better to start off in javascript and pass the output in some way to python and then run the python script from within js. Or (preferably) is there some way to run applets (or standalone java) within python e.g. in Tkinter or some other GUI and "on-click" take the output from the editor into the python script for the crunching bit. </p> <p>Thanks for any pointers - book chapters, useful projects/libraries and links to examples would be great. </p>
java javascript python
[1, 3, 7]
5,703,456
5,703,457
Problems with a method imported from a SDK library
<p>I am new to C# and ASP.NET and I have a problem with a library that I am importing. I have a small application that is going to convert a sound file in a format that is proprietaty to the vendor and they have an SDK that provides a method to make the conversion from their extension to .WAV format.</p> <p>The issue I have is after importing the SDK library into VS2008, and putting the using statement on my code behind, I am getting an error when I try to use the method I need in order to make the conversion. My code is below and the error says:</p> <blockquote> <p>Name space ALTIHELPERLib</p> <p>Error 'ALTIHELPERLib.IAHelper.ADPCM2Wav(wavFilePath, filePath)'. Not all code paths return a value return </p> </blockquote> <p>I have tried to look around for a solution but so far nothing has worked. Any help will be appreciate it. Here is my code:</p> <pre><code>string wavFilePath = @"\mylocation\"; //destination of file once onverted string filePath = "\source\"; //location of source file public string ALTIHELPERLib.IAHelper.ADPCM2Wav(wavFilePath, filePath){ } </code></pre>
c# asp.net
[0, 9]
5,556,619
5,556,620
How to use jQuery WYSIWYG HTML editor in ASP.net page
<p>I am working in a blog application , i want to integrate the HTML editor of jQuery in ASP.net application.Although i have much easier option of using ASP.net AJAX toolkit editor , but it is not lightweight, so i want to go with jQuery HTML editor.</p> <p>Can you suggest some tutorial which helps to do so.</p> <p>Thanks in advance.</p>
jquery asp.net
[5, 9]
3,464,662
3,464,663
How to check over what element my mouse is when I lose focus on input element
<p>Let's say I have this:</p> <pre><code>&lt;body&gt; &lt;input type="text" onblur="myFunction()" /&gt; &lt;... rest of page ...&gt; &lt;/body&gt; &lt;script type="text/javascript"&gt; function myFunction() { //this function alerts over what element your mouse is when the input loses focus } &lt;/script&gt; </code></pre> <p>Does someone know how to implement this?</p>
javascript jquery
[3, 5]
2,633,823
2,633,824
How can I conduct a post via Javascript from jQuery?
<p>I want to conduct a <code>POST</code> request via jQuery.</p> <p>Say I have four Javascript variables: <code>var1</code>,<code>var2</code>,<code>var3</code>,<code>var4</code> and a endpoint of URL.</p> <p>How would I <code>POST</code> via jQuery (I would rather not be using Ajax for the sake of this example).</p>
javascript jquery
[3, 5]
1,003,964
1,003,965
Downloading a file from server and save it in client
<p>I am currently developing an ASP.net application, where I generate a word document in server and I want to save it in client machine who access that feature with out user interactions. How can I download it and save it in client machine, using Javascript?</p>
c# javascript asp.net
[0, 3, 9]
1,171,645
1,171,646
$(window).load(function()-how it works with FF
<p>I have a jquery code.</p> <pre><code>$(window).load(function() { document.title = $("#myid").text(); //not working in FF }); </code></pre> <p>Here I have used $(window).load(function() because in the #myid I am getting value through another javascript, if I use ready(), its giving me error. so I am first loading the window then start reading value. Now in IE, after the window loads itself , I am getting the value of document.title, but for FF its coming as blank.undefined. Why? any idea or alternate sln.</p>
javascript jquery
[3, 5]
1,444,434
1,444,435
What is the best way to convert an existing php class into Java?
<p>I have been tasked with converting several php classes into java classes, which is quickly becoming a nightmare for me. I understand the basic language structure, it being similar to C. It is all of the function calls and class calls that seem to go nowhere and the fact that a var can be declared in the <strong>!middle of an expression!</strong> that is spinning my head, oh and the fact that there is zero "0" documentation.</p> <p>What is the best <strong>method</strong> (and/or) <strong>tool</strong> (and/or) <strong>reference material</strong> to convert the php into java code?</p> <p>edit: There is 3 reasons that I am having to convert the php to java. </p> <ol> <li>The usual reason, my boss told me too.</li> <li>The php is too slow, it is taking <strong>minutes</strong> sometimes to run a request to the server. </li> <li>php is a nightmare to scale and maintain.(at least for us strong typed language types)</li> </ol>
java php
[1, 2]
1,973,378
1,973,379
jQuery / Javascript execution order?
<p>I'm trying to exactly figure out the execution order of what is going on here. I'm using jquery to retrieve new data, and I get occasional irregularities. How I have its current work flow order should be something like this:</p> <ol> <li>Onload - get() function (retrieves data for both divs)</li> <li>The move() function is activated via a button</li> <li>move.php has the mysql_query update action</li> <li>Reload the div with the updated database information.</li> </ol> <hr> <pre><code>function get(varpass) { varpass = typeof(varpass) != 'undefined' ? varpass : "all"; var j = "&lt;?=$_SESSION['username']?&gt;"; if (varpass == "all" || varpass == "left") { $('#left').hide(); $.get('data.php', { name: j, p: varpass }, function (output) { $('#left').html(output).fadeIn(250); }); } if (varpass == "all" || varpass == "main") { $('#main').hide(); $.get('main.php', { name: j, p: varpass }, function (output) { $('#main').html(output).fadeIn(250); }); } } $(document).ready(function () { get("all"); }); function move(p) { var j = "&lt;?=$_SESSION['username']?&gt;"; $.get('move.php', { name: j, p: p }, function (output) { $('#debug').html(output).fadeIn(1); }); $('#main').hide(); get("main"); } </code></pre> <p>I find that on occasion the div will retrieve information before the move.php mysql_query has been completed. How can control the order of execution better? I want the information to finish being updated before it calls to retrieve the data from the database again.</p> <p>Thanks</p>
php javascript jquery
[2, 3, 5]
1,649,264
1,649,265
Is it possible to change form attr name dynamically?
<p>I have one form which it's dynamic depends on parameters. the form name attribute should be different for each dynamic built form. Is there a way how to change form name attribute? or sufficient work around?</p> <p>this way is not working or I'm missing something</p> <pre><code>&lt;form action="get" name="oldname"&gt; &lt;/form&gt; $('#formid').attr('name', 'dynamicname'); </code></pre> <p>I'd like to change the "oldname" via client-side javascript so it ends up like this:</p> <pre><code>&lt;form action="get" name="dynamicname"&gt; &lt;/form&gt; </code></pre> <p>Thanks</p>
javascript jquery
[3, 5]
2,552,435
2,552,436
What's wrong with this Intent?
<p>What I am trying to do is, when the user chooses this option, my Android app runs an intent. The intent calls for the camera of the Android device, and the camera takes a picture, and then saves the file into the directory named posense.</p> <pre><code>path = Environment.getExternalStorageDirectory().getName() + File.separatorChar + "posense"; Intent intent = new Intent("android.media.action.IMAGE_CAPTURE"); File photo = new File(path); Intent newintent = intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photo)); imageuri = Uri.fromFile(photo); startActivityForResult(newintent, 1); </code></pre>
java android
[1, 4]
2,684,041
2,684,042
Request for another page from aspx site
<p>it is possible to do a request for another page on internet from page_load? I mean if it is possible to aquire markup code with informations from another page and display them on my aspx site? For example something like this:</p> <pre><code>protected void Page_Load(object sender, EventArgs e) { UnknownType anotherSite = GetMarkupCode("www.fifa.com"); //parse anotherSite . . . //display parsed informations . . . } </code></pre> <p>If it is possible how can i do that? Many thanks for answers.</p>
c# asp.net
[0, 9]
2,760,378
2,760,379
Jquery UI tabs disable AJAX functionality for some tabs
<p>How is it possible to disable AJAX functionality for a tab or two when using jQuery UI tabs?</p> <p>So after clicking the user is taken to an URI defined by the href attribute of a link. Right now, the default behaviour is that the content from the the external URI is loaded via AJAX.</p>
javascript jquery
[3, 5]
2,811,108
2,811,109
Jquery last click
<p>How i can determine the last clicked id ?! Because if i use :</p> <pre><code> if(clicks &gt; 1){ var lc = event.target.id; // Last Clicked event } </code></pre> <p>It will return the current button clicked id I have something like this :</p> <pre><code>$('#menu).click(function(event) { clicks++; if(clicks &gt; 1){ var lc = event.target.id; // Last Clicked event } console.log(lc); </code></pre> <p>And i have 2 buttons Now if i click on first button console log will show undefinded but if i click on second button it will show his id.I want to prevent that</p>
javascript jquery
[3, 5]
4,041,476
4,041,477
find all youtube links with js (jquery)
<p>Say there is a div that has content and a youtube link. I want to grab that youtube link and embed it.</p> <pre><code>&lt;div id="content"&gt;&lt;p&gt;Here is a cool video. Check it out: http://www.youtube.com/watch?v=oHg5SJYRHA0&lt;/p&gt;&lt;/div&gt; </code></pre> <p>I want to grab the link and replace it with the embed code with js (jquery).</p> <p>Update 1:</p> <p>This is my js so far:</p> <pre><code> $("#content").each(function(){ var allContent = $(this).html(); //need regex to find all links with youtube in it, ovbiously it can't == youtube.com, but basically the link has to have youtube.com in it. if ($("a",allContent).attr("href") == "youtube.com" ) { // grab youtube video id /* replace link with &lt;div id="yt-video"&gt; &lt;object width="560" height="340"&gt;&lt;param name="movie" value="http://www.youtube.com/v/429l13dS6kQ&amp;hl=en&amp;fs=1&amp;"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/429l13dS6kQ&amp;hl=en&amp;fs=1&amp;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="560" height="340"&gt;&lt;/embed&gt;&lt;/object&gt; &lt;/div&gt; */ } }); </code></pre>
javascript jquery
[3, 5]
1,552,499
1,552,500
Accessing C# variable in javascript
<p>I'm going to design a website for DMS (educational domain) in C#.NET, which I am new to. </p> <p>In one of my ASPX pages, I want to disable a menu, which is in JavaScript, according to <code>accessright</code>. </p> <p>The <code>accessright</code> stored in database table <code>login</code> as one attribute in SQL server, and I want to retrieve that <code>accessright</code> to one C# variable and want to access that variable in JavaScript.</p> <p>If there is another possible approach please tell.</p>
c# asp.net javascript
[0, 9, 3]
1,474,573
1,474,574
Period (.) in dataset field name - Cannot bind to repeater
<p>I have a dataset that i am binding to a repeater. The <code>GetXML()</code> of the dataset looks like this:</p> <pre><code>&lt;NewDataSet&gt; &lt;Table1&gt; &lt;Company.Date&gt;03/22/2009&lt;/Company.Date&gt; &lt;/Table1&gt; &lt;/NewDataSet&gt; </code></pre> <p>The aspx looks like this:</p> <pre><code>&lt;%# DataBinder.Eval(Container.DataItem, "Company.Date")%&gt; </code></pre> <p>When I bind it, I get the error:</p> <pre><code>System.Data.DataRowView' does not contain a property with the name 'Company'. </code></pre> <p>It doesn't seem to like the period. Is there a way to fix this without changing the naming convention?</p>
c# asp.net
[0, 9]
4,979,993
4,979,994
How to check whether JavaScript is enabled in client browser using Java code
<p>can anyone help me in trying to check whether JavaScript is enabled in client browser using Java code.</p> <p>Thanks in advance</p>
java javascript
[1, 3]
956,314
956,315
IDE Like interface with jQuery (Resizing divs)
<p>I am planning to develop a site which will have interface very similar to IDE</p> <p><img src="http://i.stack.imgur.com/mTr7D.png" alt="alt text"></p> <p>I was wondering if there is a jQuery plugin which allows the resizing of divs (horizontal / vertical based on settings) or any ideas on what would be the best approach.</p>
javascript jquery
[3, 5]
1,443,690
1,443,691
Java/Android - Search ArrayList<HashMap<String, String>> for matching key -> value
<p>I have an ArrayList of HashMaps, and I have the key and value of one HashMap that I'd like to use to match the value of another HashMap found at a different position..</p> <p>For example:</p> <pre><code>1- [&lt;key1, val1&gt;, &lt;key2, "some value"&gt;, &lt;key3, val3&gt;] 2- [&lt;key1, val1&gt;, &lt;key2, val2&gt;, &lt;key3, val3&gt;] 3- [&lt;key1, "some value"&gt;, &lt;key2, val2&gt;, &lt;key3, val3&gt;] </code></pre> <p>And I know that Array.get(1).get(key2) == "some value"</p> <p>How can I then use this to match the key1 at Array.position(2), and return the value of key3?</p> <p>Or in other words, how can I find the position of an ArrayList given the value of one of it's containing key/value HashMaps?</p> <p>Something like Array.where("key1" == "some value").</p> <p>Thanks</p>
java android
[1, 4]
2,513,066
2,513,067
using the click event to fade in and fade out hidden divs
<p>I am currently trying to learn the fundamentals of jquery and would love some advice on how to achieve the following.</p> <p>When I click on the 'Drop down' link a hidden list of links is faded in, when I click on any part of the page except the #innerList tag then the hidden list fades out or if I click on one of the hidden links then the list fades out also.</p> <p>My current effort is here <a href="http://jsfiddle.net/kyllle/b6XC4/" rel="nofollow">http://jsfiddle.net/kyllle/b6XC4/</a> </p> <p>It would be great to get some advice on how I can achieve this result.</p>
javascript jquery
[3, 5]
1,567,249
1,567,250
How to hide check all, clear all checkbox
<p>I am having check box in the column header. The function of this is to check or uncheck all the check boxes in that column.If the row check box is checked and say delete, that row can be deleted from the dataTable.</p> <p>If the row object is used in some other table as a foreign key i put '-' in that row instead of check box which indicates that row cannot be deletable.</p> <p>In these cases if all the row has '-" , there is no need to have the header check box. How to programatically hide this 'Check All | Clear All' check box, if there is nothing to be removed.</p> <p>It would be even preferable to hide the 'Remove' button if there is no selection to be made.</p> <p>What are the best practices to address the above scenario. I have attached the javascript which I am using.</p> <pre><code>&lt;script type="text/javascript"&gt; var tableId = '#user\\:userList'; jQuery(document).ready(function() { jQuery('#selectAll').click(function() { jQuery(tableId).find("input[type='checkbox']").attr('checked', jQuery('#selectAll').is(':checked')); }); }); &lt;/script&gt; </code></pre>
javascript jquery
[3, 5]
4,944,218
4,944,219
Something similar to checkstyle for C++ to be working on Linux
<p>I am looking for some tool to help with C++ like <code>checkstyle</code>, which is for JAVA. It should be available for LINUX.</p> <p>Are you guys aware of any?</p>
java c++
[1, 6]
4,628,088
4,628,089
How to call JavaScript function from a PHP printed button
<p>What a weird question. If anyone has a better title for this, please go ahead and edit it; I can't think of what else to call it. I am printing a button from PHP using <code>echo</code>. The purpose of a button is to show a form by calling a JavaScript function that uses <code>document.getElementById()</code> to change the style attribute of the form tag to visible so the form is visible to the user. The problem I'm having is that the echoed string has to have quotes around it, the <code>onclick</code> event has to have quotes around it, and the parameter passed to the JavaScript function has to have quotes around it. I tried escpaing the quotes for the parameter with backslashes but that didn't work. Can anyone help me?</p> <p>Here is my code:</p> <pre><code>echo "&lt;input type = 'button' onclick = 'showform(\'psswdform\')' value = 'Change password'&gt;";//this shows the form and needs quotes </code></pre> <p>JavaScript function:</p> <pre><code>function showform(id) { document.getElementById(id).style.visibility = "visible"; } </code></pre>
php javascript
[2, 3]
1,577,500
1,577,501
Including a file in json_encode()
<p>Thsi does not seem to work:</p> <pre><code>$msg="Your changes have been saved successfully"; $view=include('application/view/admin/cms/_slides-current.php'); $return_array=array('success'=&gt;true, 'msg'=&gt;$msg, 'view'=&gt;$view); echo json_encode($return_array); </code></pre> <p>The array needs to be passed back to a jQuery ajax success callback. Anybody know how it should be done?</p> <p>The include file is simply a HTML template. This HTML template will be inserted on to the page.</p> <p>Is there any way other than using json_encode() to do what I am trying to do?</p> <pre><code>success: function(result){ alert(result.msg); if(result.success == true) { $('#slides').html(result.view); } } </code></pre>
php jquery
[2, 5]
2,840,912
2,840,913
Dynamically generated Button click not getting called?
<p>I have associated a Button ID while generating Buttons dynamically and created a Button event handler as follows:</p> <pre><code>btn.Click += new EventHandler(btn_Click); </code></pre> <p>Button Click event:</p> <pre><code>protected void btn_Click(object sender,EventArgs e) { Button b = new Button(); b = (Button)sender; string i = b.ID.Substring(b.ID.Length - 1, 1); int j1 =Convert.ToInt32(i); id1 = to[j1]; Page.ClientScript.RegisterClientScriptBlock(Type.GetType("System.String"), "addScript", "PassValues('" + id1 + "')", true); ScriptManager.RegisterStartupScript(this, this.GetType(), "sendMessage", "javascript:sendMessage(); ", true); } </code></pre> <p>However this event is not getting called i have placed all my controls inside an UpdatePanel</p> <p>EDIT: What is happening is on button click somehow a function is getting called which is present on <code>Page.Load</code></p> <pre><code>protected void getEntriesRight() { j = (int)Session["j"]; int n1 = j + 3; for (; j &lt;= n1; j++) { if (j &lt; fr.data.Length) { HtmlGenericControl listItem = new HtmlGenericControl("li"); HtmlGenericControl a1 = new HtmlGenericControl("a"); Label anchor = new Label(); Image im = new Image(); btn = new Button(); im.ImageUrl = fr.data[j].pic_square; im.Height = 45; im.Width = 47; btn.CssClass = "btn-add"; btn.Text = "Invite"; to[j] = fr.data[j].uid; btn.ID = "btn" + j; a1.Attributes.Add("href", "#"); anchor.Text = fr.data[j].name; a1.Controls.Add(btn); a1.Controls.Add(im); a1.Controls.Add(anchor); listItem.Controls.Add(a1); list.Controls.Add(listItem); btn.Click += new EventHandler(btn_Click); } } Session["j"] = j; } </code></pre> <p>Help!</p>
c# asp.net
[0, 9]
817,008
817,009
ReferenceError: function is not defined when using onclick
<p>I set up an anchor tag using javascript so that that <code>onclick</code>, I call a function <code>showSavingsEasterEgg</code> and pass it a value. The problem I am getting is that I'm not referencing my function correctly:</p> <p><code>ReferenceError: showSavingsEasterEgg is not defined</code></p> <p>I've tried moving the <code>showSavingsEasterEgg</code> function into the <code>showData</code> function to see if it solved the scoping problem, but it didn't.</p> <p>Any tips</p> <pre><code>define(["jquery", "go/util", "underscore", "jqueryui/slider"], function ($, util,_) { function showData(data) { $('#item').append('&lt;a class="savings_link" href="#" onclick=\'showSavingsEasterEgg('+data[key]['saving']+')\'&gt; Savings'); } function showSavingsEasterEgg(data){ console.log("SUccess"); console.log(data); } }); </code></pre>
javascript jquery
[3, 5]
3,982,047
3,982,048
Getting relative image src with jQuery
<p>I've got image tags that look like this:</p> <pre><code>&lt;img src="/path/to/my/image.jpg" /&gt; </code></pre> <p>But when I access the src bit using jQuery, jQuery gives me back:</p> <pre><code>http://example.com/path/to/my/image.jpg </code></pre> <p>This is causing problems in some comparisons I'm doing. I don't want to change my image paths to use absolute URLs.</p> <p>Any ideas as to how I can either get the absolute URL from the image path (this might not be as simple as concatenating the domain - since the URLs may occasionally be absolute), or get the path I provided in the HTML? Either way I need them to match up.</p> <h3>Edit per comment from activa</h3> <p>There's not really a lot of jQuery code to post, I'm using the <a href="http://malsup.com/jquery/cycle/">cycle</a> plugin, and in the <code>onbefore</code> function, I'm just calling <code>next.src</code>. My jQuery and JavaScript foo isn't sufficient to really understand what the cycle plugin is doing to generate <code>next</code> - I think it's the DOM element for the next image being cycled in, if you're familiar with what cycle does.</p> <p>My image tag is actually this:</p> <pre><code>&lt;img src="/site_media/photologue/photos/cache/6927d406810ee9750a754606dcb61d28.jpg" alt="" class="landscape slideshow-image-1" /&gt; </code></pre> <p>and in my <code>onbefore</code> function this code:</p> <pre><code>alert(next.src); </code></pre> <p>results in an alert with:</p> <pre><code>http://127.0.0.1:8000/site_media/photologue/photos/cache/6927d406810ee9750a754606dcb61d28.jpg </code></pre>
javascript jquery
[3, 5]
2,908,675
2,908,676
convert image to byte[] c# and get image back in android
<p>I have the following code in c# which convert image to the byte[]</p> <pre><code>MemoryStream memory = new MemoryStream(); bitmap.Save(memory, System.Drawing.Imaging.ImageFormat.Jpeg); </code></pre> <p>now i want to get the image back in the android, what should i do ?</p>
c# java android
[0, 1, 4]
2,542,761
2,542,762
save files on server
<p>I am developing a website for the project on of my course.this is a system with a lot of user and <strong>each user can upload files on server</strong>. now i have two way for implementation that:</p> <ol> <li>create a folder with name files and upload files in that and retrieve from that.</li> <li>each user have a distinct folder and upload files in that.</li> </ol> <p>the implementation of second way is easy but i think create a lot of folder(each user have distinct folder) may decrease the speed when every one try to load them from sever.</p> <p>whats your opinion? what way is better? </p>
c# asp.net
[0, 9]
1,655,535
1,655,536
Refactoring if-else statements checking for different file extensions
<p>I have this piece of code which i feel could be cleaned up ( i could be wrong) but i wanted to see if anyone has a suggestion how i can change this to be "better"</p> <pre><code>string getExt = Path.GetExtension(DocumentUNCPath.Text); var convertFileId = Guid.NewGuid(); var convertFilePath = @"c:\temp\" + convertFileId + ".pdf"; if (getExt == ".doc" || getExt == ".docx" || getExt == ".txt" || getExt == ".rtf") { WordToPdf(convertFilePath); } else if (getExt == ".xlsx" || getExt == ".xls") { ExcelToPdf(convertFilePath); } else if (getExt == ".jpg" || getExt == ".png" || getExt == ".jpeg" || getExt == ".JPG" || getExt == ".PNG") { ImgToPDF(convertFilePath); } </code></pre>
c# asp.net
[0, 9]
1,515,936
1,515,937
asp.net :: J query :: add new element using J query
<p>I append new table cell to the page using c# and Jquery:</p> <p>this code is in a web handler from that i called it from JQuery event :</p> <pre><code>sb.Append("&lt;td style=width: 5%; align=center&gt;" + " &lt;input id=cbSelect"+dt.Rows[i]["FileID"].ToString()+ " type=checkbox name=cbSelect"+dt.Rows[i]["FileID"].ToString() +" onclick='return selectSingleCheckbox('"+dSize.ToString() +"','cbSelect"+dt.Rows[i]["FileID"].ToString()+"')';&gt;" + "&lt;/td&gt;"); </code></pre> <p>the table cell is add successfully, but it is java script <strong><code>onclick='return selectSingleCheckbox('"+dSize.ToString() +"','cbSelect"+dt.Rows[i]["FileID"].ToString()+"')'</code></strong> doesn't fired.</p> <p>How can I fire this javascript event according to the table cell</p>
c# javascript jquery asp.net
[0, 3, 5, 9]
4,723,968
4,723,969
How can I determine the direction of a jQuery scroll event?
<p>I'm looking for something to this effect:</p> <pre><code>$(window).scroll(function(event){ if (/* magic code*/ ){ // upscroll code } else { // downscroll code } }); </code></pre> <p>Any ideas?</p>
javascript jquery
[3, 5]
5,035,067
5,035,068
jQuery UI Tabs loading specific link within tab
<p>I want to load only links within a certain div inside the tab, otherwise it should just go to the actual link.</p> <p>Current the code i use loads all links inside the content in the same tab</p> <pre><code>&lt;script type="text/javascript"&gt; $(function(){ $('#tabs').tabs({ load: function(event, ui) { $('a', ui.panel).click(function() { var tabId=$('#tabs').tabs('option', 'selected'); $('#tabs').tabs("url", tabId, this.href).tabs("load",tabId); return false; }); } }); }); &lt;/script&gt; </code></pre> <p>Tab Page</p> <pre><code> &lt;div id="sresults" style="width: 520px"&gt; &lt;div id="tabs"&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="mylink.html"&gt;Songs&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="mylink.html"&gt;Albums&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="mylink.html"&gt;Videos&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="mylink.html"&gt;Entire Blog&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>And then heres the page inside the tab</p> <pre><code>&lt;div id="content"&gt; &lt;a href="permalink.html"&gt;My links&lt;/a&gt; &lt;/div&gt; &lt;div id="navi"&gt;&lt;a href="tab?page=2"&gt;Next Page&lt;/a&gt; &lt;/div&gt; </code></pre> <p>I want the links inside the navi div to load within the tab, but all links outside should go to the actual link</p>
javascript jquery
[3, 5]
3,070,482
3,070,483
jquery bind on images?
<p>I've an img and a button, and I'd like to use jQuery bind to respond to onclick events. Bind works on the input button, but not on img. Here is my JavaScript code:</p> <pre><code>function drawDetails (event) { var id=0; if ((typeof $(this).attr('id')) !== 'undefined') { id = parseInt($(this).attr('id').replace(/[^0-9]+/g,'')); } else if((typeof e.id)!=='undefined') { id = e.id; } alert("drawDetails " + id); } $("input[id^=camera-]").bind('click', drawDetails); $("input[id^=details-]").bind('click', drawDetails); </code></pre> <p>HTML:</p> <pre><code>&lt;img id="camera-10" src="camera.gif"/&gt; &lt;input id="details-10" type="button" value="Details 10"&gt; &lt;img id="camera-11" src="camera.gif"/&gt; &lt;input id="details-11" type="button" value="Details 11"&gt; </code></pre> <p>I've prepared a <a href="http://jsfiddle.net/eJ3rn/2/" rel="nofollow">JSFiddle</a> of it. How can I make the event fire also when the image is clicked? </p>
javascript jquery
[3, 5]
1,055,130
1,055,131
writing a function which creates a string (javascript) and then add it to a button as its attribute?
<p>hi I have a Button in my .aspx web form and use c# 3.0 I want to add a javascript function to its attribute as its "onclick" event handler. the function has 1 parameter in order to check whether onclick javascript should get a confirmation from user or not. The parameter Datatype is bool But when I send true, execution of the program halts and show me a message that True is not defined!!</p> <p>What's wrong?</p>
c# asp.net javascript
[0, 9, 3]
4,251,306
4,251,307
Javascript issue
<p>I have a question regarding my button disappear</p> <p>I've put an image as my button</p> <pre><code>&lt;div id="button1"&gt; &lt;a href="javascript:example_animate('-=200px')"&gt; &lt;img src="images/button1.jpeg"&gt; &lt;/a&gt; &lt;/div&gt; </code></pre> <p>that is animated with this function</p> <pre><code>&lt;script language="javascript"&gt; function example_animate(px) { $('#content2').animate({ 'marginTop' : px }); } &lt;/script&gt; </code></pre> <p>and i can't get it disappear after doing this function with this script</p> <pre><code>&lt;script language="javascript"&gt; $("#button1").click(function () { this.visible = false; }); &lt;/script&gt; </code></pre> <p>please help!</p>
javascript jquery
[3, 5]
5,786,108
5,786,109
How to disable jsTree right click create option after create once
<p>In my application I'm using jstree.js. I succesfully applied necessary coding for tree view. My question is I want to remove right click create option after creating one node. I tried to write some codes in create event, but I could'nt succeeded.</p> <p>here is how my code looks right now</p> <pre><code> $('#my_tree').bind("create.jstree", function (e, data) { $.jstree.defaults.contextmenu.items.create = ""; }); </code></pre>
javascript jquery
[3, 5]
913,740
913,741
Nullreference exception - why?
<pre><code>Panel pnl_Confirmation = (Panel)form1.FindControl("ConfirmationPanel") as Panel; pnl_Confirmation.Visible = false; </code></pre> <p>I keep getting a "NullReferenceException" in the above code. "ConfirmationPanel" is a panel I show/hide depending on if the form is submitted successfully or not.</p> <p>The panel is wrapped in a LoginView control, which is why I cannot call "ConfirmationPanel" directly:</p> <pre><code>&lt;asp:LoginView ID="LoginView1" runat="server"&gt; &lt;LoggedInTemplate&gt; &lt;asp:Panel id="ConfirmationPanel" runat="server" Wrap="False"&gt; </code></pre> <p>...</p> <p>Why is this null? It should be referencing the Panel with the ID "ConfirmationPanel", no?</p> <p>Thanks</p>
c# asp.net
[0, 9]
5,113,596
5,113,597
Showing a list of DataTables on DataGrids
<p>I have a very simple scenario but poor experience in this area and googling around didn't help much.</p> <p>Consider a classic ASPX page with C# code behind. Let's say I have a list of <code>DataTable</code>s (or a <code>DataSet</code> with several tables). I need the means to display all tables using one <code>DataGrid</code> per table.</p> <p>I tried binding entire <code>DataSet</code> to <code>DataGrid</code> but it displayed only the first table.</p> <p>Something tells me I should be using a <code>Repeater</code> in conjunction with <code>DataGrid</code> but I need help with this or a totally different (better) alternative.</p>
c# asp.net
[0, 9]
693,634
693,635
jQuery load() not passing complete string in url
<p>I have a function that takes a country name and passes it to a processing page via the load() function.</p> <p>In the following example the country is "American Samoa"</p> <pre><code>function loadRates(oArg) { var Destination = oArg.Destination.toString() || ''; alert(Destination); // Alerts "American Samoa" var uniqueid = new Date().getTime(); $('#divRates2').html('&lt;img src="/images/ajax-loader.gif"&gt;').load('inc_rates_output.cfm?Destination=' + Destination + '&amp;uniqueid=' + uniqueid); } </code></pre> <p>However, the processing page (inc_rates_output.cfm) receives the Destination url variable as "American", i.e. without the "Samoa".</p> <p>Any ideas appreciated.</p>
javascript jquery
[3, 5]
4,591,235
4,591,236
Javascript IF loop takes false and execute the true loop with jquery
<p>Here is jquery code in rails app. The purpose of the code is to eval the value of #rfq_need_report and show the #rfq_report_language if need_report is true or hide if false:</p> <pre><code>$(document).ready(function() { var rpt = $('#rfq_need_report').val(); alert(rpt); if (rpt) { alert(rpt); $('#rfq_report_language').show(); alert('show'); } else { $('#rfq_report_language').hide(); alert(rpt); alert('hide'); } }); // end ready </code></pre> <p>The alert here is just for debug. The rpt is false, however alert('show') gets executed. It seems that the if loop is taking false and decided to execute the loop for true. Sometime If loop is working and sometime it does not. What could cause this strange behavior? Thanks.</p>
javascript jquery
[3, 5]
3,090,761
3,090,762
Jquery hasClass show
<p>I am about to make a menu in drupal with jquery, I need the link to when it has class active it need to be shown.</p> <pre><code>(function ($) { $(document).ready(function() { $('.region-sidebar-first .block-menu ul.menu').children('li').children('a').hasClass('active').hide(); $('.region-sidebar-first .block-menu h2').click(function() { $(this).parent().siblings().children().next().children().slideUp(400); $(this).next('.content').children('.menu').slideDown(400); }); }); }(jQuery)); </code></pre>
javascript jquery
[3, 5]
5,938,694
5,938,695
How do you click text that's inside a hyperlink so you can drag and highlight it?
<p>If you have a paragraph of normal text, you can click anywhere inside the text and drag your mouse to highlight it. However, if the text is inside an anchor/link tag, it won't allow you to click and drag -- the link catches the mouse and prevents it from happening. </p> <p>To see what I mean, find a text link on this page and try to click inside it and drag to select it. It won't let you -- you'll have to click outside the link and drag around it.</p> <p>What do you need to do in JavaScript/JQuery to temporarily disable the link long enough for you to drag and highlight it? </p> <p>The reason I can't just start outside the link is because every word in the paragraph is within a hyperlink -- it's a video transcript and each link is synced to a segment in the video.</p>
javascript jquery
[3, 5]
5,043,847
5,043,848
Wait until loading content
<p>I'm trying to load a table by jQuery load then zebra the table but the content of table is loaded but the zebra fails. If the page is loaded and the table exists the zebra function works.</p> <pre><code>$("#processTab").load("URL"); $(".Innertable tr:nth-child(even)").css("background-color", "#eee"); </code></pre>
javascript jquery
[3, 5]
4,803,991
4,803,992
How to get the value of an ASP.net variable into a javascript textbox
<p>I'm writing some Javascript code for an ASP.net page.</p> <p>I have the string "foo" assigned to a string variable <code>myString</code>.</p> <p>I would like to assign the value of <code>myString</code> to a JavaScript variable, so I write in my ASP.net code:</p> <pre><code>&lt;script type='txt/javascript' language='javascript'&gt; var stringFromDotNet = '&lt;%=myString%&gt;'; &lt;/script&gt; </code></pre> <p>This works fine as long as <code>myString</code> does not contain quotation marks or line-breaks, but as as soon as I try to assign something with quotation marks or line-breaks, all hell breaks loose and my code doesn't work. As a matter of fact, I can see that this code is vulnerable to all sort of injection attacks.</p> <p>So... What can I do get the value of <code>myString</code> assigned to a variable in JavaScript?</p> <p><i>Update</i>: I've tried creating a page with just an ASP:Hidden field. It looks like the values inside are html encoded.</p>
javascript asp.net
[3, 9]
152,744
152,745
Android DateTime Picker Application please help us
<p>Once a time has been chosen, the AM/PM setting is correct on consecutive runs, but I don't know how to set it to the proper AM/PM. in android Dialog box ie.(timepicker ).If anybody knows Please help me</p>
java android
[1, 4]
4,554,591
4,554,592
Search text on javascript
<p>How to search text on javascript.</p> <pre><code>var v=20; str = "The rain 20 in SPAIN stays mainly in the plain"; var patt1=/ain v/gi; var n = str.match(patt1); alert(n); </code></pre> <p>i am trying it but not getting any result. Where am i wrong, any buddy can you please help me out.</p>
javascript jquery
[3, 5]
1,602,875
1,602,876
Change true false in preferences in java
<p>I'm attempting to use a Button from view class to turn off sound from app. (ie: mute) When user pushes box i want code to check if value is already true or flase and then set to opposite using ID called 'mute'. I think i have the IF part setup, just need easy change SharedPreferences from true to flase and vice versa...</p> <p>Here is code framework I'm testing(BEFORE):</p> <pre><code>SharedPreferences getPrefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext()); boolean cmute = getPrefs.getBoolean("mute", defValue); if (cmute == true){ } if (cmute == false){ } </code></pre> <p>I have tried various findings for the solution but most are too complex for this simple need I think..</p> <p>Here is my rework AFTER posted suggestion:</p> <pre><code>if (cmute == false){ Editor editor = getPrefs.edit(); editor.putBoolean("mute", true); editor.commit(); Editor editor2 = getPrefs.edit(); editor.putBoolean("notice", true); editor.commit(); } if (cmute == true){ Editor editor = getPrefs.edit(); editor.putBoolean("mute", false); editor.commit(); Editor editor2 = getPrefs.edit(); editor.putBoolean("notice", false); editor.commit(); } </code></pre>
java android
[1, 4]
4,159,087
4,159,088
String sequence similarity / difference ratio in javascript and python
<p>Say I had a reference string</p> <p>"abcdabcd"</p> <p>and a target string</p> <p>"abcdabEd"</p> <p>Is there a simple way in javascript and python to get the string sequence similarity ratio?</p> <p>Example:</p> <p>"abcdabcd" differs from "abcdabEd" by the character "E" so the ratio of similarity is high but less than 1.0</p> <p>"bcdabcda" differs from "abcdabEd" greatly because every character at a specific string index is different so the similarity ratio is 0.0</p> <p>note that the similarity ratio is not how many similar characters are in each string but how similar the sequences are from each other</p> <p>therefore code like </p> <pre><code># python - incorrect for this problem difflib.SequenceMatcher(None, "bcdabcda", "abcdabEd").ratio() </code></pre> <p>would be wrong</p>
javascript python
[3, 7]
4,520,515
4,520,516
How to display description of input value while calling a function in asp.net?
<p>I want to add description of parameters/value we input in function in asp.net.</p> <p>So that when we call the function it will display description of value which is going to enter.</p> <p>Code:</p> <pre><code>public static void DoingSplit(string name, int id) { // some code } protected void Page_Load(object sender, EventArgs e) { // some code DoingSplit(name,id); } </code></pre> <p>I want to do when someone calling the function</p> <pre><code>DoingSplit( </code></pre> <p>When he press <strong>(</strong> key intellisense display description that which type of value you have to pass.</p> <p>Normally it will show only <strong>string s</strong> in my case.</p> <p>I want to add more descriptions in this. like : <strong>enter string with no spaces.</strong></p> <p>Can any one help me regarding this.</p>
c# asp.net
[0, 9]
5,332,439
5,332,440
"Please wait..." between two page is not working correctly
<p>I have login page which contains some images and ajax contorls, when this page gets refresh all layout and the way page appears, totally awkward. So, after quick searching in the google, I have taken a javascript method and calling this in page load event like this(), it's working fine but only after refreshing the page, means after loading page completely page is being shown.</p> <p>But, problem still remains because before refreshing, page again starts with same awkward condition. So, do I need to call javascript method as soon as my page gets refresh or need to work on my css. Here is my javascript code....</p> <pre><code> function hideBodyloader() { document.getElementById("bodyloader").style.display = "none"; } </code></pre> <p>and css for div....</p> <pre><code> #bodyloader { position: fixed; width: 100%; height: 100%; top: 0; left: 0; z-index: 1000000000; background-color: white; display: block; } .bodyloader { text-align:left; color: Black; font-size: 13px; font-family: Arial, Helvetica, sans-serif; } </code></pre> <p>If there is another way to achieve this please advise me too, but should be on page refresh not on button event.</p> <p>Thanks in advance, any suggestion would be appreciated.......:)</p>
c# asp.net
[0, 9]
6,006,517
6,006,518
What is the Easiest way to stop a soundpool of 4 streams
<p>What is the Easiest way to stop a soundpool of 4 streams.</p> <pre><code> mSoundManager.addSound(1, R.raw.svphorn); mSoundManager.addSound(2, R.raw.svpphaser); mSoundManager.addSound(3, R.raw.svpwail); mSoundManager.addSound(4, R.raw.svpyelp); </code></pre> <p>I need a button to stop all sounds playing @ one time.</p>
java android
[1, 4]
5,487,764
5,487,765
Passing and getting hyperlinks into a single JQuery function
<p>What I would like to do is to take several links that may be on a page and send only the link that was clicked on to a PHP script to be parsed.</p> <pre><code>&lt;a href="?something=2&amp;id=100&amp;somethingelse=55" class="link"&gt;My First Link&lt;/a&gt; &lt;a href="?something=3&amp;id=400&amp;somethingelse=65" class="link"&gt;My Second Link&lt;/a&gt; </code></pre> <p>What I would like is to grab the link and have it passed to PHP. Using this code, I am only ever able to get the first link, no matter which link I click on.</p> <p>I'd rather have one function to send these links into than a function for each and every hyperlink I have in the site. I'm simply trying to condense or consolidate the amount of functions needed that basically do the same thing.</p> <p>Here is what I have so far:</p> <pre><code> $(".link").click(function() { var v1 = $("a.link").attr("href"); // var v1 = $("a.ajax-link")[2].href; var dataString = 'v1='+ v1; $.ajax({ type: "POST", url: "/", data: dataString, dataType: 'json', success: function(data) { if(data.success == 1){ alert(data.success); } else{ alert(data.success); } } }); return false; }); </code></pre>
javascript jquery
[3, 5]
5,048,823
5,048,824
How to create a dynamic tree like structure
<p>I have the details of the members of my family in a database. I want to generate a web page with a family tree generated dynamically by reading from the table.</p> <p>My table schema looks like this</p> <pre><code>id(int) name father(int) mother(int) spouse(int) dateOfBirth </code></pre> <p>where <code>father</code>, <code>mother</code>, and <code>spouse</code> are referencing the <code>id</code> column of the same table. The root node will have null for father and mother.</p> <p>Given this data how can I go about dynamically generating the family tree. I am new at designing tables, so if this design is sub optimal kindly suggest another schema from which this objective can be achieved.</p> <p>Any pointers on how to atleast get started would be highly appreciated.</p>
php javascript
[2, 3]
529,186
529,187
get mouse position with respect to parent element
<p>this is my setup</p> <pre><code>&lt;div id="uxcParent"&gt; &lt;div id="uxcClickable"&gt;&lt;/div&gt; &lt;/div&gt; </code></pre> <p>now when a user clicks in the inner element i want the mouse position with respect to the parent div and not the page.</p> <p>this what i tried.</p> <pre><code> var x= e.pageX- obj.offsetLeft; var y= e.pageY- obj.offsetTop; </code></pre> <p>this works fine only when i don't scroll the page. I want the function to return the same values no matter where my elements are on the same page.</p> <p><b>update</b>:</p> <p>i think it was not clear enough. am detailing more now..</p> <p>consider that the elements are in the document in x position with respect to the document. the page has a scroll bar. now i can scroll to any part of the page and the position is still going to be x. but the position with respect to the view port would have changed. so pageX and pageY will give different values. this is my catch.</p> <p>my elements can be anywhere in the view port and when i go over the inner element i should get co-ordinates with respect to the parent only(should not be influenced by where the parent is)</p> <p>hope i am clear now.</p>
javascript jquery
[3, 5]
3,161,457
3,161,458
setTimeout Problem
<p>i got a problem with <a href="https://developer.mozilla.org/en/window.setTimeout" rel="nofollow">setTimeout</a>.. i dont know why this will not work..</p> <pre><code>$(document).ready(function(){ var counterNum = 0; function tick() { addText(counterNum); setTimeout('tick()',1000); counterNum++; } function addText(strNum) { $("div.counter").empty(); $("div.counter").append(strNum); } });​ </code></pre> <p>you can check it here for the live preview <a href="http://jsfiddle.net/BNF5J/" rel="nofollow">LINK</a></p> <p>and also sir, what is the difference between</p> <pre><code>setTimeout('tick()',1000); </code></pre> <p>and </p> <pre><code>setTimeout(tick(),1000); </code></pre> <p>?</p>
javascript jquery
[3, 5]
2,501,947
2,501,948
Scroll to bottom of page, only if the user already was at the bottom before DOM manipulation
<p>I'd like to learn how to use <code>window.scrollTo</code>.</p> <p>Here's is the desired behavior:</p> <ol> <li>Determine if the user is scrolled to the bottom of the page, or no scroll bar is visible</li> <li>Then I want to grow a DIV, this is working</li> <li>If #1 was true, use <code>window.scrollTo</code> to scroll to the bottom of the page after the DIV has grown which changed the window height.</li> </ol> <p>Ideas?</p>
javascript jquery
[3, 5]
4,977,258
4,977,259
How to bind Request.QueryString[""] to Eval() in ASP.NET
<pre><code>ImageUrl='&lt;%#Eval("Name","../Master Pages/DisasterImages/") %&gt;'+'&lt;%#Eval("Request.QueryString["DisID"].ToString()/{0}") %&gt;' </code></pre> <p><strong>DisID</strong> is a folder name.</p> <p>What i want is to display the images in the directory. I have done it using a repeater control.Problem is now i want to get the folder name in the Query String.How can i do this.Above is the code that i have tried and it doesn't seems to be working....</p> <p>Any help would appreciated</p> <p>Thank you! </p>
asp.net javascript
[9, 3]
4,474,473
4,474,474
Weird stuttering issues that I cannot get rid of (full source included)
<p>I based my game off the lunarlander example and have been having stuttering issues since I first started making it. Nothing I have tried has gotten rid of them so I have gotten to the point where I have spent a few hours creating a stripped down version of the lunarlander example, and put a simple scrolling image in to show the stuttering. NOTE: it is not related to the garbage collector. If you think it is, just look at the log, the garbage collector runs no-where near as often as the stutter appears.</p> <p>The image that scrolls down the screen stutters approximately every second for about 1/10th of a second on my phone (Motorola Milestone, 2.2). This kind of stuttering does not exactly completely destroy gameplay, but it is very distracting and frustrating. My game also involves a lot of fast scrolling and quick movements so it is generally more obvious there.</p> <p>If any of you have the time could you take a quick look at this eclipse project and see if:</p> <ol> <li>It stutters for you on your phone (look closely as it scrolls, it has a small hitch every half second to second and a half)</li> <li>If you can see any way to fix the stuttering</li> </ol> <p>I am hoping I simply have a retarded line of code that is causing this whole thing without me realising. I just can't believe that even after stripping out this much it still has the exact same amount of stutter as my full game with 1000 objects, especially since it runs at a solid 60fps on my phone.</p> <p>EDIT: Have profiled my game on Traceview, it seems fine.</p> <p>Source download link: <a href="http://dl.dropbox.com/u/4972001/LunarLander.rar" rel="nofollow">http://dl.dropbox.com/u/4972001/LunarLander.rar</a></p>
java android
[1, 4]
2,557,932
2,557,933
jQuery: Fix div when browser scrolls to it
<p><a href="http://knowyourmeme.com/memes/pizza-is-a-vegetable" rel="nofollow">http://knowyourmeme.com/memes/pizza-is-a-vegetable</a></p> <p>If you scroll down, the div will lock onto the browser (I'm assuming applying a position: fixed; attribute)</p> <p>How can this be achieved with jQuery?</p>
javascript jquery
[3, 5]
413,118
413,119
a strange popup window opens in website
<p>i have a games website. in that there are more than 4000 flash games available.</p> <p>Now my problem is in my website i am getting a strange popup window whenever i first open up my web site in a day that pop up appears with sometimes google, sometimes yahoo sometimes and somee other sites..i dont know how the popups are coming..</p> <p>i havent added any code for those kind of stuff to open ...can anyone tell me how its happening..</p>
php javascript
[2, 3]
2,042,020
2,042,021
Dynamically call jQuery function
<p>I want to do this:</p> <pre><code>var todo = "text"; $this.eval(todo).split(/\b[\s,\.-:;]*/).length; </code></pre> <p>So that this would be the resulting function:</p> <pre><code>$this.text().split(/\b[\s,\.-:;]*/).length; </code></pre> <p>I can't figure it out...How do I do this?</p>
javascript jquery
[3, 5]
3,241,009
3,241,010
javascript html popup window
<p>I am fairly a beginner with javascript. What I want to do is when I click on a button: <img src="http://i.stack.imgur.com/9iWk3.png" alt="enter image description here"></p> <p>I want it to popup a window. The content of this window is HTML (actually it's a .php) code. As follows: <img src="http://i.stack.imgur.com/WJq4P.png" alt="enter image description here"></p> <p>Then when you click next it scrolls to the next list of movies. What is the easiest javascript/jQuery library to do this?</p> <p>This snippet of pitcure is taken from the website getglue. I tried to firebug the site, but can't seem to find the js code to do it.</p> <p><strong>IMPORTANT:</strong> The movie title and image is taken from a database, and therefore content is not static html. This is where I actually got confused on how to do a dynamic content generated window popup box</p>
php javascript jquery
[2, 3, 5]
3,282,053
3,282,054
how can i extract text after hash # in the href part from a tag?
<p>I have following a tags:</p> <pre><code>&lt;a href="#tab1"&gt;Any tab1 Label&lt;/a&gt; &lt;a href="#tab2"&gt;tab2 Label&lt;/a&gt; &lt;a href="#tab3"&gt;Any tab3 Label&lt;/a&gt; &lt;script&gt; function tellMyName() { alert(this.href); } &lt;/script&gt; </code></pre> <p>Now i want to bind the tellMyName function to all the a tags and get <strong>tab1</strong> if <strong>Any tab1 Label</strong> is clicked, <strong>tab2</strong> if <strong>tab2 Label</strong> is clicked and so on...</p>
javascript jquery
[3, 5]
5,140,776
5,140,777
How to store search result?
<p>I am working on my personal site, where I want to <strong>store my customers recent search</strong> result limited to that <strong>particular session</strong>. </p> <p>I am using <strong>PHP</strong> platform and <strong>Javascripts</strong>.</p> <p><a href="http://www.networksolutions.com/domain-name-registration" rel="nofollow">Here</a> <strong>is an example</strong> of what I am exactly looking at :</p> <p>It <strong>stores</strong> your <strong>previously searched domain</strong> name for that <strong>particular session</strong> so that user can make decision by comparing those results.</p> <p>Thanks.</p> <p><strong>EDIT-</strong> Well Thanks for all of your answers and suggestions.</p> <p>But If you have noticed <a href="http://www.networksolutions.com/domain-name-registration" rel="nofollow">above example</a></p> <p>It looks like some kind of script <strong>loading a new content</strong> on the <strong>same page</strong> without <strong>refreshing</strong> it and <strong>keeping previous search content</strong> <code>&lt;div&gt;</code> as it is.</p> <p>How to achieve this using <strong>javascripts or some sort of div layer</strong> ????</p>
php javascript jquery
[2, 3, 5]
4,525,974
4,525,975
Print float numbers
<p>I am creating Android app and I need to print float number with textView. Could someone say which function should I use?</p>
java android
[1, 4]
3,552,362
3,552,363
Need assistance to understand a piece of code
<p>I'm having difficulties to understand the code below taken from this page <a href="http://trevordavis.net/play/jquery-one-page-nav/" rel="nofollow">http://trevordavis.net/play/jquery-one-page-nav/</a> (tutorial for one page websites). Especially the .do and the Lorem ispum text in the middle of the code and also the reference to section-4. Could you shade some light on that? Many thanks</p> <pre><code>&lt;script src="jquery.js"&gt;&lt;/script&gt; &lt;script src="jquery.scrollTo.js"&gt;&lt;/script&gt; &lt;script src="jquery.nav.min.js"&gt;&lt;/script&gt; &lt;script&gt; $(document).ready(function() { $('#nav').onePageNav(); $('.do').click(function(e) { $('#section-4').append('&lt;p&gt;Lorem ipsum dolor...&lt;/p&gt;'); e.preventDefault(); }); }); &lt;/script&gt; </code></pre>
javascript jquery
[3, 5]
1,042,306
1,042,307
Make a DropdownList visible on click of a RadioButton
<p>When I perform a <code>radiobuttonclick</code>, I want to set a <code>dropdownlist</code> to become visible. The <code>radiobutton</code> and <code>dropdownlist</code> are within the same <code>datagrid</code>. I am not sure how to do this.</p> <pre><code>&lt;asp:UpdatePanel ID="updatepanel" UpdateMode="conditional" runat="server"&gt; &lt;ContentTemplate&gt; &lt;asp:DataGrid ID="DataGrid" AutoGenerateColumns = "false" CssClass="objectSubTitle" ItemStyle-Wrap="true" runat="server" OnItemCommand="handler" &gt;&lt;Columns&gt; &lt;asp:TemplateColumn&gt; &lt;ItemTemplate&gt; &lt;asp:RadioButton ID ="RadioButton1" Text="Yes" GroupName="creatingNewCard" OnCheckedChanged="RadioButtonYes" AutoPostBack="True" runat="server" /&gt; &lt;asp:DropDownList ID="DropDownList1" Visible="false" runat="server"/&gt; &lt;/ItemTemplate&gt; &lt;/asp:TemplateColumn&gt; </code></pre>
c# asp.net
[0, 9]
1,009,204
1,009,205
GridView Lostfocus in edit mode
<p>Can anybody let me know how to display a Pop up to confirm if he wants to save the changes ,when a record is in Edit mode in Gridview and user Clicks or tabs away from the row.</p> <p>Thanks in advance Divya.</p>
asp.net javascript
[9, 3]
2,886,101
2,886,102
how to check the first time user of my App in android?
<p>In my App, first it shows a splash screen. after that another activity, then my main activity must be show. this is my design plan. the second activity(i.e before main activity) must be show for the first time user of the app. if he/she closes the app.splash screen will redirect to main activity automatically. how to do this ? Any Idea? i am developing my app for android phones.</p>
java android
[1, 4]
5,542,779
5,542,780
.NET port with Java's Map, Set, HashMap
<p>I am porting Java code in .NET and I am stuck in the following lines that (behave unexpectedly in .NET).</p> <p><strong>Java</strong>:</p> <pre><code>Map&lt;Set&lt;State&gt;, Set&lt;State&gt;&gt; sets = new HashMap&lt;Set&lt;State&gt;, Set&lt;State&gt;&gt;(); Set&lt;State&gt; p = new HashSet&lt;State&gt;(); if (!sets.containsKey(p)) { ... } </code></pre> <p>The equivalent <strong>.NET</strong> code could possibly be:</p> <pre><code>IDictionary&lt;HashSet&lt;State&gt;, HashSet&lt;State&gt;&gt; sets = new Dictionary&lt;HashSet&lt;State&gt;, HashSet&lt;State&gt;&gt;(); HashSet&lt;State&gt; p = new HashSet&lt;State&gt;(); if (!sets.containsKey(p)) { /* (Add to a list). Always get here in .NET (??) */ } </code></pre> <p>However the code comparison fails, the program think that "sets" never contain Key "p" and eventually results in OutOfMemoryException.</p> <p>Perhaps I am missing something, object equality and identity might be different between Java and .NET.</p> <p><em>I tried implementing IComparable and IEquatable in class State but the results were the same.</em></p> <p><strong>Edit:</strong> </p> <p>What the code does is: If the sets does not contain key "p" (which is a HashSet) it is going to add "p" at the end of a LinkedList>.</p> <p>The State class (Java) is a simple class defined as:</p> <pre><code>public class State implements Comparable&lt;State&gt; { boolean accept; Set&lt;Transition&gt; transitions; int number; int id; // ... public int compareTo(State s) { return s.id - id; } public boolean equals(Object obj) { return super.equals(obj); } public int hashCode() { return super.hashCode(); } </code></pre>
c# java
[0, 1]
610,923
610,924
Confused on setInterval()
<p>I use setInterval() to get the newest datas and draw something at set intervals.But in IE,it only works one time,I searched it in google,it says the cache of IE may be a problem,so I added a time stamp to my url like this:</p> <pre><code>url+"?"+Math.random(); </code></pre> <p>But it still doesn't work,or I made some mistakes?</p> <p>I changed another way to write my function,the former codes are:</p> <pre><code>$(document).ready(function()){ autoRefreshFunction(some parameters){ var interval=setInterval( function(){ main function that gets data and draw },time_interval); } } </code></pre> <p>It only work one time in IE,but chrome is ok.</p> <p>The new codes are:</p> <pre><code>$(document).ready(function()){ var interval=setInterval( function(){ main function that gets data and draw },time_interval); } </code></pre> <p>It works in IE,so I am confused about the difference between this two method.</p>
javascript jquery
[3, 5]
2,265,970
2,265,971
ConcurrentModificationException crashes my app
<p>My Android app has an IntentService where it requests a list of MessageThreads objects from Facebook, parses the JSON response to build an ArrayList of the objects:</p> <pre><code>ArrayList&lt;MessageThread&gt; mMessageThreads = new ArrayList&lt;MessageThread&gt;(); </code></pre> <p>Then it calls FB again in the same service, get the names for the MessageThread ids and matches them with the MessageThread objects. At this point I have an ArrayList with complete MessageThread objects and I insert them into an SQLite db.</p> <pre><code>// save to db and broadcast for (MessageThread message : mMessageThreads) { ((FBClientApplication)getApplication()).getMessagesData().insertOrIgnore(message.toContentValues(); } </code></pre> <p>where:</p> <pre><code>public void insertOrIgnore(ContentValues values) { SQLiteDatabase db = this.dbHelper.getWritableDatabase(); db.insertWithOnConflict(TABLE, null, values, SQLiteDatabase.CONFLICT_IGNORE); } </code></pre> <p>Via ACRA reports I see that intermittently the line</p> <pre><code>for (MessageThread message : mMessageThreads) </code></pre> <p>throws an <code>ConcurrentModificationException</code> and the app forcloses. I haven't been able to isolate under what conditions. I read about this <code>Exception</code> and as I understand it it happens when we remove items from an <code>ArrayList</code> while iterating over it, but I'm not removing items from the list. Any pointers to help with this problem are greatly appreciated.</p>
java android
[1, 4]
2,734,987
2,734,988
Using Regex to remove anything within "<!--" and "/-->"
<p>Hey guys, I have a string like this:</p> <blockquote> <p>Something useful (<strong>less than sign</strong>)!--?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /--(<strong>greater than sign</strong>) Other useful stuff</p> </blockquote> <p>I need to remove anything within the "". Is there an easy way to remove this using regex or a similar method?</p>
c# asp.net
[0, 9]
206,722
206,723
How to add OnClickListener for items from ItemizedOverlay
<p>I have following class extended ItemizedOverlay. This class draws many icons on Google Map (MapView). I need to make a listener for clicking by any item of ItemizedOverlay, but I don't know how I can do it. I hope you can help me. Thank you. </p>
java android
[1, 4]
3,194,811
3,194,812
How to get the index of a particular element
<p>I got the following code from the designer:</p> <pre><code>&lt;table class="items"&gt; &lt;thead&gt; &lt;tr&gt; &lt;th id="name"&gt;name&lt;/th&gt; &lt;th id="category"&gt;category&lt;/th&gt; &lt;th id="zip"&gt;zip&lt;/th&gt; &lt;th id="city"&gt;city&lt;/th&gt; &lt;th id="street"&gt;street&lt;/th&gt; &lt;th id="latitude"&gt;latitude&lt;/th&gt; &lt;th id="longitude"&gt;longitude&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tbody&gt; &lt;tr class="odd"&gt; &lt;td&gt;MyCompany&lt;/td&gt; &lt;td&gt;Company&lt;/td&gt; &lt;td&gt;18360&lt;/td&gt; &lt;td&gt;Stroudsburg&lt;/td&gt; &lt;td&gt;4 Scott Str.&lt;/td&gt; &lt;td&gt;40.9891&lt;/td&gt; &lt;td&gt;-75.1962&lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt; &lt;/table&gt; </code></pre> <p>Using jQuery, how can I get the longitude and latitude values by taking into account the <code>th</code> elements with the specified <code>id</code>? The order of the columns might change later so direct indexing is not an option. However the <code>id</code> values will remain the same.</p>
javascript jquery
[3, 5]
1,070,760
1,070,761
please help onjquery hover
<p>I have two divs. Say div1 and div2. By default div2 is invisible. </p> <p>When the user hovers over div1, I need to display div2. Now if the div2 is hovered then i need to keep displaying this div2 (even if div1 is no longer hovered), otherwise reset the div2's visibility to hidden. </p> <p>How do I keep div2 visible while hovered?</p>
javascript jquery
[3, 5]
2,769,514
2,769,515
how to check the age of registrant during registration using jquery
<p>I want to filter all the user who can register in my website. how can i filter the age of the registrant using jquery allowing 18 years old and above, but when the age is 13 to 17 years old they can register but they must check checkbox for parental consent. I am using a textbox with mm/dd/yyyy format.</p>
javascript jquery
[3, 5]
771,400
771,401
How should I store a small amount of event data and share it between two asp.net pages?
<p>I am a PHP developer and have been asked to make some amends to an Asp.Net site. There is a hardcoded table on one page which contains event information (Date, venue etc). The page uses javascript to toggle table row colours based on whether the event has already happened. </p> <p>I need to add a block on another page which displays 2 upcoming events based on the current date. What is the simplest way to store and share the event data between pages? There is no database available so it needs to be a local file or array etc.</p> <p>I would appreciate some insight on any good libraries / techniques which would be appropriate. This is for a simple, low-traffic site.</p>
c# asp.net
[0, 9]
2,757,815
2,757,816
How to send email
<p>I am New in <code>Asp.net</code>, i need to send email from <code>Asp.net</code> using my <code>Outlook</code>. I have one button in asp and when i click button(send) i want to send email. I tried to use Hotmail and <code>Gmail</code> but remote server in blocked. If you don't understand my question please tell me. I tried this: </p> <pre><code> var smtpClient = new SmtpClient { Host = "outlook.mycompany.local", UseDefaultCredentials = false, Credentials = new NetworkCredential("[email protected]", "myPassword") }; var message = new System.Net.Mail.MailMessage { Subject = "Test Subject", Body = "FOLLOW THE WHITE RABBIT", IsBodyHtml = true, From = new MailAddress("[email protected]") }; // you can add multiple email addresses here message.To.Add(new MailAddress("[email protected]")); // and here you're actually sending the message smtpClient.Send(message); } </code></pre> <p>Exeption Show: <code>The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.1 Client was not authenticated</code> Please how can i do that ?</p>
c# asp.net
[0, 9]
5,883,593
5,883,594
javascript method extension
<p>I need to call "MyOtherFunction" when "MyFunction"(which creates an element) completes, without MyFunction knowing what MyOtherFunction is to update according to created elements.</p> <p>The reason I need this is for extension of a jquery powered fileupload User Control that is used in several places with different functionality. A specific page shows a header and file count for it, and when the upload completes, I need to modify the file count according to how many files are displayed(by created elements) I thought :</p> <pre><code>$(UserControl).on(MyFunction, UploadElem, MyOtherFunction); </code></pre> <p>but this route is not accomplishing anything. The most I can alter the User Control is add in a function call, but without effecting the original user control functionality.</p> <p>I'm not sure if because MyFunction isn't an event and doesn't bubble up or if it just isn't possible to use a defined function as a parameter of .on() is the reason I cannot get this code to work. Any suggestions?</p>
javascript jquery
[3, 5]
5,167,050
5,167,051
Get values of all textboxes with same name attributes in jquery
<p>I need to get values of all textboxes with same name attributes using jquery.</p> <pre><code>&lt;input type="text" id="text1" name="text[]"&gt; &lt;input type="text" id="text2" name="text[]"&gt; &lt;input type="text" id="text3" name="text[]"&gt; </code></pre> <p>How can I get all values of textbox <strong>text[]</strong> and compare it using jquery.</p> <p>I tried using </p> <pre><code> var values = $("input[name='text[]']") .map(function(){return $(this).val();}).get(); </code></pre> <p>but am no successful.</p>
javascript jquery
[3, 5]
3,082,502
3,082,503
Android MediaRecorder release() issue and Video capturing is not in portrait mode
<p>I am facing some issue while developing Video capturing application.</p> <p>1) When I start capturing the Video, the <code>surface view</code> comes in landscape mode. I tried a lot. But i failed. I also referred<br> <a href="http://developer.android.com/reference/android/hardware/Camera.Parameters.html#setRotation%28int%29" rel="nofollow">http://developer.android.com/reference/android/hardware/Camera.Parameters.html#setRotation%28int%29</a> .. but no result</p> <p>2) I am using <code>release()</code> method. but when we use that, after capturing application get closed. if I donot use this in memory card there is a video with no any capture and zero size.</p> <p>Can any body explain why it is happening so?</p> <p>Thanks in Advance</p>
java android
[1, 4]
1,407,440
1,407,441
android sdk set imageview x y coordinates
<p>I'm using an absolutelayout (I know its deprecated). I am adding imageview dynamically but I can't change its position from the top left corner of the screen.</p> <pre><code>ImageView iv = new ImageView(this); iv.setImageResource(R.drawable.orb1); this.addContentView(iv, new AbsoluteLayout.LayoutParams(80, 80, 200, 200)); </code></pre> <p>However, this creates the image with top left at 0, 0 instead of anywhere else. If I change the last two values of Layout Params it still remains in that position.</p> <p>Can someone assist? Thanks.</p> <p>Edit: Using relative layout still doesn't work </p> <pre><code>ImageView iv = new ImageView(this); iv.setImageResource(R.drawable.orb1); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(80, 80); params.topMargin=50; params.leftMargin=50; this.addContentView(iv, params); </code></pre>
java android
[1, 4]
964,916
964,917
c# populate textboxes using sqldatareader method
<p>I created the below method which i tested and does return the correct data. Where I am confused is what is the proper way to populate individual textboxes on a form with the results from this method? </p> <p>Rather than using an objectdatasource and then binding a gridview to the objectdatasource that works but I need more freedom to customize the form.</p> <pre><code>public MemberDetails GetMemberDetail(int membershipgen) { SqlConnection con = new SqlConnection(connectionString); SqlCommand cmd = new SqlCommand("usp_getmemberdetail", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new SqlParameter("@MEMBERSHIPGEN", SqlDbType.Int, 5)); cmd.Parameters["@MEMBERSHIPGEN"].Value = membershipgen; try { con.Open(); SqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow); reader.Read(); MemberDetails mem = new MemberDetails((int)reader["MEMBERSHIPGEN"], (string)reader["MEMBERSHIPID"], (string)reader["LASTNAME"], (string)reader["FIRSTNAME"], (string)reader["SUFFIX"], (string)reader["MEMBERTYPESCODE"]); reader.Close(); return mem; } catch (SqlException err) { throw new ApplicationException("Data error."); } finally { con.Close(); } </code></pre>
c# asp.net
[0, 9]
5,620,941
5,620,942
Comparing double values
<p>I have a double whose value i get dynamically and the value is 0.94289988675 and also i get a another double whose value is 0.94289988777 .I just need to compare the two values. But it says they are not same. How can i compare till first four digits of those values.</p> <p><strong>Code</strong>: </p> <pre><code>for (z = 0; z &lt; something.Count(); z++) { if (largest == Math.Round(0.94289988675 [z],4)) { //proceed } } </code></pre> <p>largest = 0.94289988675 0.94289988675[z] comes 0.94289988777. z is.</p> <p>It does not go in the loop. Please help me out.</p>
c# asp.net
[0, 9]
425,705
425,706
Does java have an equivalent to python __call__?
<p>Just started learning python, I've come across <code>__call__</code> method. I understand when <code>__init__</code> gets called and when <code>__call__</code> gets called by running a simple example:</p> <pre><code>class Constructor: def __init__(self, a): print "__init__ called" def __call__(self): print "__call__ called" def dummy(self): print "a dummy method called" print "creating x obj" x = Constructor(1) print "calling x object" x() </code></pre> <p>console output:</p> <pre><code>creating x obj __init__ called calling x object __call__ called </code></pre> <p>My questions are:</p> <ol> <li>I come from java background, I know <code>__init__</code> maps to java constructor, does java have an equivalent to <code>__call__</code> to help me understand this better?</li> <li>Can someone give me a simple example of when <code>__call__</code> can be useful?</li> </ol>
java python
[1, 7]
3,917,677
3,917,678
Show information based on what button that was pressed
<p>I'm making a information app for Android and I can't figure out how to change a button depending on which button was pressed in a previous class.</p> <p>I made this picture that shows how the app works: </p> <p><img src="http://i.imgur.com/Q3a5f.jpg" alt="Flowchart"></p> <p>After clicking the first button you get to a new class with 2 new buttons that sends you to the same class but the 3 buttons there is supposed to change depending on which one of the two buttons you pressed, the three buttons you get sent to sends you to the same class but there is a TextView that changes text depending on what button you pressed.</p> <p>So I need to add some kind of information to the button (an intent?) so it knows what you pressed earlier.</p> <p>I'm kinda new to Java and Android so I'm sorry if I explained in a weird way.</p> <p>Thanks in advance</p>
java android
[1, 4]
3,688,165
3,688,166
ASP.Net codebehind can't access component from page?
<p>For an unknown reason, I have 1 page that I can't access by ID to any of the component.</p> <p>Here is some informations. The page use asp:Content because the website use MasterPage. Inside the asp:Content, this page has a asp:FormView with some data that I cannot access from the CodeBehind.</p> <p>Here is the Page declaration:</p> <blockquote> <p>&lt;%@ Page Language="C#" AutoEventWireup="true" CodeFile="InfoAccount.aspx.cs" Inherits="Private_InfoAccount" MasterPageFile="~/MasterPagePrincipal.master" %></p> </blockquote> <p>Here is the code in the page behind that doesn't compile :</p> <pre><code>protected void FormView1_PreRender(object sender, EventArgs e) { DateBirthdayValidator.MaximumValue = DateTime.Now.Date.ToString("dd-MM-yy"); } </code></pre> <p>Here is the error : </p> <blockquote> <p>Error 2 The name 'DateBirthdayValidator' does not exist in the current context</p> </blockquote> <p>I have search in google, I got some answer about using FindControl but it doesn't work. Any idea?</p> <h2>Edit1:</h2> <p>I can access the FormView1 component but no the validator inside the EditItemTemplate. How can I access control that is inside the EditTemplate?</p> <h2>Edit2:</h2> <p>If I try: <code>FormView1.FindControl("DateBirthdayValidator")</code> it compile but always return null. So still doesn't work but at least I can access the FormView1...</p>
c# asp.net
[0, 9]
611,223
611,224
Android's InputManager::registerInputDeviceListener isn't calling my listener
<p>I'm trying to get a notification when input devices are added/removed, and from what I understand that's what registerInputDeviceListener should do... but my listener isn't being called!</p> <p>Here's a snippet of my code:</p> <pre><code>InputManager im = (InputManager) getSystemService(Context.INPUT_SERVICE); im.registerInputDeviceListener(new InputManager.InputDeviceListener() { @Override public void onInputDeviceAdded(int deviceId) { Log.d("Input", "InputDeviceAdded: " + deviceId); } @Override public void onInputDeviceRemoved(int deviceId) { Log.d("Input", "InputDeviceRemoved: " + deviceId); } @Override public void onInputDeviceChanged(int deviceId) { Log.d("Input", "InputDeviceChanged: " + deviceId); } }, null); </code></pre> <p>And here's what I see in logcat when I unplug my usb mouse:</p> <pre><code>01-15 19:19:04.025: INFO/EventHub(5935): Removing device '/dev/input/event0' due to inotify event 01-15 19:19:04.025: INFO/EventHub(5935): Removed device: path=/dev/input/event0 name=Primax USB OPTICAL MOUSE id=11 fd=245 classes=0x80000008 01-15 19:19:04.045: INFO/InputReader(5935): Device removed: id=11, name='Primax USB OPTICAL MOUSE', sources=0x00002002 </code></pre> <p>But my listener never gets called... </p>
java android
[1, 4]
3,112,479
3,112,480
jQuery if statement causes browser to crash
<p>I have a small script that should show a hidden div if the corresponding button is pressed. For example, if the button first-button is clicked than the div first-button-content should show. Right now, when I click on the button, chrome crashes and the div does not show. </p> <p>Here is the html:</p> <pre><code> &lt;div class="home-middle-buttons"&gt; &lt;div class="first-button"&gt; &lt;span&gt;I’m an In-House Marketer&lt;/span&gt; &lt;/div&gt; &lt;div class="second-button"&gt; &lt;span&gt;I Work at an Agency&lt;/span&gt; &lt;/div&gt; &lt;div class="third-button"&gt; &lt;span&gt;I’m a Business Owner&lt;/span&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="home-middle-content"&gt; &lt;div class="first-button-content"&gt; &lt;p&gt;Lorem ipsum dolor&lt;/p&gt; &lt;/div&gt; &lt;div class="second-button-content"&gt; &lt;p&gt;Lorem ipsum dolor&lt;/p&gt; &lt;/div&gt; &lt;div class="third-button-content"&gt; &lt;p&gt;Lorem ipsum dolor.&lt;/p&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>Here is the script: </p> <pre><code>jQuery(document).ready(function() { jQuery(".home-middle-buttons div").click(function() { if (jQuery(".first-button").click()) { jQuery(".first-button-content").css( 'display', 'block' ); } else { jQuery(".second-button-content").css( 'display', 'block' ); } }); }); </code></pre>
javascript jquery
[3, 5]