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
194,801
194,802
jQuery ajax and append - content too large?
<p>I am writing an ajax search page that contains a search box and "tabs"; the idea is that a user enters a query, changes the tab, the query is submitted with new options, and results loaded below.</p> <p>I am having a weird issue where the length(?) of the data ('content') returned seems to stop me running any extra JS.</p> <p>See below, #resultsArea is designed to have several sets of results in it as a user flicks between tabs so it'll show cached results if the query is the same rather than sending another unnecessary db query.</p> <p>"Content" is the data returned - and it seems as soon as I use this (whether it be in an alert, or printed on the page), I cannot execute any more javascript. If I remove +content+ from the .append function, the alert following the line will fire. Is this by design?</p> <p>"Content" contains quite a large quantity of data - loads of s and formatting, so I wonder if this is the issue. However this all works and displays OK as it is! I just want to add some extra JS so I can load adverts into the rendered results, but this is stumping me.</p> <pre><code>$.ajax({ type: 'POST', url: formUrl, data: formData, dataType: 'html', success: function(content) { $('#resultsBit').slideUp(200); if (query!=prevQuery) { $('#results_'+flavour).remove(); } alert('I will fire'); $('#resultsArea').append('&lt;div id="results_'+flavour+'" style="display:true;"&gt;'+content+'&lt;/div&gt;'); alert('I will not fire'); } }); </code></pre> <p>Thanks in advance for any pointers.</p>
php javascript jquery
[2, 3, 5]
3,162,877
3,162,878
Stopping and resuming timer in jQuery
<p>I've got two solutions. The first of them using the method <code>animate</code>:</p> <p><a href="http://jsfiddle.net/g9aK8/3/" rel="nofollow">http://jsfiddle.net/g9aK8/3/</a></p> <p>The problem is with a delay, when we pause timer for example on 400px and resume then we have to wait again all delay (the speed of bar is absolutely lower). </p> <p>In the second solution I used <code>interval</code>:</p> <p><a href="http://jsfiddle.net/6wNcd/1/" rel="nofollow">http://jsfiddle.net/6wNcd/1/</a></p> <p>It looks better, but when I tried stop this after a few minutes I had to wait something about 30 seconds then stopped. I not sure that using here <code>interval</code> with that small value is correct.</p> <p>Have you any ideas how do this smartly?</p>
javascript jquery
[3, 5]
358,558
358,559
How can I create a progress bar with percentage?
<p>I want to create a progress bar with jquery or javascript that finds the percentage while loading the javascript. All the images are loaded in the javascript, they use the jquery append tag and so I want to load all these images with a screen that is shown with a loading bar based on percentage of how much of the data has been loaded. What is the best way to do this?</p>
javascript jquery
[3, 5]
3,290,231
3,290,232
javascript object help
<p>I'm following a tutorial on how to make a javascript game, but i'm stuck on the return part. Why are is there { }, and what is the init: init for? Any help would be appreciated. Thanks.</p> <pre><code>var JS_SNAKE = {}; JS_SNAKE.game = (function () { var ctx; var xPosition = 0; var yPosition = 0; var frameLength = 500; //new frame every 0.5 seconds function init() { $('body').append('&lt;canvas id="jsSnake"&gt;'); var $canvas = $('#jsSnake'); $canvas.attr('width', 100); $canvas.attr('height', 100); var canvas = $canvas[0]; ctx = canvas.getContext('2d'); gameLoop(); } function gameLoop() { xPosition += 2; yPosition += 4; ctx.clearRect(0, 0, 100, 100); //clear the canvas ctx.fillStyle = '#fe57a1'; ctx.fillRect(xPosition, yPosition, 30, 50); //a moving rect setTimeout(gameLoop, frameLength); //do it all again } return { init: init }; })(); $(document).ready(function () { JS_SNAKE.game.init(); }); </code></pre>
javascript jquery
[3, 5]
3,176,295
3,176,296
create list of tuple (long integer)
<p>Can we create a list of tuple of long integer. I have gone through which says that Python type is variable. Is it Possible in Python.</p> <p>Reason. C++ code has migrated from 32 bit to 64 bit machine and long size become 8 in 64 bit machine but Python is still in 32 bit machine.</p> <p>First I put lot off effort to fix from C++ side but later feel but we increase datatype in Python it may require minimum change.</p> <p>As of now it is defined in following way. Can I upgrade to long<br> temp = [ (0,0), (1,0), (1, 1), (0, 1), (0,0) ]</p> <p>Adding more info for better clarification: Generally we have declare long variable which we assign value from PyInt_AsLong() . which was working fine in 32 bit machine. if I change to int than we have done lot of places long conversion. and the value of int become garbage. But if I use long variable than I am getting error from Python Interface " Python int too large to convert to C long". So I am stuck with problem.Not able to figure out exact solution.</p>
c++ python
[6, 7]
752,810
752,811
Use jQuery to attribute selector to select all IDs and run a function
<p>I want to get all the IDs that start with blblblb_ and run a separate JS function that I made. Here is what I have, it is only getting the first ID:</p> <pre><code>$(window).scroll(function() { var test = $('div[id^="blblblb_"]').attr('id'); foo(test); }); </code></pre> <p>Any ideas what I'm doing wrong?</p>
javascript jquery
[3, 5]
1,097,307
1,097,308
Edit history like Stackoverflow itself
<p>I am trying to implement the Editing History functionality like this website itself which shows the initial post and how the edits were made. </p> <p>Is there any specific name for this functionality and any source code available for it? </p>
c# asp.net
[0, 9]
213,734
213,735
call functions from JQuery - better way
<p>I want to call a JQuery function on window resize and also during the initial load. I just tried this, I am sure there is a better way, Please explain this learner,</p> <pre><code>$(document).ready(function () { $(function () { var doosomething = function () { $('#bottomDiv').css('top', $(window).height() - 105); } $(window).resize(doosomething); }); }); </code></pre>
javascript jquery
[3, 5]
4,837,266
4,837,267
Combining string and object as a jQuery selector
<p>I'm having a hard time finding the solution for this for some reason -- perhaps it's right under my nose.</p> <p>But is there a way to essentially combine a string and an object so I'm not repeating the same method on a certain event?</p> <pre><code>$j(window).resize(function(){ //stuff here }); $j('body').resize(function(){ //same stuff here }); </code></pre> <p>Maybe I'm just thinking about it the wrong way?</p> <p>Thanks.</p>
javascript jquery
[3, 5]
3,668,372
3,668,373
Why is the boolean variable always resetting to false;
<p>I have a boolean variable declared at the top of a class and when a radio button is selected on a page, the variable gets set to true, but when the page is reloaded, the variable gets reset back to false. One way I have handled this was by using the static keyword, but I am not sure if this is the best way to handle this. Here is the class where I tried doing things in the Page_Load event, but it is still resets the variables to false.</p> <pre><code>public class SendEmail { bool AllSelected; protected void Page_Load(object sender, EventArgs e) { if(!Page.IsPostBack) { AllSelected = false; } } protected void rbAll_SelectedIndexChanged(object sender, EventArgs e) { if(rbAll.SelectedValue == "All") AllSelected = true; } public Send() { if(AllSelected) { //Send Email. Never runs because AllSelected is always false; } } } </code></pre>
c# asp.net
[0, 9]
527,091
527,092
jQuery getting element index despite wrapper / parent element?
<p>I have divs with same class, but each 3 are wrapped in a parent div. I can't get the index the way I want it. I am sorry, could anyone help me to get the index as number from 0 to 8.. when i click on any element? despite the parent element.</p> <p>Here is my full code for your testing.</p> <pre><code>&lt;div class="more-content"&gt; &lt;div class="post"&gt;post 1&lt;/div&gt; &lt;div class="post"&gt;post 2&lt;/div&gt; &lt;div class="post"&gt;post 3&lt;/div&gt; &lt;/div&gt; &lt;div class="more-content"&gt; &lt;div class="post"&gt;post 4&lt;/div&gt; &lt;div class="post"&gt;post 5&lt;/div&gt; &lt;div class="post"&gt;post 6&lt;/div&gt; &lt;/div&gt; &lt;div class="more-content"&gt; &lt;div class="post"&gt;post 7&lt;/div&gt; &lt;div class="post"&gt;post 8&lt;/div&gt; &lt;div class="post"&gt;post 9&lt;/div&gt; &lt;/div&gt; &lt;script type="text/javascript"&gt; $(function() { // navigate posts with next/prev buttons $(".post").click(function(){ alert($(this).index()); }); }); &lt;/script&gt; </code></pre> <p>If i click i get index 0, 1, 2 ..i think because each 3 items are wrapped in parent? I am new with jquery, any help appreciated. what i need is get the index of post with same class.. say post 6 = index 5.. and so on</p> <p><strong>UPDATE How can I get the same result if the clicked element is a child anchor in the post div and not the post div directly?</strong></p>
javascript jquery
[3, 5]
5,389,191
5,389,192
Could not get the updated value of textbox once the page is redirected
<p>I am building a web application in c# and asp.net.I am trying to access the value of textbox and generate a preview in next page with the content of textbox in the page1.When I am generating the preview for first time it works well,but the next time when I change the content of the textbox the value of textbox.Text remains the same.I thought that it is due to the session variable not working fine and posted <a href="http://stackoverflow.com/questions/7805265/unable-to-get-updated-value-of-session-variable-and-textbox">this</a> but when I printed the value of textbox in the same page using </p> <pre><code>Response.Write(TextBox1.Text ); </code></pre> <p>it prints the initial value.</p> <p>Please tell me where I am going wrong.</p>
c# asp.net
[0, 9]
1,907,571
1,907,572
Android reading file from memory card limits to 10kb on samsung phones
<p>I'm trying to read contents from a file stored on the sdcard on an android phone. For this I use the following code:</p> <pre><code>public String readIt(File file) { StringBuffer sb = new StringBuffer(); try { BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), encoding)); String line; while (( line = reader.readLine()) != null) { sb.append(line + '\n'); } reader = null; } catch (FileNotFoundException e) { Toast.makeText(this, "File not found", Toast.LENGTH_SHORT).show(); return null; } catch (IOException e) { Toast.makeText(this, "Error reading file", Toast.LENGTH_SHORT).show(); return null; } return sb.toString(); } </code></pre> <p>This has been bothering me for a while, any idea of why it cuts of on samsung phones? And does anyone have a suggestion of how to solve it and also keeping the file encoding when reading it?</p>
java android
[1, 4]
3,948,509
3,948,510
How to do skip and take functions in javascript for Json array
<p>I want to do that in javascript:</p> <pre><code> for (int i = 0; i &lt;= pieces; i++) { List&lt;product&gt; piecesProuducts = productList.Skip(i * 2).Take(2).ToList(); } </code></pre> <p>I have a json array. I want to get two records block from this json array as above linq code in javascript. Is that possible and how?</p>
javascript jquery asp.net
[3, 5, 9]
4,404,223
4,404,224
How to load other web page in ASP.NET
<p>I want to load some fixed part from other website to my web application. How to accomplish this? Thanks.</p>
c# asp.net
[0, 9]
2,143,157
2,143,158
Prevent Click Fraud in Advertisement system with PHP and Javascript
<p>I would like to build an Advertising project with PHP, MySQL, and Javascript. I am talking about something like...</p> <ul> <li>Google Adsense</li> <li>BuySellAds.com</li> <li>Any other advertising platform</li> </ul> <p>My question is mainly, what do I need to look out for to prevent people cheating the system and any other issues I may encounter?</p> <p>My design concept. An Advertisement is a record in the Database, when a page is loaded, using Javascript, it calls my server which in turn will use a PHP script to query the Database and get a random Advertisement. (It may do kore like get an ad based on demographics or other criteria as well) The PHP script will then return the Advertisement to the server/website that is calling it and show it on the page as an Image that will have a special tracking link.</p> <p>I will need to...</p> <ul> <li>Count all impressions (when the Advertisement is shown on the page)</li> <li>Count all clicks on the Advertisement link</li> <li>Count all Unique clicks on the Advertisement link</li> </ul> <p>My question is purely on the query and displaying of the Advertisement and nothing to do with the administration side. If there is ever money involved with my Advertisement buying/selling of adspace, then the stats need to be accurate and make sure people can't easily cheat the system. Is tracking IP address really the only way to try to prevent click fraud?</p> <p>I am hoping someone with some experience can clarify I am on the right track? As well as give me any advice, tips, or anything else I should know about doing something like this?</p>
php javascript
[2, 3]
4,781,498
4,781,499
jquery script not working under chrome, safari and partially opera, FF is ok
<p>today I have been asking here for help with this <a href="http://stackoverflow.com/questions/8397096/select-exact-number-of-table-td-after-a-radiobutton-is-checked">script</a>.</p> <p>It was successfully done – thanks again to RKW.</p> <p>I've merge the code with my previous one, and everthing seems working well – under FF. But now, I've tryed it under Chrome, Safari (mac) and Opera. In Chrome and Safari the script isn't doing enything at all (and the error console stay clear). Under opera only the first part is working – the class active is added.</p> <p>Any suggestions?</p> <pre><code>$(document).ready(function(){ $('input').focus(function() { /* add class active to parent div */ $('div').removeClass('active'); $(this).parent().parent().parent().addClass('active'); $(this).closest("div").addClass('active'); }); $('input:radio').focus(function() { /* add class highlight to specified tds in one column */ var num = 2; var col = $(this).closest('td').index() + 1; var row = $(this).closest('tr').index(); var tds = $('td:nth-child(' + col + ')'); tds = tds.slice(row,row+num); $('td').removeClass('highlight'); tds.addClass('highlight'); }); }); </code></pre>
javascript jquery
[3, 5]
1,482,815
1,482,816
I want to make a web application to sending mail
<p>I want to make web application to my personal use for sending emails to my friends.</p> <p>I'm using my gmail id to sending mail to other any one have idea how send mail to other using my gmail id i'm using asp.net with c#.</p>
c# asp.net
[0, 9]
2,971,690
2,971,691
Remove web content emails and add spam protected content?
<p>I have job crawler website, which crawls list 10,000 of jobs in my website, however i have a issue with some job descriptions has direct email link saying </p> <p>please email your resume to hr@xxx.com . This results in a spam attacks for them, So i need find a solution where i can hide these emails from the spam bots and BUT i need to show them to the valid human user. </p> <p>I am wondering about the possible solutions and few things comes into my mind are </p> <ol> <li><p>May be doing a preg replace to email and replace email with "click here view email" do some JavaScript script to retrieve the actual email when clicked.</p></li> <li><p>Use captcha text to enter and get the email (very inconvenience for the end user)</p></li> </ol> <p>Any other possible solutions ?</p>
php javascript jquery
[2, 3, 5]
2,053,221
2,053,222
android is my application still running?
<p>i have this thread which run as a service:</p> <pre><code> public void run() { try { while(true) { Thread.sleep(timeInterval); results = sendGetMessage(); b.putString("results", results); receiver.send(2, b); } } catch (InterruptedException e) { results = e.toString(); } this.stop(); } </code></pre> <p>i want to write a simple function which will check if my application is still running (in order to replace the everlasting while(ture) i've written). something like: while(isMyAppRunning). my problem now that even when i'm closing the app, the service keep on running.. can someone please be kind and give me a code example?</p>
java android
[1, 4]
2,414,755
2,414,756
jQuery get multiple rel values from anchor
<p>Is it possible to get multiple rel values from a single anchor in jQuery or generally in JavaScript without splitting the rel into an array?</p> <p>For example, in the case of an anchor having two rel attributes delimited by the standard space:</p> <pre><code>&lt;a id='a' class='b' rel='9 9' href='#'&gt;Link&lt;/a&gt; </code></pre> <p>I can get each by using:</p> <pre><code>$('.b').click(function(e) { /* ... */ var rels = $(this).prop('rel').split("_"); $('form#form-stage-2 input[name=sleeve_t]').val( rels[0] ); $('form#form-stage-2 input[name=sleeve_n]').val( rels[1] ); /* ... */ }); </code></pre> <p>But was wondering if something along the lines of might be valid?</p> <pre><code>$('.b').click(function(e) { /* ... */ $('form#form-stage-2 input[name=sleeve_t]').val( $(this).prop('rel[0]') ); $('form#form-stage-2 input[name=sleeve_n]').val( $(this).prop('rel[1]') ); /* ... */ }); </code></pre>
javascript jquery
[3, 5]
5,625,928
5,625,929
C# Array of objects
<p>I've consumed a web service with two classes "address" and "request." One of the properties of the request object is an array of address objects:</p> <pre><code>request _req = new request(); _req.addresses = // expecting address[] </code></pre> <p>I know I'm doing this wrong (as I keep getting exception errors) so I'm hoping someone can help me out. How do I create an array of address objects and set the "_req.addresses" value equal to that object (address[])? I get an "object reference not set to an instance..." error on the second line, when trying to set the city value equal to the string _q.LocationA.City... so these aren't working:</p> <pre><code> address[] _address = new address[1]; _address[0].city = _q.LocationA.City; _address[0].state = _q.LocationA.State; _address[0].street = _q.LocationA.Address; _address[0].zipCode = _q.LocationA.Zip; request _req = new request(); _req.addresses = _address; </code></pre> <p>And I've tried this:</p> <pre><code> address _address = new address(); _address.city = _q.LocationA.City; _address.state = _q.LocationA.State; _address.street = _q.LocationA.Address; _address.zipCode = _q.LocationA.Zip; request _req = new request(); _req.addresses[0] = _address; </code></pre>
c# asp.net
[0, 9]
5,901,831
5,901,832
'jQuery' is undefined
<p>I'm trying to use the Fullscreenr Jquery plugin in my asp.net project. Here is the code on my master page:</p> <pre><code>&lt;script src="Fullscreenr/jquery-1.3.2.min.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="Fullscreenr/jquery.fullscreenr.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; var FullscreenrOptions = { width: 907, height: 680, bgID: '#bgimg' }; jQuery.fn.fullscreenr(FullscreenrOptions); &lt;/script&gt; </code></pre> <p>It fails on the <code>jQuery.fn.fullscreenr(FullscreenrOptions);</code> line. The full error is :</p> <blockquote> <p>Microsoft JScript runtime error: 'jQuery' is undefined.</p> </blockquote> <p>Any ideas?</p>
javascript jquery asp.net
[3, 5, 9]
4,963,543
4,963,544
Count how many times user has loaded a page on my site?
<p>I'm wondering if I can count the times user loads pages on my site, with JavaScript. Probably like this?</p> <pre><code>var pageloads = 1; $(document).ready(function(){ var pageloads =++ }); </code></pre> <p>But where would I store it? In a cookie?</p>
javascript jquery
[3, 5]
4,075,263
4,075,264
Mega Menus using using Asp.net C#
<p>I need to create an option at work to use mega menus, basically the designer should be able to set the level per columns for the mega menus so if there are 10 items under one category and the designer sets the level to 2 then the megamenu for that category should split into two columns of 5 items. What would be the best way to implement this using Asp.net C# and JQuery so it looks nice?.</p> <p>Also, how can i do it so that if there are 10 items I can break it into columns of 5?</p> <p>Relevant information: - The data for the menu is comming from a table. - The menu will be horizontal</p> <p>I am not asking for the code but for the best approach and also the best way to go about this.</p> <p>Thank you!</p>
c# asp.net
[0, 9]
964,137
964,138
session in asp.net C#
<p>basically i have 3 pages, log in page, main page and registration page.</p> <p>My users have 2 access level, admin and User.</p> <p>Admin can go to registration apge, User can't.</p> <p>On log in page, there are 2 session, Name and Role.</p> <p>on page load, I clear both session.</p> <p>If log in is succeeded, I filled in the values.</p> <p>My problem is..</p> <p>I log in as Admin, Session["Name"]="admin"; Session["Role"]="Admin";</p> <p>I go to main page, then to registration page with hyper link. (enable only for admin)</p> <p>On registration pageload, I check the role. If it is not access, I redirect to main page.</p> <p>Every page has logged out hyper link.</p> <p>I will redirect that link to log in page.</p> <p>As I clear the session values at the loading of log in page, they are all clear.</p> <p>When I get to Admin page, I copy the URL.</p> <p>I log out and log in as someone else with User access.</p> <p>I go to Main page.</p> <p>I can't go to registraion page as the hyper link is disable.</p> <p>But when I paste the URL, it can go to registration page.</p> <p>Only when I click something, it will redirect to main page as the page_load function is not run at the first time.</p> <p>Any idea?</p>
c# asp.net
[0, 9]
1,227,288
1,227,289
Link button control using asp.net
<p>I have one link button in master page and one dropdown list in content page . Can any one tell How to change the visibility of the dropdown list.</p>
c# asp.net
[0, 9]
3,944,478
3,944,479
Exception when inserting row to database
<p>I've written this code to insert a row into the database:</p> <pre><code>SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["earchConnectionString"].ConnectionString); //string insCmd = "Insert into [node] (title, parent_id, oid, display, linkById, customLinks, contentType) values (@title, @parent_id, @oid, @display, @linkById, @customLinks, @contentType)"; string insCmd = "Insert into [node] (title) values (@title)"; SqlCommand insertUser = new SqlCommand(insCmd, con); insertUser.Parameters.AddWithValue("@title", TextBoxTitle.Text); try { insertUser.ExecuteNonQuery(); con.Close(); Response.Redirect("addNode.aspx"); Label1.Text = "update success"; } catch (Exception er) { Label1.Text = er.StackTrace; } </code></pre> <p>The stack trace:</p> <pre><code>at System.Data.SqlClient.SqlConnection.GetOpenConnection(String method) at System.Data.SqlClient.SqlConnection.ValidateConnectionForExecute(String method, SqlCommand command) at System.Data.SqlClient.SqlCommand.ValidateCommand(String method, Boolean async) at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) at System.Data.SqlClient.SqlCommand.ExecuteNonQuery() at Admin_addNode.Button1_Click(Object sender, EventArgs e) in c:\inetpub\web1\Admin\addNode.aspx.cs:line 52 </code></pre> <p>Anyone know what's the problem?</p>
c# asp.net
[0, 9]
1,510,029
1,510,030
Issues with Android ImageView
<p>I have an application which allows the user to upload pictures from gallery or take photos using camera. everything works fine, but when i display the bitmap in the image view, the image view will be bigger then the required size, trying to fill the parent even if i had set it's layout params to wrap content.</p> <p>why is this so?</p>
java android
[1, 4]
5,005,560
5,005,561
button click event automatically fires
<p>My situation is like this i have a asp button inside my user control </p> <pre><code> &lt;asp:Button ID="btnSubmit" Text="Send Notification" class="submit-btn01" onclick="btnSubmit_Click1" runat="server" /&gt; </code></pre> <p>in my browser when I refresh my page, button click event automatically happens.i cant figure out what is wrong with this..</p>
c# asp.net
[0, 9]
5,550,486
5,550,487
Trying to show message in asp.net using Javascript
<p>I am doing project in asp.net in C#. I am trying to show message in script format. For that i am using the below code</p> <pre><code>Page page = new Page(); page.ClientScript.RegisterClientScriptBlock(this.GetType(), "Key", "alert('Your Full Name Sucessfully Updated...');", true); </code></pre> <p>but it is not showing any error. or warning. even it is not showing the messege. kindly suggest me and help me.</p> <p>Thanks and Regards</p>
c# javascript asp.net
[0, 3, 9]
1,987,638
1,987,639
Jquery click function effect
<p>I have a jquery code, but I'm a little bit confused on how can I put a css on this:</p> <pre> $(document).ready(function () { $('span.account-menu').click(function () { $('ul.menu').slideToggle('medium'); }); }); </pre> <p>I wanted to add this css in the click function.</p> <pre> border: 1px solid #999999; background-color: #333333; </pre> <p>This style, I wanted to effect only in 'span.account-menu' and not affecting ul.menu. I try the code that you have given but the problem is when I click back the menu the style will not disappear.</p>
javascript jquery
[3, 5]
4,759,715
4,759,716
how to close current window in php
<p>I want to take a value in session then close the current window.</p> <pre><code>if(isset($_POST['ok'])) { echo "&lt;script type='text/javascript'&gt;"; echo "closeCurrentWindow()"; echo "&lt;/script&gt;";; } </code></pre> <p>why thish is not working?</p>
php javascript
[2, 3]
3,370,591
3,370,592
Replace input value .val() with jQuery
<p>So basically here is my jsFiddle - <a href="http://jsfiddle.net/CmNFu/" rel="nofollow">http://jsfiddle.net/CmNFu/</a> .</p> <p>And code also here -</p> <p>HTML -</p> <pre><code>&lt;b style="float: left; margin-right: 10px;"&gt;category 1&lt;/b&gt;&lt;input type="checkbox" value="category1" style="float: left;" class="portfolio-category" /&gt;&lt;br /&gt; &lt;b style="float: left; margin-right: 10px;"&gt;category 2&lt;/b&gt;&lt;input type="checkbox" value="category2" style="float: left;" class="portfolio-category" /&gt;&lt;br /&gt; &lt;br /&gt; &lt;br /&gt; &lt;input type="text" name="categories" id="portfolio-categories" /&gt;​ </code></pre> <p>jQuery -</p> <pre><code>jQuery(document).ready(function() { jQuery(".portfolio-category").click(function() { if(jQuery(this).is(":checked")) { jQuery("#portfolio-categories").val(jQuery("#portfolio-categories").val()+" "+jQuery(this).val()); } else { var portfolioCategories = jQuery("#portfolio-categories").val(); alert("before + "+portfolioCategories); var currentElement = jQuery(this).val()+" "; alert(currentElement); portfolioCategories = portfolioCategories.replace(currentElement, ""); alert(portfolioCategories); } }); }); </code></pre> <p>​Well basically what I would like to achieve is, when user checks the checkbox, the value automatically adds inside input field (Done, it's working, whooray!), but the problem is when it unchecks the checkbox, the value should be removed from input box (the problem starts here), it doesn't remove anything. You can see I tried assigning val() function to variables, but also without success. Check my example on jsFiddle to see it live. </p> <p>Any suggestions? I guess replace() is not working for val(), is it?</p> <p>So, is there any other suggestions?</p>
javascript jquery
[3, 5]
1,651,678
1,651,679
How to move jquery function/callback into document ready
<p>How can I change this code so that I can add it to the standard document ready for jquery so that all my scripts are together. </p> <pre><code> /* * Fetch RSS feed once page has finished loading. */ (function(url, callback) { jQuery.ajax({ url: document.location.protocol + '//ajax.googleapis.com/ajax/services/feed/load?v=1.0&amp;num=10&amp;callback=?&amp;q=' + encodeURIComponent(url), dataType: 'json', success: function(data) { callback(data.responseData.feed); } }); })('http://www.bet365.com/news/en/betting/sports/rss', function(feed){ var entries = feed.entries, content, publishDate; for (var i = 0; i &lt; entries.length; i++) { publishDate = new Date(entries[i].publishedDate); date = publishDate.getDate() + '/' + publishDate.getMonth() + '/' + publishDate.getFullYear(); content = truncateText((entries[i].contentSnippet) ? entries[i].contentSnippet : entries[i].content, 100); jQuery('#rss &gt; ul').append('&lt;li&gt;&lt;a href="' + entries[i].link + '" title=" ' + content + ' " target="_blank"&gt;&lt;span&gt; ' + date + '&lt;/span&gt;' + entries[i].title + '&lt;/a&gt;&lt;/li&gt;'); } }); </code></pre>
javascript jquery
[3, 5]
876,117
876,118
check dynamic array against static array
<p>I need some javascript/jquery for this. I have two arrays, one static array that is hard coded and another dynamic array that is user driven. For example the values in each array represent a div. Each div is represented in the static array. I want to be able to show only the divs that are present in the dynamic array. So if the dynamic array changes, it shows the divs present in the dynamic array and hides the divs not present. I also want to be able to run a function connected to each div, ie box1 has a function that needs called if it is displayed.</p> <pre><code>var static_list = new Array("box1","box2","box3"); var dynamic_list = new Array("box1","box3"); </code></pre>
javascript jquery
[3, 5]
3,096,546
3,096,547
How to know which page is redirected? in javascript
<p>how to determine which page is redirected? </p> <p>i am using this code but this is not helping what i am looking for: </p> <pre><code> $(function () { //var locate = window.location; //var t = window.location.hash; var pagename = location.pathname.substr(location.pathname.lastIndexOf("/") + 1, location.pathname.length).toLowerCase(); if (pagename == "toppages.aspx") { $('#back_to_your_list').show(); } else { $('#back_to_your_list').hide(); } }); </code></pre> <p>EDIT:</p> <p>So, I have a link on my home page (<code>mydomain.com/employee/default.aspx</code>) and once the user click on it then this will redirect to another page (<code>mydomain.com/employee/toppages.aspx</code>) from it there are other links and say the user click on a link called <code>Background check</code> and this will redirect to a different page and this time the url of this page will be (<code>mydomain.com/employee/toppages.aspx?id=123</code>) </p> <p>the logic should be.</p> <p>if the page is coming from <code>mydomain.com/employee/toppages.aspx?id=123</code> then <code>$('#back_to_your_list').show();</code> otherwise <code>hide</code></p> <p>i hope it make sense and confused :)</p>
javascript jquery
[3, 5]
3,888,339
3,888,340
AlertBox - Error occured while executing doInBackground()
<pre><code> public class IdAsync extends AsyncTask&lt;String, Void, Void&gt; { AlertDialog alertDialog = new AlertDialog.Builder(MainClass.this).create(); protected Void doInBackground(String... params) { . . alertDialog.setTitle("Reset..."); alertDialog.setMessage("R u sure?"); alertDialog.setButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { //here you can add functions } }); alertDialog.show(); . .} </code></pre> <p>This gives Runtime error E/AndroidRuntime(16606): at android.app.Dialog.show(Dialog.java:241)</p>
java android
[1, 4]
1,704,118
1,704,119
Countdown javascript app
<p>I have this piece of JavaScript which is part of a countdown timer I need to know how to preset the timer to only run for 48 hours every time the page is submitted ? at the moment I place a time in a it begins to countdown to that time. Please help! </p> <pre><code>&lt;script&gt; $(document).ready(function(){ $("#countdown").countdown({ date: "16 january 2013 16:45:00", format: "on" }, function() { // callback function }); }); &lt;/script&gt; </code></pre>
javascript jquery
[3, 5]
4,317,449
4,317,450
Knowing if a page is being iframed in
<p>Is there any way of knowing if a page is being iframed in?</p> <p>I was thinking something like <code>if (window.parent)</code>, but that obviously isn't right.</p> <p>Can anyone help?</p>
javascript jquery
[3, 5]
3,088,453
3,088,454
Enum to string C# and JavaScript
<p>In my .aspx I've got the following javascript variable defined:</p> <pre><code>var action = &lt;%=ProdView %&gt; </code></pre> <p>In code-behind this returns a custom enum value:</p> <pre><code>protected ProductView ProdView { get; private set; } </code></pre> <p>I would figure that this would automatically be converted to a string in javascript? Looks like no because I get the runtime error "Item is not defined" where Item is the value ProdView.Item. Ultimately I want the action's value to be "Item" as the value.</p> <p>Here's the Enum:</p> <pre><code> public enum ProductView { Product, Item } </code></pre>
c# javascript
[0, 3]
302,225
302,226
Find out the post data size in byte
<p>When I submits the form in php. I want to find the size of the data for each text box that are posted through javascript in bytes. </p>
php javascript
[2, 3]
449,869
449,870
load list of links one at a time as soon as previous finishes
<p>Similar to <a href="http://stackoverflow.com/questions/5357094/show-a-list-of-links-in-an-iframe-one-at-a-time-with-jquery">Show a list of links in an iframe one at a time with jquery</a> but without the setTimeout function - as i would rather start the next fetch once the previous document as finished loading. </p> <p>I'm a noob with javascript and even more so with jquery, but here was my first shot:</p> <pre><code>links = ["http://example1.com","http://example2.com","http://example3.com"] function loadNext(x){ if ( x &lt; links.length ){ $('#target').load('links[x]'); $('#target').ready(function(){ x++; loadNext(x); }); }; }; $(document).ready(function(){ $('.loader').click(function(){ loadNext(0); }); }); &lt;/script&gt; &lt;div id="bd" role="main"&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="#" class="loader"&gt;Start loading&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;div id="target"&gt;&lt;/div&gt; &lt;/div&gt; </code></pre> <p>I can't really see why this wouldn't work. The logic seems correct at least. on click fire a function with index 0 passed in, then load that array value (full url) in id="target " and once that target is ready run the function again. Clicking doesn't appear to even load the first target, much less iterate (i had expected it to redirect the first click until i figured out the proxy stuff...)</p>
javascript jquery
[3, 5]
3,672,043
3,672,044
Jquery fadeIn fadeOut not working in IE8 but working in chrome, firefox
<p>I m trying to show and hide some elements(span) using jquery fadeIn and fadeOut method so I used following code:</p> <pre><code>&lt;script type="text/javascript"&gt; $(document).ready(function(){ $("a.moretag").click(function(){ $("span.hideelement").fadeIn("slow"); $("a.moretag").fadeOut("slow"); $("a.lesstag").fadeIn("slow"); }); $("a.lesstag").click(function(){ $("span.hideelement").fadeOut("slow"); $("a.lesstag").fadeOut("slow"); $("a.moretag").fadeIn("slow"); }); }); &lt;/script&gt; ..... &lt;span class="hideelement" style="display:none;"&gt;First&lt;/span&gt; &lt;span class="hideelement" style="display:none;"&gt;Second&lt;/span&gt; . . &lt;span class="hideelement" style="display:none;"&gt;Tenth&lt;/span&gt; &lt;a class="moretag"&gt;&lt;strong&gt;More&lt;/strong&gt;&lt;/a&gt; &lt;a class="lesstag" style="display:none;"&gt;&lt;strong&gt;Less&lt;/strong&gt;&lt;/a&gt; ..... </code></pre> <p>In above code when user clicks "more" link it will display previously hidden elements(display:none), more link is disappear and "less" link is displayed vice-vers.</p> <p>Here when I clicked "More" link it works fine means it disappears and displays "Less" link vice-ver. but it doesn't show/hide hidden span elements.</p> <p>This code works great in chrome, mozilla and IE7 but not working in IE8. What's wrong with code. Please help me.</p> <p>THANKS in ADVANCE.</p>
javascript jquery
[3, 5]
5,251,327
5,251,328
How to convert this raw javascript into jQuery
<p>How to convert this raw javascript into jQuery:</p> <pre><code>document.getElementById('myIframe').contentWindow.document.body.innerHTML </code></pre>
javascript jquery
[3, 5]
3,530,384
3,530,385
Scoop.it API access in C#
<p>I'm trying to access the Scoop.it API via C# to retrieve posts in topics. It's pretty much straight forward, in PHP, how are objects managed in C# and how to you access the properties?</p> <p>Here's the php code which i'd like to get a C# equivalent of:</p> <pre><code>$topic = $scoop-&gt;topic(24001); foreach($topic-&gt;curatedPosts as $post) { echo $post-&gt;title; } </code></pre>
c# php
[0, 2]
1,172,052
1,172,053
Getting my head around jQuery
<p>OK, I'm designing a site and thought I'd stick some jQuery in as I really need so js experience.</p> <p>Page with my problem is here: <a href="http://new.focalpix.co.uk/moreinfo.php" rel="nofollow">http://new.focalpix.co.uk/moreinfo.php</a></p> <p>JS in question is:</p> <pre><code>$(document).ready(function(){ $(".answer").css("display","none"); $("#maincontent a.animate").click(function() { $("#maincontent .answer").slideUp('slow'); var id = $(this).attr('href'); $(id).slideDown('slow'); return false; }); }); </code></pre> <p>This works fine, but if you click on a link where the answer has already slid down, then it slides up, then back down again.</p> <p>I'm not sure on the cleanest way to stop this happening - any ideas?</p>
javascript jquery
[3, 5]
4,276,677
4,276,678
Close popup div if element loses focus
<p>I have the following scenario: On a label's mouseover event, I display a div. The div must stay open in order to make selections within the div. On the label's mouseout event, the div must dissappear. The problem is that when my cursor moves from the label to the div, the label's mouseout event is fired, which closes the div before I can get there. I have a global boolean variable called <code>canClose</code> which I set to true or false depending on the case in which it must be closed or kept open. I have removed the functionality to close the div on the label's mouseout event for this purpose. Below is some example code.</p> <p><strong>EDIT</strong> I have found a workaround to my problem, event though Alex has also supplied a workable solution. I added a <code>mouseleave</code> event on the label as well, with a <code>setTimeout</code> function which will execute in 1.5 seconds. This time will give the user enough time to hover over the open div, which will set <code>canClose</code> to false again.</p> <pre><code>$("#label").live("mouseover", function () { FRAMEWORK.RenderPopupCalendar(); }); $("#label").live("mouseout", function () { setTimeout(function(){ if(canClose){ FRAMEWORK.RemovePopupCalendar(); } },1500); }); this.RenderPopupCalendar = function () { FRAMEWORK.RenderCalendarEvents(); } }; this.RenderCalendarEvents = function () { $(".popupCalendar").mouseenter(function () { canClose = false; }); $(".popupCalendar").mouseleave(function () { canClose = true; FRAMEWORK.RemovePopupCalendar(); }); } this.RemovePopupCalendar = function () { if (canClose) { if ($(".popupCalendar").is(":visible")) { $(".popupCalendar").remove(); } } }; </code></pre> <p>Any help please?</p>
javascript jquery
[3, 5]
2,063,738
2,063,739
how to dispose once done
<p>i want to dispose the instance once the function is finished. something with "using" i think... </p> <p>also i want to add each name to an array . </p> <p>i try: </p> <pre><code> using( Database db = new Database()) public string[] FindNameByLength(int minimumCharNumber) { try{ var query = from u in db.Users where u.FullName.Length &gt; minimumCharNumber select u.FullName; string[] namesLength; int counter; foreach (var s in query) { namesLength.Concat(new[] {s }); } return namesLength; } finally IDisposable(db).dispose(); } } </code></pre>
c# asp.net
[0, 9]
3,420,299
3,420,300
JQuery change type of input field
<pre><code>$(document).ready(function() { // #login-box password field $('#password').attr('type', 'text'); $('#password').val('Password'); }); </code></pre> <p>This is supposed to change the #password input field (with id="password") which is of type password to a normal text field and fill in the text "Password".</p> <p>It doesn't work though. Why?</p> <p>Here is the form:</p> <pre><code>&lt;form enctype="application/x-www-form-urlencoded" method="post" action="/auth/sign-in"&gt; &lt;ol&gt; &lt;li&gt; &lt;div class="element"&gt; &lt;input type="text" name="username" id="username" value="Prihlasovacie meno" class="input-text" /&gt; &lt;/div&gt; &lt;/li&gt; &lt;li&gt; &lt;div class="element"&gt; &lt;input type="password" name="password" id="password" value="" class="input-text" /&gt; &lt;/div&gt; &lt;/li&gt; &lt;li class="button"&gt; &lt;div class="button"&gt; &lt;input type="submit" name="sign_in" id="sign_in" value="Prihlásiť" class="input-submit" /&gt; &lt;/div&gt; &lt;/li&gt; &lt;/ol&gt; &lt;/form&gt; </code></pre>
javascript jquery
[3, 5]
5,373,493
5,373,494
jQuery has error of unexpected token
<p>I had the line of code that ran jQuery library in my header</p> <pre><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"&gt;&lt;/script&gt; </code></pre> <p>My javascript file sends an ajax request to a web service. The web service will output a random quote. The javascript file takes the output and displays it in a div with id='quote'. I checked the php file for web service, it worked fine and printed a random quote. But I kept getting the error below for the line with jQuery</p> <p>Uncaught SyntaxError: Unexpected token ( </p> <p>And this is code from my javascript file. I also used prototype, that was why I wrote "jQuery" instead of "$"</p> <pre><code>function displayQuote(ajax){ var quote = ajax.responseText; $("quote").hide(); $("quote").innerHTML = quote; jQuery.("#quote").fadeIn(1000); } </code></pre> <p>Thank you</p>
php javascript jquery
[2, 3, 5]
6,001,298
6,001,299
PHP/Javascript Form Reset upon page entry or back
<p>I have a standard PHP form that has a series of checkboxes, radio, selects and text. The form works fine and proceeds to a search results page. My problem is that when you click Back browser in any browser the search page shows the previous selects. How do I ensure that the back button displays the form as if its the first time the visitor visits the page?</p>
php javascript
[2, 3]
4,766,313
4,766,314
Show/Hide Multiple DIV IDs on Select
<p>I Would like the div to show based on the option selected.</p> <p>This is what I'm trying however when I select a new option I'd like to replace the div that's there and this is displaying them all one after the other as I select new options.</p> <pre><code>&lt;div id="body" style="width:300px;"&gt; &lt;div&gt; &lt;form name="frmOptions"&gt; &lt;select id="cboOptions" onChange="displayDiv('div',this)"&gt; &lt;option value="1"&gt;Option0&lt;/option&gt; &lt;option value="2"&gt;Option1&lt;/option&gt; &lt;option value="3"&gt;Option2&lt;/option&gt; &lt;option value="4"&gt;Option3&lt;/option&gt; &lt;/select&gt; &lt;/div&gt; &lt;div id="content" style="float:right;"&gt; &lt;div id="div0" style="display:none;"&gt;Test 0&lt;/div&gt; &lt;div id="div1" style="display:none;"&gt;Test 1&lt;/div&gt; &lt;div id="div2" style="display:none;"&gt;Test 2&lt;/div&gt; &lt;div id="div3" style="display:none;"&gt;Test 3&lt;/div&gt; &lt;/div&gt; &lt;/form&gt; </code></pre> <p></p> <p>The script I'm using.</p> <pre><code>&lt;script type="text/javascript"&gt; function displayDiv(id,sel){ var div = document.getElementById(id+sel.selectedIndex); if (div) div.style.display = 'block'; } &lt;/script&gt; </code></pre> <p>Could anyone help me with this? </p>
javascript jquery
[3, 5]
5,242,331
5,242,332
How to display the first 3 elements in UL only on document load?
<p>I have a List (UL) which has a class of .more_stories the UL contains LI. </p> <p>I use this code to hide them by default on load:</p> <pre><code>$('ul.more_stories li').css({'display': 'none'}); </code></pre> <p>Now I want to display the first 3 li items inside the UL after that. How can I do that in jQuery?</p> <p>-Note: I have several ULs with the same class.</p> <p>I try that and I get unexpected results..</p> <pre><code>// more stories $('ul.more_stories li').css({'display': 'none'}); $('ul.more_stories li:gt(2)').show(); </code></pre> <p>Thanks in advance.</p>
javascript jquery
[3, 5]
5,199,764
5,199,765
Pass javascript variable to php function using ajax in same file without page refresh
<p>I am using PHP function to display geofences. I want to pass javascript variable to php function in same file without page refresh.</p> <pre><code>function load(id,type){ if(type===2){ window.location.href="basic.php?idd=" + id; // i want to change code here &lt;?php $cir = get_fence_by_type($_GET['idd']); if($cir) { foreach($cir as $row){ $fence_id = $row['geo_id']; } } ?&gt; </code></pre> <p>PHP function is:</p> <pre><code>function get_fence_by_type($id){ $query = "Select * from geofence where geo_id=".$id; $result = pg_exec($query); $d = array(); while($myrow = pg_fetch_assoc($result)) { $d[] = $myrow; } return $d; //returns result in array } </code></pre> <p>javascript <code>window.location.href</code> passes javascript value to php function but it reloads page also.</p>
php javascript
[2, 3]
5,845,674
5,845,675
Adding a comma at every third number character
<p>In my code I have a variable <code>myCash</code>, which is printed into an <code>h1</code> element using javaScript's <code>innerHTML</code>. I found a function online that puts a comma after every third character from the end of the number so that the number is easier to read. I've tried for a couple of hours now sending my variable <code>myCash</code> into the function and then print it on the screen. I CANNOT get it to work.</p> <p>I've tried just alerting the new variable to the screen after page load or by pressing a button, but I get nothing and the alert doesn't even work. Here's the comma insert function:</p> <pre><code>function commaFormatted(amount) { var delimiter = ","; // replace comma if desired amount = new String(amount); var a = amount.split('.',2) var d = a[1]; var i = parseInt(a[0]); if(isNaN(i)) { return ''; } var minus = ''; if(i &lt; 0) { minus = '-'; } i = Math.abs(i); var n = new String(i); var a = []; while(n.length &gt; 3) { var nn = n.substr(n.length-3); a.unshift(nn); n = n.substr(0,n.length-3); } if(n.length &gt; 0) { a.unshift(n); } n = a.join(delimiter); if(d.length &lt; 1) { amount = n; } else { amount = n + '.' + d; } amount = minus + amount; return amount; } </code></pre> <p>now when I want my variable to change I've tried it a few different ways including this:</p> <p><code>var newMyCash = commaFormatted(myCash); alert(newMyCash);</code></p> <p>and this:</p> <p><code>alert(commaFormatted(myCash);</code></p> <p>Where of course <code>myCash</code> equal some large number;</p> <p>This does absolutely nothing! What am I doing wrong here??</p>
javascript jquery
[3, 5]
3,825,820
3,825,821
How to pause/delay on Android?
<p>I am currently learning how to develop applications for Android mobile devices.</p> <p>I wrote a test application to display numbers 0-9 on the device screen. I created a simple function to delay the number change.</p> <p>However, upon running the application, only the final number is displayed. There is also a delay before this final number shows. I'm assuming that the length of the pause is my defined delay multiplied by the number of digits to be shown.</p> <p>How do I create an app that changes the numbers with a delay?</p> <pre><code>public class AndroidProjectActivity extends Activity { public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); Main(); } void Delay(int Seconds){ long Time = 0; Time = System.currentTimeMillis(); while(System.currentTimeMillis() &lt; Time+(Seconds*1000)); } void Main() { String ConvertedInt; TextView tv = new TextView(this); setContentView(tv); for(int NewInt = 0; NewInt!= 9; NewInt++){ ConvertedInt = Character.toString((char)(NewInt+48)); tv.setText(ConvertedInt); Delay(5); } } </code></pre>
java android
[1, 4]
901,343
901,344
Number to Word - jquery
<p>anyone know's a way to describe a cash value or a plugin who does that ?</p> <p><strong>exp:</strong> if i have $ 1.200.000,00 and the user <code>hover()</code> the value: description will be "<strong>one million two hundred</strong> "</p> <p>Thanks!</p>
javascript jquery
[3, 5]
1,105,782
1,105,783
Javascript ASP>NET get siblings/neighbours
<p>I have a gridview and i have text boxes and uneditable text fields in each row. For the textbox that I have ...I have an onblur function... I generate these textboxes from the server as follows </p> <pre><code> "&lt;input type=text name=\"txtPrice\" id=\"txtPrice_{0}\" value=\"{1}\" maxlength=\"10 \" runat=\"server\" class=\"g1 g2\" style=\"width:71px;\" onblur=\"javascript:myfun(this);\" /&gt;"); </code></pre> <p>For each text box that I have in the row I want to get its neigbouring labels/txtboxes by using javascript Remeber I cannot pass values rather I want to pass the textbox object just like I am doing in the above code</p> <p>IMPORTANT:I dont know weather the label will be its direct neighbour...i want to get the neighbour using the coulmn name/header text</p> <p>Or if I can pass the complete row to Javascript from the server side??</p> <p>Thanks</p>
javascript asp.net
[3, 9]
2,169,521
2,169,522
how to insert DOM element just after the div clicked
<p>I've my mark up as</p> <pre><code>&lt;div id="wrap"&gt; &lt;div class="clickhere"&gt;&lt;/div&gt; &lt;div class="clickhere"&gt;&lt;/div&gt; &lt;div class="clickhere"&gt;&lt;/div&gt; &lt;div class="clickhere"&gt;&lt;/div&gt; &lt;div class="clickhere"&gt;&lt;/div&gt; &lt;/div&gt; </code></pre> <p>Now, I want to add another <code>&lt;div class="clickhere"&gt;&lt;/div&gt;</code> just after the div clicked using jQuery. I thought of <code>.append()</code> or <code>.prepend()</code> but it only adds at the last or the first of the parent element (if applied at the parent element).</p> <pre><code>$('.clickhere').click(function(){ // add &lt;div class="clickhere"&gt;&lt;/div&gt; just below $(this) }) </code></pre>
javascript jquery
[3, 5]
1,756,563
1,756,564
Using jquery how can I remove a DIV if it's contents are empty?
<p>I'm looking for a way to remove the following empty div using jquery.</p> <p>The following div is output sometimes without content inside it. For display reasons I need to remove it when it's empty.</p> <pre><code>&lt;div class="field-group-format group_call_to_action_aside div group-call-to-action-aside box yellow speed-fast effect-none"&gt;&lt;/div&gt; </code></pre> <p>Thoughts?</p> <p>I've been trying the following and variations of it, but have't had any luck. </p>
javascript jquery
[3, 5]
2,336,959
2,336,960
jQuery, new line and enter button
<p>I'm using following code for textarea:</p> <pre><code>$('#ajaxSendMessage').live('keyup', function(event) { if (event.keyCode == 13) { controller.sendMessage($(this).val(), $("#ajaxAnswerTo").val()); } }); </code></pre> <p>This code works, but <code>$("#ajaxAnswerTo").val()</code> have new line characte when I click enter... For example: I entered: helo world and then moved cursor to helo world, updated it to hello and clicked enter. The result code will be: hell\no world.</p> <p>How to remove this \n?</p>
javascript jquery
[3, 5]
2,346,708
2,346,709
append in word document using c#
<pre><code>//Text to word file StringBuilder strBuilder = newStringBuilder(); strBuilder.Append("&lt;h1 title='Header' align='Center'&gt;Writing To Word Using ASP.NET&lt;/h1&gt; ".ToString()); strBuilder.Append("&lt;br&gt;".ToString()); strBuilder.Append("&lt;table align='Center'&gt;".ToString()); strBuilder.Append("&lt;tr&gt;".ToString()); **strBuilder.Append("&lt;td style='width:100px;color:green'&gt;Date :&lt;asp:Label ID='lbl_dte' runat='server' Text=&gt;Labe2&lt;/asp:Label&gt;&lt;/td&gt;".ToString());** strBuilder.Append("&lt;td style='width:100px;color:red'&gt;India&lt;/td&gt;".ToString());' kstrBuilder.Append("&lt;/tr&gt;".ToString()); strBuilder.Append("&lt;/table&gt;".ToString()); // string strPath = Request.PhysicalApplicationPath + "\\document\\Test.doc"; string strPath = filename; //string strTextToWrite = TextBox1.Text; FileStream fStream = newFileStream (strPath,FileMode.Append); fStream.Close(); StreamWriter sWriter = newStreamWriter(strPath); sWriter.Write(strBuilder); sWriter.Close(); </code></pre> <p>I add a asp label <code>&lt;asp:Label ID='lbl_dte' runat='server' Text=&gt;Labe2&lt;/asp:Label&gt;</code></p> <p>Can I get the contol of label in code behind(c# asp.net)?</p>
c# asp.net
[0, 9]
674,892
674,893
Loading raw HTML in Java/Android
<p>I have written a couple of live wallpapers in recent weeks using local resources. Now a potential client wants me to make one that loads and displays the photos (usually between 3 and 10) from his daily news report posted online. The report file has a URL along the lines of <code>http://example.com/dailytext/report.html</code> which loads images along the lines of <code>http://example.com/dailymedia/obama.jpg</code> The references in <code>report.html</code> look like<br> <code>img src="../dailymedia/obama.jpg" ...</code></p> <p>Am I supposed to use a WebView to do this? That doesn't seem quite right, because I don't want to display the HTML. I would think that I want to throw the raw HTML into an array, parse the HTML looking for the instances of <code>"img src..."</code>, reconstruct the full URLs, then load the bitmaps. I'm getting the impression this is more of a pure Java task than anything to do with Android's specialized classes, but I don't know. Any suggestions about "best practice?"</p>
java android
[1, 4]
4,665,762
4,665,763
C# retrieve data dynamically from a website
<p>A website displays result when the register number is given. I have a web form to input the register number. How can I retrieve the results from that page into an Excel document using C#?</p>
c# asp.net
[0, 9]
3,954,449
3,954,450
Can't save image for barcode generation in ASP.NET C# project
<p>I'm trying to save an image using System.Drawing.Save() and I keep getting a Invalid Parameter exception.</p> <p>Can somebody please take a look at my code and tell me what I'm doing wrong.</p> <p>Here is the code that generates the barcode image.</p> <pre><code> public class BarcodeHelper { Font barcodeFont; public BarcodeHelper() { PrivateFontCollection fonts; FontFamily family = LoadFontFamily("~/../fonts/Code128bWin.ttf", out fonts); barcodeFont = new Font(family, 20.0f); // when done: barcodeFont.Dispose(); family.Dispose(); family.Dispose(); } public FontFamily LoadFontFamily(string fileName, out PrivateFontCollection fontCollection) { fontCollection = new PrivateFontCollection(); fontCollection.AddFontFile(fileName); return fontCollection.Families[0]; } public Image GenerateBarcode(string barcodeText) { Image barcodeImage; using (barcodeImage = Image.FromFile(@"C:\Users\Administrator\Desktop\YodelShipping\YodelShipping\images\barcode.bmp")) { using (Graphics g = Graphics.FromImage(barcodeImage)) { g.DrawString(barcodeText, new Font(barcodeFont, FontStyle.Bold), Brushes.Black, barcodeImage.Height /2, barcodeImage.Width / 2); } } return barcodeImage; } } </code></pre> <p>Here is where I call the code to create and save the barcode image. I'm getting the exception, when calling the Save() method.</p> <pre><code>System.Drawing.Image img = barcodeHelper.GenerateBarcode("2lgbub51aj+01000002"); img.Save("~/images/barcode.png"); </code></pre> <p><img src="http://i.stack.imgur.com/7G3rs.png" alt="enter image description here"></p>
c# asp.net
[0, 9]
2,953,460
2,953,461
c# asp .net Convert to MailAddress
<p>I am working on an application that is going to send an email automatically. I have the preferences(sender,receiver etc...) in web.config file. I am trying for ex to get the receiver like the following </p> <pre><code> MailMessage msg = new MailMessage(); msg.To = ConfigurationManager.AppSettings["AdminEmail"]; </code></pre> <p>I get the following error. Error 3 Cannot implicitly convert type 'string' to 'System.Net.Mail.MailAddressCollection'. Any help?</p>
c# asp.net
[0, 9]
3,732,868
3,732,869
Javascript widget inspired by iPhone UITableView?
<p>Cocoa Touch's UITableView allows a user to scroll through large numbers of data rows with good performance because it recycles table rows. Rather than create a GUI element for every single data row, a limited number of table rows is created, and simply updated with the relevant data as the user scrolls, giving the illusion of navigating up and down a very large number of table rows.</p> <p>Has anyone seen this done in javascript? Is there a plugin available anywhere that will do this for me?</p>
javascript iphone
[3, 8]
389,329
389,330
If text exists, reload the page
<p>I'm trying to do a search on page for text, and if the text is found, reload the page.</p> <pre><code>&lt;p class="textmedium"&gt;These are the droids I'm looking for&lt;/p&gt; </code></pre>
javascript jquery
[3, 5]
1,796,194
1,796,195
aspx to jpeg image conversion
<p>Am trying to convert aspx page to image i.e save it as a png file. I used iecapt for this. I have many textboxes on aspx page. The problem is the textbox values are not saved in the image file. Am just getting the source file image. Hope i get some suggestions on this. Thank You</p> <p>protected void btnsend_Click(object sender, EventArgs e) {</p> <pre><code> string url = "http://localhost:4101/WebForm3.aspx"; if(Request.Params["weburl"] != null) { url = Request.Params["weburl"]; } string savepath = String.Format("C:\\IECapt\\{0}.png" , System.Guid.NewGuid()); System.Diagnostics.Process process = new System.Diagnostics.Process(); process.StartInfo.FileName = "C:\\IECapt\\IECapt.exe"; process.StartInfo.Arguments = String.Format("\"{0}\" \"{1}\"",url,savepath); process.StartInfo.UseShellExecute = false; process.Start(); process.WaitForExit(); process.Dispose(); Response.Clear(); Response.ContentType = "image/png"; Response.WriteFile(savepath); Response.End(); } </code></pre>
c# asp.net
[0, 9]
3,108,464
3,108,465
Getting actual text in freetextbox control
<p>I am using <a href="http://www.freetextbox.com/" rel="nofollow">FreeTextBox control</a></p> <p>in asp.net.When I am getting its Text in my code I am getting the Html code with all the formatting.</p> <p>If I want to get the actual text (i.e. only text without html tags),then how I should get.</p>
c# asp.net
[0, 9]
1,360,478
1,360,479
Getting values from dictionary
<p>I have a Dictionary&lt;int, int&gt; in my class. How can I access both values without knowing the key?</p> <p>For instance, I want to be able to do something like this: If the dictionary contains Dictionary&lt;int, int&gt;<br> and the values are &lt;5, 4&gt;<br> I want to be able to get the value of &lt;(this),(this)&gt; like</p> <p>Pseudo code:</p> <pre><code>foreach(Dictionary item or row) { my first int = Dictionary&lt;(this), (not this)&gt; my second int = Dictionary&lt;(not this), (this)&gt; } </code></pre> <p>How can I do this using a dictionary? If this is not doable: Is there another way?</p>
c# asp.net
[0, 9]
4,897,066
4,897,067
jQuery live hover
<p>I can't seem to convert the following into a live hover</p> <pre><code>$("li.favorite_item").hover( function () { $(this).append($(" &lt;a href='#' class='button'&gt;x&lt;/a&gt;")); }, function () { $(this).find("a:last").remove(); } ); </code></pre> <p>I've tried:</p> <pre><code>$("li.favorite_item"").live('hover', function() { function () { $(this).append($(" &lt;a href='#' class='button'&gt;x&lt;/a&gt;")); }, function () { $(this).find("a:last").remove(); } }); </code></pre> <p>But it does not work.</p>
javascript jquery
[3, 5]
3,108,971
3,108,972
Jquery mouseover firing click
<p>Ive got a select menu and i want on mouseover to fire a click event, </p> <p>I've got this</p> <pre><code>$('.selectMenu').live('mouseover', function() { $(this).click(); }); </code></pre> <p>but it doesnt seem to be grabbing the right values. Any ideas how to fix this?</p>
javascript jquery
[3, 5]
4,638,405
4,638,406
Find an Anchor tag inside a Paragraph tag.
<p>I have the following markup which I need to bind a click event to the <code>&lt;a&gt;</code> tag below. </p> <p>How can i achieve this?</p> <pre><code> &lt;p class="people_rt_link2" id="test"&gt; &lt;a href="#" title="2011"&gt;2011&lt;/a&gt; &lt;p style="padding-left: 3px; margin: 3px 0px;"&gt; a href="http://192.168.20.24/mclarengroup/archives/928"&gt;McLaren to build £10m Big Yellow in Chiswick, West London&lt;/a&gt; &lt;/p&gt; &lt;br&gt; &lt;a href="#" title="2010"&gt;2010&lt;/a&gt; &lt;br&gt; &lt;/p&gt; </code></pre> <p>This is my current javascript function:</p> <pre><code> &lt;script type="text/javascript"&gt; $(document).ready(function() { $('.people_rt_link2 a').click(function() { alert('aa'); }); var data = { cat_id:&lt;?php echo $cat_id?&gt;,posted_year:&lt;?php echo $posted_year?&gt;}; jQuery.post("&lt;?php echo $ajax_page_details-&gt;guid?&gt;", data, function(response) { $('#test').html(response); }); }); &lt;/script&gt; </code></pre>
javascript jquery
[3, 5]
856,793
856,794
Method is not getting executed in ASP.NET Wizard
<p>I have a class that inserts a <code>TextBox</code> value and a <code>FileUpload</code> image into the SQL Server. I'm executing all the class in the <code>Wizard1_FinishButtonClick</code> event. I have 4 steps in Wizard. All the classes are getting executed and inserted other than <code>InsertCert()</code> class. I executed same codes in a simple .aspx page and the values are inserting into the DB.</p> <p>Where 'm I going wrong? Following is the class and Wizard1_FinishButtonClick.</p> <pre><code>public void Insertcert() { String KKStech = @"Data Source=USER-PC\SQLEXPRESS;Initial Catalog=KKSTech;Integrated Security=True"; SqlConnection conn = new SqlConnection(KKStech); String insertstring2 = @"insert into Cert(CertName, CertLogo) values(@CertName, @CertLogo)"; SqlCommand cmd = new SqlCommand(insertstring2, conn); cmd.CommandText = insertstring2; cmd.CommandType = CommandType.Text; try { if (FileUpload1.HasFile) { byte[] productImage = FileUpload1.FileBytes; conn.Open(); cmd.Parameters.AddWithValue("@CertName", TextBox18.Text); cmd.Parameters.Add("@CertLogo", SqlDbType.VarBinary).Value = productImage; cmd.ExecuteNonQuery(); } } catch (Exception ex) { throw ex; } finally { conn.Close(); } } </code></pre> <p>This is the final class where all the classes are inserted.</p> <pre><code> protected void Wizard1_FinishButtonClick(object sender, WizardNavigationEventArgs e) { InsertInfo(); Insertcert(); Insertaddress(); Insertskills(); } </code></pre>
c# asp.net
[0, 9]
5,681,283
5,681,284
gridview - allowing one column to be edited but not another
<p>i have an asp.net c# application.</p> <p>my gridview has a datasource that has 2 fields.</p> <p>1 field cannot be edited by the user, but i need the other one to be editable!</p> <p>is this possible to do?</p>
c# jquery asp.net
[0, 5, 9]
1,751,228
1,751,229
How to check if SqlDataSource.SelectCommand returned null
<p>I have a gridview and sqldatasource.</p> <pre><code>I'm using : SqlDatasource1.SelectCommand = "Select Name from Table Where RowID=@RowID"; </code></pre> <p>how can I check if the the selectedcommand returned null ( no value found ) </p> <p>Thanks</p>
c# asp.net
[0, 9]
4,219,072
4,219,073
Only submit this.val on form when submitted?
<p>I'm making a form that displays a dynamic value and I have the forms action in a Jquery function and I want to take a value out of <code>$(this).closest('tr') &lt;input type="text" class="line_Order_ID" value="'.$Order_ID.'" size="5" readonly&gt;</code> I want to take the value from the <code>.line_Order_ID</code> and send it to a php page to process.</p> <p><em><strong>jQuery</em></strong></p> <pre><code>$(document).ready(function(e) { $('.viewThis').live({ click: function() { var $tr = $(this).closest('tr'); var Order_ID = $('.line_Order_ID', $tr).val(); $('form#ordersList').attr({ action: "phpDump.php", target: "_blank", }).submit(); return false; } }); }); </code></pre> <p>Any ideas?? </p>
php jquery
[2, 5]
4,992,653
4,992,654
Converting this python logic into C#
<p>I have been searching for an example implementation of a influence map spreading algorithm and I found one written in python, i thought, great! Since I have used python in the past and I thought it would be simple to understand the core ideas of the algorithm.</p> <p>However I found this rather cryptic implementation : </p> <pre><code># spread the influence while iterations: neighbors[:-1,:] += weightmap[1:,:] # shift up neighbors[1:,:] += weightmap[:-1,:] # shift down neighbors[:,:-1] += weightmap[:,1:] # shift left neighbors[:,1:] += weightmap[:,:-1] # shift right # keep influence values balanced neighbors *= FACTOR # prepare for next iteration weightmap,neighbors = neighbors,weightmap iterations -= 1 </code></pre> <p>Now, I looked into the python docs and found out about those "matrices selection" of "from:to". However, translating what I thought was the C# equivalent, I found myself looking at a piece of code that didnt make much sense.</p> <p>So I turn to you, how would I translate that piece of code into C#? Assuming normal building blocks like While( something ), For(;;) and array[posX, posY] = something.</p> <p>Thank you</p>
c# python
[0, 7]
3,221,273
3,221,274
FileNotFoundException when trying to read a file I've written
<p>I am trying to write an object (pilotRecord) to a file and read it back again. I understood that I didn't need to specify a path as it is internal to my app, so I want all files deleted if the app is uninstalled.</p> <p>Here's my code:</p> <pre><code> fileoutputstream = openFileOutput("test1", Context.MODE_WORLD_WRITEABLE); Log.d(this.getClass().getName(), "loadPilotRecord: "+fileoutputstream.toString()); objectoutputstream = new ObjectOutputStream(fileoutputstream); Log.d(this.getClass().getName(), "loadPilotRecord: "+objectoutputstream.toString()); objectoutputstream.writeObject(pilotRecord); objectoutputstream.close(); fileoutputstream.close(); fileinputstream = new FileInputStream("test1"); Log.d(this.getClass().getName(), "loadPilotRecord: "+fileinputstream.toString()); objectinputstream = new ObjectInputStream(fileinputstream); Log.d(this.getClass().getName(), "loadPilotRecord: "+objectinputstream.toString()); pilotRecord = (PilotRecord)objectinputstream.readObject(); objectinputstream.close(); fileinputstream.close(); </code></pre> <p>My problem is that I get a FileNotFoundException on the following line in the above code: fileinputstream = new FileInputStream("test1"); I'm not really sure how to find out what path it is using, or maybe there is a more obvious problem I'm just not seeing. Sorry if this is a bit basic, but I'm still trying to find my feet. The Log.d statements just output the class name and an Id.</p> <p>TIA,</p> <ul> <li>Frink</li> </ul>
java android
[1, 4]
1,184,248
1,184,249
Asp.net configuration, security part error
<p>I use visual studio 2010 and I have a problem when I want to add a username and a password using asp.net configuration and I have this error :</p> <p>" Failed to generate a user instance of SQL Server due to a failure in starting the process for the user instance. The connection will be closed. "</p> <p>I search for a solution for this problem but I didn't find one , so I hope someone can help me and I will be so thankful ...</p>
c# asp.net
[0, 9]
768,224
768,225
find error in javascript
<p>I have a few javacsript files, and I'm using a js packer to pack them, then combine them all and include them in a page.</p> <p>The problem is that after they are packed I'm getting this error:</p> <blockquote> <p>Error: missing ; before statement</p> </blockquote> <p>I assume it's because somewhere in the js file a new line is used instead of the <code>;</code> character, and since the packer removes new lines you get the error</p> <p>so, how could I find where <code>;</code> is ommited in the script(s)? </p>
javascript jquery
[3, 5]
802,225
802,226
How to show image using onmouseover in javascript
<p>I have lots of pets. what i want to achive is that when ever i hover, it will display the image of particular pet in nearby div.</p> <p>for example</p> <pre><code>&lt;code&gt; &lt;select name="pet" id="pet"&gt; &lt;option value="1"&gt;Dog&lt;/option&gt; &lt;option value="2"&gt;Cat&lt;/option&gt; &lt;option value="3"&gt;Rat&lt;/option&gt; &lt;/select&gt; &lt;div id="petimage"&gt;&lt;/div&gt; &lt;/code&gt; </code></pre> <p>Earlier i was using onmousehover in option then with the help of ajax i was albe to get the particular pet image but now i realized onmousehover event not working in IE.</p> <p>Can anyone tell me the alternative?</p> <p>Thanks navi</p>
php jquery
[2, 5]
4,956,373
4,956,374
What is the most widely used feed-parsing library for Android
<p>I want to make an app which (amongst other things) can parse feeds loaded via the network. Given that the standard Anrdoid + Core Java libraries do not provide a feed parser service and I dont want to write a one myself, can you nominate a Java feed parser which will work on a low-spec Android device. </p> <p>I'm just starting out learning Android, having completed the Hello World examples I'd like to move onto my first app. I want to make something which prarses some ATOM or RSS feeds and displays some content in a GridView. </p> <p>The UI stuff seems to be very well documented in Android, and Sun have plenty of examples of how to retrieve a URL, however I'm not so how to do the feed parsing. </p> <p>Previously when I've done this sort of thing in Pythion I use a general purpose feed parser which can parse pretty much anything (e.g. RSS, ATOM). There are plenty of good Python implementations of this sort of thing, however I've not found anything like this as part of the standard Android library. </p> <p>At work I've done (light) maintenance on corporate java apps. The general practice seems to be to take whatever classes you like (e.g. the Jakarta Commons feed-parser) and simply bundle them into the CLASSPATH. Desktop apps do not care how big the dependancies are, however I'm sure that's a big issue when compiling an APK bundle for use on a device with limited meory. Surely I have to be very picky about what kind of Jars I depend on, right? Can I just go ahead and use the same classes that I'd use for desktop apps?</p> <p>Notes: </p> <ul> <li>My background is in Python (with only light Java experience) </li> <li>Ideally I'd like to use something popular (not neccecarily the best) so I can get support on it. </li> <li>Even better, I'd like to use built in library functionality so I dont have to add any 3rd party Jars to bloat my app.</li> <li>Currently targeting Android 1.5 (because that's what my device runs)</li> </ul>
java android
[1, 4]
3,282,207
3,282,208
echo a javascript function with parameters in php
<p>I am trying to pass a JavaScript function with an onclick event in php. The problem I am facing is that the function that I need to pass has a parameter that needs to be in double quotes as follows:</p> <pre><code>onclick="removeElement("div8")" </code></pre> <p>Now when I use JavaScript to generate the parameter it comes out fine, but whenever I use an echo function in php, the following happens when I look at the function in the browser</p> <pre><code>onclick="removeElement(" div8")" </code></pre> <p>the code I am using to generate this is:</p> <pre><code>echo '&lt;div&gt;&lt;img src="img.png" alt="image" onclick="removeElement("div'.$x.'")" /&gt;&lt;/div&gt;'; </code></pre> <p>where $x is the number to be added to the parameter.</p> <p>Is there a way that the function is returned as a whole and not get the space in between?</p>
php javascript
[2, 3]
4,858,393
4,858,394
How to translate jQuery .live() to .on() with events bound to this?
<p>I'm in the process of converting code from the deprecated <code>.live()</code> API to <code>.on()</code> (see the <a href="http://blog.jquery.com/2011/11/03/jquery-1-7-released/">jQuery 1.7 release notes</a>)</p> <p>I have live events attached to <code>this</code> in multiple custom jQuery plugins, e.g.</p> <pre><code>this.live('click', function() { ... }); </code></pre> <p>the <a href="http://api.jquery.com/live/">jQuery .live() doc</a> has some guidance on how to migrate to <code>.on()</code> as follows:</p> <pre><code>$(selector).live(events, data, handler); // jQuery 1.3+ $(document).on(events, selector, data, handler); // jQuery 1.7+ </code></pre> <p>however, this doesn't work:</p> <pre><code>$(document).on('click', this, function() { ... }); </code></pre> <p>so... how do I make live events bound to <code>this</code> work with the new <code>on()</code> API?</p>
javascript jquery
[3, 5]
2,273,045
2,273,046
Why is the asp.net checkbox not disabled?
<p>I am trying to set the disabled property for my <code>CheckBox</code> to true. However, when I do a postback the <code>CheckBox</code> is still enabled?</p> <p><strong>HTML:</strong></p> <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"&gt;&lt;/script&gt; &lt;head runat="server"&gt; &lt;title&gt;&lt;/title&gt; &lt;script&gt; $(document).ready( function () { $("#CheckBoxList1_0").attr('disabled',true); } ); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;form id="form1" runat="server"&gt; &lt;div&gt; &lt;asp:CheckBoxList ID="CheckBoxList1" runat="server"&gt; &lt;asp:ListItem&gt;een&lt;/asp:ListItem&gt; &lt;asp:ListItem&gt;twee&lt;/asp:ListItem&gt; &lt;asp:ListItem&gt;drie&lt;/asp:ListItem&gt; &lt;/asp:CheckBoxList&gt; &lt;/div&gt; &lt;asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" /&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p><strong>c#:</strong></p> <pre><code> protected void Button1_Click(object sender, EventArgs e) { if (!CheckBoxList1.Items[0].Enabled) { Response.Write("it is disabled"); } } </code></pre>
c# jquery asp.net
[0, 5, 9]
4,453,654
4,453,655
Can I use a JS file to render previews when using MarkItUp?
<p>Is there a way I can use a JS file instead of a server side file eg. PHP to render my previews when using <a href="http://markitup.jaysalvat.com/home/" rel="nofollow">MarkItUp</a>?</p>
javascript jquery
[3, 5]
3,097,987
3,097,988
How do you make an android application wait?
<p>I'm trying to make a pedometer application with Android using only the accelerometer to gather data. I gathered a lot of raw data from the phone and found certain patterns to constituted a step from my gait and created 3 booleans to model how one step would look like to an accelerometer.</p> <pre><code>public boolean beforeStep(float y) { if(y &gt; 1.5 &amp;&amp; y &lt; 3){ return true; } else { return false; } } public boolean duringStep(float y) { if(y &gt; 3 &amp;&amp; y &lt; 5){ return true; } else { return false; } } public boolean afterStep(float y) { if(y &gt; 1.5 &amp;&amp; y &lt; 3){ return true; } else { return false; } } if(beforeStep(accel)){ if(duringStep(accel)){ if(afterStep(accel)){ stepCount++; } } } </code></pre> <p>At first I had run these booleans in my onSensorChanged() method, but I realized that this meant that it would pass the same acceleration value to all three booleans, so the program would never recognize a step. How do I make Android wait, say 10ms, between each boolean check so that the acceleration value updates?</p> <p>Also, if there is a more accurate/efficient way to go about counting steps using raw acceleration data, please let me know!</p>
java android
[1, 4]
1,921,402
1,921,403
Parsing JSON key with colon in it
<p>Consider this JSON string:</p> <pre><code>{ "title": "value1", "link": "value2", "media:info": "value3" } </code></pre> <p>I know how to parse title and link, but the parser isn't accepting media info because of the colon in the middle I think. Does anyone have any ideas?</p>
java android
[1, 4]
2,888,732
2,888,733
Nested Methods? Why are they useful?
<p>So I'm just learning some new stuff in C# &amp; Python. Turns out both lanuages support nested methods (C# sort of does). </p> <p>Python:</p> <pre><code>def MyMethod(): print 'Hello from a method.' def MyInnerMethod(): print 'Hello from a nested method.' MyInnerMethod() </code></pre> <p>C# (using new features in .NET 3.5):*</p> <pre><code>static void Main() { Console.WriteLine("Hello from main."); Func&lt;int, int&gt; NestedMethod = (x) =&gt; { Console.WriteLine("In nested method. Value of x is {0}.", x); return x; }; int result = NestedMethod(3); } </code></pre> <p>So why are nested methods so important? What makes them useful?</p> <p><hr></p> <p>*<em>The C# code has not been tested. Feel free to edit if it doesn't compile.</em></p>
c# python
[0, 7]
1,329,115
1,329,116
What's a good Javascript tutorial library?
<p>I'm looking for something that will allow me to walk a new user through a a web app one step at a time with different hints on what to click and look at. Does something like this exist?</p>
javascript jquery
[3, 5]
3,758,045
3,758,046
e.Row.Cell adding control does not work
<p>I have a code:</p> <pre><code> protected void gvContacts_RowDatabound(object sender, GridViewRowEventArgs e) { Label label = new Label(); label.Text = "test"; if (e.Row.RowType == DataControlRowType.DataRow &amp;&amp; e.Row.RowIndex == 0) { for (int i = 0; i &lt; e.Row.Cells.Count; i++) { e.Row.Cells[i].Controls.Add(label); //doesnt work e.Row.Cells[i].Text = "this works"; } } } </code></pre> <p>where label does not appear to my cells. What's wrong?</p>
c# asp.net
[0, 9]
3,866,824
3,866,825
Executing Python Script from C#
<p>I am trying to execute the python script from C# in the following way:</p> <pre><code>int ExitCode; ProcessStartInfo ProcessInfo; Process Process; ProcessInfo = new ProcessStartInfo(); ProcessInfo.FileName = "C:\Python27\python.exe"; ProcessInfo.Arguments = "C:\generate.py book1.pdf"; ProcessInfo.CreateNoWindow = true; ProcessInfo.UseShellExecute = false; ProcessInfo.RedirectStandardOutput = true; Process = Process.Start(ProcessInfo); Process.WaitForExit(); ExitCode = Process.ExitCode; Process.Close(); </code></pre> <p>When I execute this on the server, I get the ExitCode as 1. But the same code is working fine locally.</p> <p>Also when I run this command from the cmd prompt, the python script executes without any issues.</p> <p>This python script is actually being used to convert the PDF pages to SWF files, extract the text from pages and create thumbnail of the pdg pages using various open sources.</p> <p>Can anyone please help me understand what could be the issue with above C# code or do I need to set any permissions on the server?</p> <p>Thanks in advance,</p>
c# python
[0, 7]
884,099
884,100
how to connect a remote SQLserver using widows authentication from a .net application, if possible
<p>currently I am using this connection string inside the app.config file of the application</p> <pre><code>add name="LightSailEntities" connectionString="metadata=res://*/LightSailEntities.csdl|res://*/LightSailEntities.ssdl|res://*/LightSailEntities.msl;provider=System.Data.SqlClient;provider connection string='data source=abc.xyz.com;initial catalog=LightSail;user id=LightSail; password=yourpasswordhere;MultipleActiveResultSets=True;App=EntityFramework'" providerName="System.Data.EntityClient" </code></pre> <p>The domain of .Net application and the domain of client, using .Net application, is different from domain of SQL server. I mentioned <strong>"using widows authentication"</strong> only because of, I have the access of the server machine(means I can use Remote Desktop Connection) on which the SQL server is installed.</p>
c# asp.net
[0, 9]
5,729,266
5,729,267
onrowupdating event not working
<p>I dont know why because <code>onrowdeleting</code> works fine The delete method is in the same class as the update method</p> <pre><code>&lt;form id="formulario" runat="server" method="post"&gt; &lt;asp:GridView AllowPaging="true" id="inf_clientes" AutoGenerateColumns="false" runat="server" GridLines="Both" BorderWidth="1" onrowdeleting="Grid_DeleteCommand" onrowupdating="Grid_UpdateCommanda" DataKeyNames="cliente_id,nombre,apellido,celular"&gt; &lt;Columns&gt; &lt;asp:TemplateField&gt; &lt;ItemTemplate&gt; &lt;asp:ImageButton CommandName="Delete" runat="server" ValidationGroup="validation" ImageUrl="borrar.jpg" ToolTip="Borrar" Height="20px" Width="20px" /&gt; &lt;/ItemTemplate&gt; &lt;/asp:TemplateField&gt; &lt;asp:TemplateField&gt; &lt;ItemTemplate&gt; &lt;asp:ImageButton CommanName="Update" ImageUrl="guardar.jpg" ValidationGroup="validation" runat="server" ToolTip="Guardar" Height="20px" Width="20px" /&gt; &lt;/ItemTemplate&gt; &lt;/asp:TemplateField&gt; </code></pre> <p>and code behind </p> <pre><code>protected void Grid_UpdateCommanda(object origen,GridViewUpdateEventArgs e) { con.Open(); EjecutarComando = new SqlCommand("UPDATE dclntes SET nombre='c' where cliente_id=4",con); EjecutarComando.ExecuteNonQuery(); con.Dispose(); todos(); } </code></pre> <p>If you need more let me know</p>
c# asp.net
[0, 9]
1,354,798
1,354,799
PHP/jQuery - Highlight the menu with current page
<p>Hi<br /> I am going to highlight a menu item according to the page that is reading currently, when user click on different page through the menu, that menu item will be highlighted, example is <a href="http://templates.joomlart.com/ja_pyrite/index.php?option=com_content&amp;view=article&amp;id=44&amp;Itemid=53" rel="nofollow">http://templates.joomlart.com/ja_pyrite/index.php?option=com_content&amp;view=article&amp;id=44&amp;Itemid=53</a>.</p> <p>If I use PHP/jQuery to check the url and highlight the menu, it will be good if the url look like "http://example.com/contact", but the example above is bad.</p> <p>If I don't going to check the url and highlight the menu item, could someone give me a idea/method that can be done with the same effect?</p> <p>Thank you</p>
php jquery
[2, 5]
2,745,290
2,745,291
Writing and reading to and from a file for integers and strings
<p>I am trying to save a file (and then read it later) in java (android) using the following </p> <pre><code>FileInputStream fis = openFileInput(filename); </code></pre> <p>and then maybe use BufferedReader/writer. Anyways, I am trying to save String and numbers and I was wondering what would be the best method to write and read from I/O for such case? I was about to do the following for reading </p> <pre><code>FileInputStream fis = openFileInput(filename); InputStreamReader inputStreamReader = new InputStreamReader(fis); BufferedReader bufferedReader = new BufferedReader(inputStreamReader); </code></pre> <p>and for writing</p> <pre><code>FileOutputStream fos = openFileOutput(filename, 20); OutputStreamWriter outStreamReader = new OutputStreamWriter(fos); BufferedWriter bufferedWriter = new BufferedWriter(outStreamReader); </code></pre> <p>but I noticed that the readLine will always return string of the line. so I have to go throught the conversion of Strings to Integer for some lines. Is this an efficient way of doing it (or correct way)? I feel I am missing something Thank you</p>
java android
[1, 4]
1,933,394
1,933,395
See threads that JavaScript is creating?
<p>Is there a way to see the "threads" that JavaScript is creating? For example, if I have an event handler attached to a DOM element, I assume that JavaScript will implicitly make a new thread to run that code in the background? If so, is there a way to see (e.g. via Firebug, WebKit inspector, etc.) the different "threads" that JavaScript has open? (And if it's not threads that JavaScript is using, then how do event handlers work "behind-the-scenes"?)</p>
javascript jquery
[3, 5]