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
5,131,553
5,131,554
Transferring data from PHP to Java
<p>I have an XML file which I need to parse using PHP and send the parsed data to Java, what are some best practices to accomplish it ?</p>
java php
[1, 2]
5,673,580
5,673,581
I can't remember programming 5 mins after learning?
<p>I'm learning Java, and I found a great teacher. He explains everything perfectly. I understand it <em>all</em>. My problem, is that after learning a short section, for example "Nested If Statements" or "Many Methods and Instances", I can type it all great, but in 5 mins, after going on to a new section (when I'm comfortable with the last section) I forget the code to type for the last section. Any tips or techniques you guys use to remember code????</p>
java javascript
[1, 3]
2,322,991
2,322,992
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]
4,204,691
4,204,692
How to get the css of a javascript container and all objects within it in javascript or jquery
<p>Some elements in my page are rendered through php code. Sometimes, on link clicks that redirect to a page in the same site, I want to insert html elements like div, span etc through javascript in their respective places. My main question is: how do I insert the elements in the appropriate place, and apply the same css styles to them as they would have if they had been inserted through normal flow like php or html code.</p> <p>For example, suppose I need to insert a div element, which has a span element and an image element inside it, inside a container that has the other elements with the same structure:</p> <pre><code>&lt;div class="container"&gt;&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;img /&gt;&lt;/div&gt;...&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;img /&gt;&lt;/div&gt; &lt;/div&gt; . </code></pre> <p>I want to apply same style rules to my inserted elements as there are for other elements. That is, the inserted </p> <pre><code>&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;img /&gt;&lt;/div&gt; </code></pre> <p>should have the same styles applied as </p> <pre><code>&lt;style&gt; </code></pre> <p>.container div {...} .container div span {...} .container div img{...} </p> <p>But I dont want to manually compute the styles and then add those styles in jquery. How do I do this. The second part of this question is: suppose there are conditional styles applied depending on the browser. Now, how do I apply the conditional styles depending on the browser, without trying to do it manually?</p>
javascript jquery
[3, 5]
1,077,035
1,077,036
Designing Game Randomization Logic
<p>I am creating a game that adds sprites to my scene randomly. The randomness is weighted and I can change the weight based on the supplied parameters to my method to change which sprite I want to be added more than others.</p> <p>Now the game is round based. So, during round one I would like for the weight of the sprite the user needs to be shown a lot which I will set by the weight, and set the other sprites at a lower weight to make it easy in the first stage.</p> <p>The second round I would like to change the weights up and make them a little harder by mixing more of the unneeded sprites into the scene. </p> <p>The problem is I don't want to hard code this since I want the user to go on as many rounds as they can. So how could I make this where it isn't hard coded to do what I needed it to do? </p> <p>Hope this makes sense</p> <p><strong>EDIT:</strong></p> <p>So basical what happens is i have a wiehgt method that controls the probability of a sprite being added to the scene over the other 3 sprites.</p> <pre><code>updateWeights(int itemNumber, double weight); </code></pre> <p>That is my method i use to update each sprites weight by supplying the sprites itemNumber then the weight i want to use.</p> <p>What i would like to do is as the user gets further along in the game based on a requirement i set the game will gradually get harder by changing the weights to different weights. The thing is the sprite that MUST show on the scene more than the others should always be higher than the others(this is why i don't want to use a random generator). See what i mean? If anyone sees easier logic to this please feel free to suggest it.</p>
java android
[1, 4]
2,662,406
2,662,407
print an asp .net page without considering IE version
<p>net site with a print option (onclick = window.print()) the problem is that when using IE 7 it gets fine on the page but when users using IE 6 print the page they get it larger than the page is</p>
c# asp.net javascript
[0, 9, 3]
2,328,609
2,328,610
JQuery: replace a string inside a div
<pre><code>&lt;div id="content"&gt; ... &lt;p&gt;NUMBER times...&lt;/p&gt; ... &lt;p&gt;Place N°: NUMBER&lt;/p&gt; &lt;/div&gt; </code></pre> <p>How do I replace all NUMBER inside the content div? I tried <code>replace</code> method but it didn't work.</p> <p>Thanks.</p>
javascript jquery
[3, 5]
1,759,356
1,759,357
How do i get parent caller
<p>Let us say that user opens Twitter app and hits share button for a selected tweet. He then sees my app in the list along with other apps like Gmail, SMS etc.</p> <p>In OnCreate method of my activity, I process the tweet. Remove short links etc and then call the PostActivity of twitter app. Below code then shows "My tweet" in compose tweet section of twitter app.</p> <pre><code> Intent intent1 = new Intent("android.intent.action.MAIN"); intent1.setComponent(new ComponentName("com.twitter.android","com.twitter.android.PostActivity")); intent1.setAction(android.content.Intent.ACTION_SEND); intent1.putExtra(android.content.Intent.EXTRA_TEXT,"my tweet"); intent1.setType("text/plain"); startActivity(intent1); </code></pre> <p>What i want to do is ,before i call PostActivity, i need make 100% sure that my activity was called from twitter app. </p>
java android
[1, 4]
2,261,151
2,261,152
div hides onmouseover event on a link
<p>I have a div and a simple jQuery code that calls the div on an 'onlclick' event and properly hides on 'onmouseout' event. The problem is when I put a text or a link inside this div and move a cursor over the text / link in this div - it triggers out() function effect and dissappears - even if the cursor is still inside the div. Why is that so ? Thanks for comments.</p> <pre><code>&lt;script src="js/jquery.js"&gt;&lt;/script&gt; &lt;style type="text/css"&gt; #sample { position:relative; width:500px; height:200px; background-image:url(images/img.png); background-repeat:repeat-x; } &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;a href="javascript:show();" &gt;link&lt;/a&gt; &lt;div id="sample" onmouseout="out()"&gt;&lt;a href=""&gt;THIS IS TEXT&lt;/a&gt;&lt;/div&gt; &lt;script type="text/javascript"&gt; $(document).ready(function() { $("#sample").hide(); }); function show() { $("#sample").fadeIn('slow'); } function out() { $("#sample").fadeOut('slow'); } &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
javascript jquery
[3, 5]
3,818,890
3,818,891
dynamically adding validators
<p>In my case I would like to dynamically add validators to my control based on given logic. For each control I first check something in my DB and if it goes aout that field is required I would like to add requiredField to that control. I firt iterate through each control and if its required I add attribute required="true".</p> <p>I added this code but it doens work I mean nothing happens, none validation is being made.</p> <pre><code>if(gc.Attributes["controlid"] != null) { RequiredFieldValidator validator = new RequiredFieldValidator(); validator.ControlToValidate = gc.Attributes["controlid"]; validator.ErrorMessage = gc.Attributes["errormessage"]; this.Controls.Add(validator); } </code></pre> <p>Thanks for any suggestions.</p>
c# asp.net
[0, 9]
435,989
435,990
Javacript for validating select box
<pre><code>&lt;select name="fruits"&gt; &lt;option value="apple"&gt;Apple&lt;/option&gt; &lt;option value="orange"&gt;Orange&lt;/option&gt; &lt;option value="pears"&gt;Pears&lt;/option&gt; &lt;/select&gt; /* fruits stored in the database */ &lt;?php $items as $each_fruit) { $fruit_count++; $a[]=$each_fruit-&gt;fruit_name; ?&gt; </code></pre> <p>The selected values are already stored in the database. I don't want to allow to add the fruit again....</p> <p>How can I check that using javascript? </p>
php javascript
[2, 3]
3,710,613
3,710,614
Getting value of dynamically generated textfield
<p>I have a table that has been generated dynamically using PHP. The table has a few textfields which are being used to update the database based on the row. This question can be referred at: <a href="http://stackoverflow.com/questions/9726265/save-dynamically-generated-textfield-from-php">Complete question</a>, based on one for the answer i am using javascript which gets the textfield value when enter is pressed. The javascript being used is:</p> <pre><code>$("#details input").live('keypress', function (e) { var code = (e.keyCode ? e.keyCode : e.which); if (code == 13) { e.preventDefault(); var ourId = $(this).id; var updatedText = $(this).val; alert(updatedText); } }); </code></pre> <p>However for some reason <code>$(this)</code> isn't returning the expected result.</p> <p>Any help will be appreciated, thanks.</p>
javascript jquery
[3, 5]
3,571,336
3,571,337
regarding sending mail to user
<pre><code>MailMessage message = new MailMessage(); message.From = new MailAddress("[email protected]"); </code></pre> <p>Now for fetching email entered by the user in the textbox, I wrote:-</p> <pre><code> message.To.Add(Convert.ToString(txtEmail)); </code></pre> <p>but this is not working..isn't this the correct way to add email address in "To" ? txtEmail is the textbox's name..Its not giving any error or something..just not working..when I comment out this line of code..the code line next to it works..otherwise code stops working when it encounters this "To.Add " method..plz help..thnx</p> <p><em><strong>[edit] I changed it to</em></strong></p> <pre><code>message.To.Add(txtEmail.ToString()); </code></pre> <p>still not working</p>
c# asp.net
[0, 9]
5,180,245
5,180,246
Why does putting jQuery code does not work sometime when placed inside <head> tag
<p>I often find myself in a place where even a simple jQuery code like below -</p> <pre><code>jQuery(document).ready(function () { jQuery("input[type='text']").click(function () { this.select(); }); }); </code></pre> <p>Does not work when placed inside "head" tag, but moving this snippet just before the end of body tag in master page works fine. Is there any basic JavaScript/jQuery principle which I am missing.</p>
jquery asp.net
[5, 9]
5,333,844
5,333,845
A sensible path to becoming a C# and ASP.NET guru?
<p>I suppose this question is pretty subjective, but I think there is bound to be a path that most people consider sensible.</p> <p>I've been working with C# and ASP.NET for about 3 years, but I've only just started REALLY studying it. My goal is to become a guru in say... 5-10 years. What skills should I have? What should I make sure I have a full understanding of? What types of applications should I make to test myself? Are there any other languages that I should learn to increase my understanding/ability in C#?</p> <p>Additionally, is there a particular order to learn the skills in? Say, hypothetically:</p> <ul> <li>Learn C# to an intermediate level</li> <li>Learn C++/C for a more base level understanding</li> <li>Learn CIL to understand what the compiler is doing to your C#</li> </ul> <p>Etc. etc.</p> <p>I appreciate any help you guys could give me. Any book/blog/website recommendations, anything really.</p>
c# asp.net
[0, 9]
5,865,744
5,865,745
How to sorting the gridview data
<p>See the below code, I am try to sorting Grid view data by calling function provided by the Microsoft vs 2008, but the paging is done well but the sorting process is not work, tell me where should i change the following code and yes i put grid view in updated penal,is there problem regarding to update penal? </p> <pre><code>protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e) { GridView1.PageIndex = e.NewPageIndex; showData(); } protected void GridView1_Sorting(object sender, GridViewSortEventArgs e) { try { SqlCommand cmd = new SqlCommand("showData", con); cmd.CommandType = CommandType.StoredProcedure; SqlDataAdapter da = new SqlDataAdapter(cmd); DataSet ds = new DataSet(); da.Fill(ds); if (ds.Tables[0] != null) { ds.Tables[0].DefaultView.Sort = e.SortExpression + " " + sortType(e.SortDirection); GridView1.DataSource = ds; GridView1.DataBind(); } } catch (Exception ex) { Label1.Text = ex.ToString(); } } private string sortType(SortDirection sortDirection) { string newSortDirection = String.Empty; switch (sortDirection) { case SortDirection.Ascending: newSortDirection = "DESC"; break; case SortDirection.Descending: newSortDirection = "ASC"; break; } return newSortDirection; } </code></pre>
c# asp.net
[0, 9]
2,221,082
2,221,083
Problem with jquery .submit() and variables
<p>I am not sure what to do and why it is not working it is my first attempt at something like this.</p> <p>Here is a fiddle of it <a href="http://jsfiddle.net/ProjectV1/LVPtN/" rel="nofollow">http://jsfiddle.net/ProjectV1/LVPtN/</a></p> <p>You will notice in javascript I have a var error which is by default false.</p> <p>If there is an error it is true.</p> <p>I have displayed the value of error next to each input on my form.</p> <p>If the variable error is false it should submit the form and false it shouldn't.</p> <p>The problem arises when an error occurs, and is then corrected the form will not submit.</p> <p>Look at the fiddle. The form directs to google just for testing.</p>
javascript jquery
[3, 5]
4,287,203
4,287,204
Placing a icon to display text onmouseover
<p>I have developed an e-commerce site. For user form input box, i want to put a question mark icon as help tool. When user takes mouse on that icon it should display the help text. I am not getting how to do it. Please someone help me in doing this .</p> <p>Thanks</p>
javascript jquery
[3, 5]
472,026
472,027
How to add data items to a List<Struct>
<p>I have the following struct defined in a user control:</p> <pre><code>public struct ColumnData { public string ColumnName { get; set; } public string ColumnDataItem { get; set; } public bool ColumnIsHyperLink { get; set; } public string ColumnHyperLinkURL { get; set; } public string ColumnHyperLinkPK { get; set; } } </code></pre> <p>I create a new instance of <code>List&lt;ColumnData&gt;</code> (In a different code behind that creates an instance of the user control) and want to pass in values to it, but how do I assign them to specific attributes within the struct object?</p> <p>I create an instance of the struct using the following code: </p> <pre><code>List&lt;ColumnData&gt; DataItems = new List&lt;ColumnData&gt;(); </code></pre>
c# asp.net
[0, 9]
5,550,661
5,550,662
Jquery Table plugin
<p>I need a table plugin that does the following</p> <ol> <li>Uses json and html table as the datasource</li> <li>supports pagination</li> <li>can specify how many rows to show by the user(i.e user can change rows per page)</li> <li>sorting of columns</li> <li>searching (complex searching options is welcome)</li> <li>free for commercial projects</li> <li>dynamic addition/deletion</li> <li>refresh option</li> </ol> <p>Finally the <strong>main requirement</strong> is searching, sorting,pagination all needs to happen client side. No server interaction needed.</p> <p>One more thing dont know if possible say i have 1000 records i want 100 to show up initially in 10 pages (i.e 10 each in 10 pages) only when user clicks on page 11 it fetches next 10 from server </p> <p>Thanks </p>
javascript jquery
[3, 5]
132,091
132,092
Button disable function after clicking on it
<p>i have save button in around 150 pages. when ever the user clicks on save button i should disable the button after the click. so that user does not keep clicking on save button again.</p> <pre><code> protected void Button1_Click(object sender, EventArgs e) { // right now once the user clicks the save button Button1.Enabled = "false" } </code></pre> <p>right now i am doing like this. is there any better solution u can provide me to improve codeing here would be great.</p> <p>thank you </p>
c# asp.net
[0, 9]
4,446,357
4,446,358
Single declaration of connection string in application
<p>In my asp.net application I have added the connection string in each page <code>Page_Load</code> function and declared the string as public in top of the page.</p> <p>I know this is wrong thing. The whole application is running the same connection, so I want to declare the connection string in only one place. Where should I declare the connection string? How can I access the connection string in each Connection?</p> <pre><code>public string connstring = ""; protected void Page_Load(object sender, EventArgs e) { if (IsPostBack != true) { connstring = ConfigurationManager.ConnectionStrings["connString"].ToString(); MySqlConnection connection = new MySqlConnection(connstring); // ---- } } </code></pre>
c# asp.net
[0, 9]
1,541,932
1,541,933
how to get file names from input type file in html 5 using javascript or jquery
<p>below is my simple code using HTML 5 multiple file upload. All i need is to grab all the file names not the paths below is simple javascript code </p> <pre><code> function getFileNames() { var path = $('#files').val(); console.log(' path = ' + path); } </code></pre> <p>and html form is as </p> <pre><code>&lt;form action='server.php' method='post' enctype='multipart/form-data' target="iframe"&gt; &lt;input id="files" name='files[]' type='file' multiple&gt; &lt;input type='button' onclick="getFileNames()"&gt; &lt;/form&gt; </code></pre> <p>when i press the button the console output is as </p> <p>path = Chrysanthemum.jpg</p> <p>which is the first name of the file and i want the remaining names , any suggestions , comments are appreciated. thanks. </p>
php javascript jquery
[2, 3, 5]
273,294
273,295
Disable browsers vertical and horizontal scrollbars
<p>Is it possible to disable the browsers vertical and horizontal scrollbars using jQuery or javascript?</p>
javascript jquery
[3, 5]
4,623,465
4,623,466
Jquery slidetoggle question
<p>How can I get one script of jQuery to start after another one has finished (or time it when you want it to start)? I have a content area that fades in on page load:</p> <pre><code>$(document).ready(function() { $("#content").hide(); $(window).load(function() { $("#content").fadeIn(3000); }); }); </code></pre> <p>Than, once that fades in I want the nav bar above the content area to slide toggle down. I'm trying to make the scripts act in accordance with the timing of one another. OK, thank you.</p>
javascript jquery
[3, 5]
2,125,212
2,125,213
reorder list elements - jQuery?
<p>I am experimenting with jQuery lately, and I was wondering if it's possible with js or pure jquery to reorder <code>&lt;li&gt;</code> elements. So if I have a silly list like the following:</p> <pre><code>&lt;ul&gt; &lt;li&gt;Foo&lt;/li&gt; &lt;li&gt;Bar&lt;/li&gt; &lt;li&gt;Cheese&lt;/li&gt; &lt;/ul&gt; </code></pre> <p>How would I move the list elements around? Like put the list element with <code>Cheese</code> before the list element with <code>Foo</code> or move <code>Foo</code> to after <code>Bar</code>. </p> <p>So is it possible? </p> <p>If so, how?</p> <p>Thanks!!</p>
javascript jquery
[3, 5]
2,251,633
2,251,634
Preventing jQuery function to repeat effect twice?
<p>i am making a something like this : When a user <strong>mouseenter</strong> DIV1 , the DIV2 will <strong>fadeIn</strong> and when the user <strong>mouseout</strong> DIV1 , DIV2 will <strong>fadeOut</strong></p> <p>But something weird is happening , when you hover in and out DIV1 quickly , the FADEIN and OUT effect of DIV2 will repeat the total number of your hovers in.</p> <p>For example: i quickly hovers in and out for 10 times @ DIV1 , DIV2 will continue to FADE IN and OUT for 10 times although my mouse is not hovering it.</p> <p>I hope people understand what i'm saying.</p> <p>CODE:</p> <pre><code>$('div1').bind('mouseenter', function() { $('div2').fadeIn(600); }); $('div1').bind('mouseout', function() { $('div2').fadeOut(600); }); </code></pre> <p>Thanks and have a nice day .</p>
javascript jquery
[3, 5]
2,283,248
2,283,249
Get the parent/ancestor UL
<p>I have a HTML markup that looks like</p> <pre><code>&lt;ul&gt; ... &lt;li&gt; &lt;ul class="x"&gt; ... &lt;a href="#"... </code></pre> <p>How can I get the parent <code>ul.x</code> element from a click event hooked on the link?</p> <p><code>this.parentNode</code> works if the UL is the parent element, but if it's one of the ancestors I have to use <code>this.parentNode.parentNode</code> depending on how many parent elements are in between...</p> <p>Can I somehow get the first UL parent?</p>
javascript jquery
[3, 5]
4,217,434
4,217,435
Cool UI templateing VS Jquery Templating
<p>i have read this article <a href="http://weblogs.asp.net/scottgu/archive/2006/10/22/Tip%5F2F00%5FTrick%5F3A00%5F-Cool-UI-Templating-Technique-to-use-with-ASP.NET-AJAX-for-non%5F2D00%5FUpdatePanel-scenarios.aspx" rel="nofollow">ScuttGu</a></p> <p>for making use of User control to make Client side templates.</p> <p>and this one too</p> <p><a href="http://encosia.com/2008/06/26/use-jquery-and-aspnet-ajax-to-build-a-client-side-repeater/" rel="nofollow">Ecnosia</a></p> <p>are they the same, regarding performance ? thanks in advanced.</p>
c# asp.net jquery
[0, 9, 5]
551,092
551,093
clear input with particular type attribute
<p>this:</p> <pre><code>$("#registrant input").val(''); </code></pre> <p>will clear all the <code>&lt;input&gt;</code> inside the div <code>#registarnt</code>.</p> <p>But, how can i exclude the input with particular type? (like "submit")</p>
javascript jquery
[3, 5]
5,507,952
5,507,953
display a particular number from dropdownlist
<p>Is there a way in dropdownlist to show the desired number on pageload.</p> <p>eg. I have a dropdownlist control</p> <p>I am using a for loop to populate it</p> <pre><code>for (int i = 1; i &lt;= 100; i++) { DropDownList1.Items.Add(i.ToString()); } </code></pre> <p>Now this displays 1 on page load ... but i want to display 7.. how do i do that?</p>
c# asp.net
[0, 9]
2,713,528
2,713,529
Issue Releted to Parameter in RDLC Reports
<p>I have ASP.Net Application in Visual Studio 2008. I have added Report Parameter in RDLC Report, I want to draw Parameter in my rdlc Report in Design View, but i dont find <code>"Report Data Panel"</code> in my ASP.Net Application... i Tried <code>ALT+CTR+D</code> but it doesn't work. How can i draw Parameter in my RDLC Report design? Thanks..</p>
c# asp.net
[0, 9]
4,304,096
4,304,097
tool tips for creating on tab menu
<p>hi in my application i have tab menu which i done using css. when ever user moves the cursor on the tab he should been given an tooltip for that tab. is it ther any solution i can solve using JQuery or any other concept.</p> <p>thank you </p>
c# asp.net jquery
[0, 9, 5]
5,045,668
5,045,669
jQuery Slide + events
<p>I'm developing a page that will present the user with a content slider, so that the user can click 'next' to browse through the slides.</p> <p>However, I also want to hide any 'previous' buttons/links and additionally, when the user reaches the last slide in the list the 'next' button needs to be replaced with a different button and take the user to another page on the site instead of going back to the beginning of the slides.</p> <p>I wondered if anyone had any advice on how to code this?</p> <p>Thank you.</p>
javascript jquery
[3, 5]
4,924,424
4,924,425
Adding multiple boxes in one page and saving the info from each box
<p>I have this task - to make a simple CMS where one of the abilities should be to create a page and add as many boxes as the admin would like and then to have the ability to edit each one of them using ckeditor, and ofcourse the page should be visible in the frontend.</p> <p>For now I'm just using CodeIgniter trying to keep things simple but for this task I can't think of pure PHP solution. I'm not much into JS and it's libraries/frameworks so what do you think is the solution with the smallest learning curve? I can't invest too much time in this, so I'm searching for an easy to implement solution (if there is such)?</p>
php javascript
[2, 3]
1,220,518
1,220,519
how to handle two function
<p>I have two funtions <code>searching</code> and <code>searchhistory</code>. Currently these two function are running in my code but the value of <code>nbofimages</code> is not updated. </p> <p>Also it's showing only one alert message after searchhistory function is completed.</p> <pre><code>$.when(searching(searchkwd, check_st, check_sf, '31', '1', filter, ori, colorcheck)) .then(searchhistory(user_search,search_pars,search_username,nbofimages)); var nbofimages; function searching(searchkwd, check_st, check_sf, '31', '1', filter, ori, colorcheck) { nbofimages = "3"; alert(nbofimages); } function searchhistory(user_search,search_pars,search_username,nbofimages) { alert(nbofimages); } </code></pre>
javascript jquery
[3, 5]
627,130
627,131
Adding start delay
<pre><code> function moveto(coordinates) { step1 = coordinates[0]; step2 = coordinates[1]; var w = $(document).width(); var h = $(document).height(); $( "#full" ) .animate({left: -(step1 * w)}, 2000 ) .animate({top: -(step2 * h) }, 500 ); } var randomNum = randomNumbers(); moveto(randomNum); </code></pre> <p>I need to add start delay of this function and to replay after a certain time</p>
javascript jquery
[3, 5]
3,578,159
3,578,160
change selecteditem of dropdownlist after binding
<p>i have a droplist in page that i bind this with code</p> <pre><code> Category catObj = new Category(); dropCat.DataSource = catObj.GetAllCategory(); dropCat.DataTextField = "Title"; dropCat.DataValueField = "CategoryID"; dropCat.DataBind(); </code></pre> <p>i want change selected item of droplist with ths code</p> <pre><code>dropCat.SelectedIndex = Convert.ToInt32(catObj.ParentId); </code></pre> <p>but this code cant change the selected item please help me thank you all</p>
c# asp.net
[0, 9]
5,278,112
5,278,113
JS: window.setInterval still running in the background?
<p>My code is like:</p> <pre><code>window.setInterval(updateSeconds, 1000); function updateSeconds() { var remainingSeconds = $('#seconds').html() - 1; if(remainingSeconds &lt; 0) { remainingSeconds = 0; } $('#seconds').html(remainingSeconds); if(remainingSeconds == 0) { //stop calling updateSeconds } } </code></pre> <p>There is no issue, except that setInterval will still keep calling updateSeconds(), is there a way to stop it?</p>
javascript jquery
[3, 5]
4,037,762
4,037,763
jquery attr("onClick") - ie and ff
<p>Using jquery, I'd like to get the javascript from an A tag's onClick attribute.</p> <pre><code>&lt;a href='#' onClick='alert("boo");' /&gt; </code></pre> <p>In Firefox: <code>alert($('a').attr("onClick"))</code> shows: <code>alert("boo")</code></p> <p>In IE 6/7: <code>alert($('a').attr("onClick"))</code> shows: <code>function anonymous(){alert("boo");return false;}</code></p> <p>How can I retrieve just the javascript, and not the wrapped function, in IE 6/7 using jquery? (or plain javascript)?</p> <p>Franko</p>
javascript jquery
[3, 5]
5,055,099
5,055,100
Disable button refresh browers
<p>I have a problem with sending message. I create a jsp page with calling form to send message using method Post. when i click button refresh on browers FF, it automatically send message again. I don't want to again send it. How could i disable button refresh?.</p>
java javascript jquery
[1, 3, 5]
1,385,881
1,385,882
Hide/Show elements with jQuery
<p>I have following site structure</p> <pre><code>&lt;div id="movies"&gt; &lt;a href=""&gt; &lt;div&gt;content&lt;/div&gt; &lt;/a&gt; &lt;a href=""&gt; &lt;div&gt;content&lt;/div&gt; &lt;/a&gt; ... &lt;/div&gt; </code></pre> <p>There can be up to 50 <code>a tags</code> inside <code>#movies</code>. I want to show only 10 and reveal another 10 if the user requests it.</p> <p>So I came up with following jquery code.</p> <pre><code> var count = $("#movies a").length; if(count &gt; 10){ for(i = 11; i &lt;= count; i++){ $('#movies a:nth-child('+i+')').hide(); } $('#more').append('&lt;a&gt;show more&lt;/a&gt;'); } $('#more a').click(function(){ var hidden = $("#movies a").filter(":hidden"); var count = 0; for(element in hidden){ if(count &lt;= 10){ element.show(); } } }); </code></pre> <p>But this gives me <code>Uncaught TypeError: Object 0 has no method 'show'</code>. Any ideas why? What do I need to change/add to make the idea work?</p>
javascript jquery
[3, 5]
254,474
254,475
Masked Input Plugin with a default value
<p>I've been using digitalbush's <a href="http://digitalbush.com/projects/masked-input-plugin/" rel="nofollow">masked input plugin</a>, and I was wondering if there was any way you could add a default value to the masked fields. </p> <p>I've tried adding it using:</p> <pre><code> &lt;input id = "date" type="text" value="DD/MM/YYYY" onfocus="this.value = this.value=='DD/MM/YYYY'?'':this.value;" onblur="this.value = this.value==''?'DD/MM /YYYY':this.value;"&gt; </code></pre> <p>but after applying the masking via </p> <pre><code>&lt;script type="text/javascript"&gt; $(document).ready(function(){ $("#date").mask("99/99/9999", {placeholder:"#"}); }); &lt;/script&gt; </code></pre> <p>The default value HTML no longer works.</p>
javascript jquery
[3, 5]
1,400,936
1,400,937
Why is $(document).ready not firing for me?
<p>In a php file i have used <code>include</code> to include the following js.php file and prior to that i have included the jquery file.</p> <pre><code>&lt;script type="text/javascript"&gt; $(document).ready(function(){ alert("hello"); }); &lt;/script&gt; </code></pre> <p>But it doesn't work. Why? when I skip the $(document).ready function it works.</p> <p>But i need jquery code inside. what is wrong?</p>
php javascript jquery
[2, 3, 5]
4,978,898
4,978,899
unable to add textboxes to listbox
<p>hi I want to add textboxes to a listbox with everyclick on the add button. so here are my codes</p> <pre><code>this.ListBox1.Controls.Add(TB);//TB is the name of my TextBox and it has been defined and initialized </code></pre> <p>I even tried to use Addat </p> <p>there are no errors but it doesnt work</p>
c# asp.net
[0, 9]
796,726
796,727
DataSet or Reader or What?
<p>When using a Class to get one row of Data from the Database what is best to use:</p> <ul> <li>A DataSet? </li> <li>A Reader and do what store the data in a Structure?</li> <li>What else?</li> </ul> <p>Thanks for your time, Nathan</p>
c# asp.net
[0, 9]
2,144,567
2,144,568
Access table based on selection criteria in C#
<p>I am working on application where I got to access data from 2 sheets, get the account number from first sheet and then look for those accounts in sheet 2.<br> I am using <code>OleDbDataAdapter</code> to select and count the number of occurrance but now the issue is to access those records out of all. One way I am thinking is to get the first occurrance row number, number of rows with specific account and use for loop to access each row. </p> <p>Is there any other method you think of doing this.... Thanks,</p> <pre><code>oconn2.Open(); OleDbDataAdapter db = new OleDbDataAdapter("select * from [Sheet2$] where [Sheet2$].account_number= '" + account_number + "'", oconn2); DataTable dt = new DataTable(); db.Fill(dt); int iRow = dt.Rows.Count; </code></pre>
c# asp.net
[0, 9]
858,988
858,989
PHP : how to return back to previous page while closing pop up
<p>I have a form submission. While i Click Submit button, will check for mandatory fields and if the fields are blank, I am opening a popup window using javascript to show error message. So once I close the popup I am not going back to previous page Instead it shows a white blank screen.</p> <p>My code for verification and opening popup is :</p> <pre><code>&lt;?php if (isset($_POST['submit'])) { if ($task == '' || $comments == '') { // generate error message print "&lt;script type='text/javascript'&gt;"; print "window.open('error.php','new_window1','status=1,scrollbars=1,resizable=0,menu=no,width=320,height=220');"; print "&lt;/script&gt;"; } else { $sql3= "INSERT INTO work (task, comments, assignee, type, priority, dataum1, dataum2, status) VALUES ('$task', '$comments', '$assignee', '$type', '$priority', '$dataum1', '$dataum2', '$status')"; mysqli_query($mysqli,$sql3) or die(mysqli_error($mysqli)); } } ?&gt; </code></pre>
php javascript
[2, 3]
1,949,056
1,949,057
Convert to numbers in Android app
<p>I am trying to create an Android app and I have gotten stuck. I am getting input text with EditText and I need to convert it to a number (as I need to do some mathematical functions). My problem is that none of the integer.something functions works with EditText. Could you suggest something?</p> <p>Cheers!</p>
java android
[1, 4]
1,517,639
1,517,640
How to create a dict that contains Java Classes hierarchy (in Python)?
<p>I'm creating a class diagram drawer for Java and I need to look into standard Java Classes to check whether two classes have common ancestor (some additional feature). I was thinking of creating a dict that will contain class hierarchy, but I have no idea how to create it. The first thing I found is to create it from text file, that will use information from there: <a href="http://docs.oracle.com/javase/6/docs/api/allclasses-frame.html" rel="nofollow">http://docs.oracle.com/javase/6/docs/api/allclasses-frame.html</a>. But I don't think it's the best solution. Any other ideas?</p>
java python
[1, 7]
1,266,220
1,266,221
image control not refresh the stream when saving snapshot images to avi file - ASP.net, C#, AForge.net
<p><br /> I am trying to get a snapshot from MJPEG stream of a Panasonic IP Camera and save all the jpeg snaphot image to avi file as a video file while the live video stream is loading to an image control of asp.net using aforge.net, and now I am facing a problem as the following: <br /><br /> - the live video stream stops loading while getting the snapshot using webresponse. <br /> <br/> Below is the codes: <br/> </p> <pre><code>try { WebRequest request = WebRequest.Create(SnapShotURL); request.Credentials = new NetworkCredential(txtUserName.Text.Trim(), txtPassword.Text.Trim()); response = request.GetResponse(); Stream responseStream = response.GetResponseStream(); bmpSnapshot = new Bitmap(responseStream); } catch (Exception ex) { } finally { imgStream.ImageUrl = ""; response.Close(); } </code></pre> <p>Your help is highly appreciated.</p>
c# asp.net
[0, 9]
3,010,529
3,010,530
How to use dynamic login ID and password in a Message API
<p>I am facing a problem in using a message API. I want to fetch the loginID and password of that message portal from the database of my web application but it is not working. I have to write the ID and Password in the code itself. I need help in making that code dynamic.</p>
c# asp.net
[0, 9]
4,851,877
4,851,878
How to use an array value from php to javascript?
<p>it was always a question for me that how can i use an array value in javascript while that array is defined in my php scripts </p> <p>For example consider reading some values from a file and use it in javascript.</p> <p>what's ur plan to do so ? </p>
php javascript
[2, 3]
1,270,729
1,270,730
jquery loading animation with php form that submits back to itself
<p>I have a PHP file that contains a form and which submits back to itself. Is there any way to show a loading animation after the form is submitted and run until the page is loaded?</p>
php jquery
[2, 5]
3,689,000
3,689,001
why shouldn't we put any javascript code between the <script> tag if we only want to include external js file?
<p>i don't really understand why the author in the "Javascript &amp; Jquery: the missing manual , second edition" advise the sentence below:</p> <blockquote> <p>When adding the src attribute to link to an external JavaScript file, don’t add any JavaScript code between the opening and closing tags. If you want to link to an external JavaScript file and add custom JavaScript code to a page, use a second set of tags. For example:</p> </blockquote> <p>what is the advantage of using the second script tag instead of only using one?</p>
javascript jquery
[3, 5]
1,385,937
1,385,938
How to access a panel inside gridview from Javascript?
<p>I have a grid view, which contains a dropdownlist and a panel that i want to make invisible and visible by the selected value of the dropdownlist.</p> <p>The javascript code which works when not used with the gridview is:</p> <pre><code> function showPannel(panelId,dropdownId ) { var panel = document.getElementById(panelId); var dropDown = document.getElementById(dropdownId); if (dropDown.options[dropDown.selectedIndex].value = 'Diesel Deals') { panel.className = "visibleDiv"; } else{ panel.className = "hiddenDiv"; } } </code></pre> <p>i'm passing the panelId and dropdownlist id from here:</p> <pre><code> if (e.Row.RowType == DataControlRowType.DataRow) { Panel p = (Panel)e.Row.FindControl("Panel1"); DropDownList t1 = (DropDownList)e.Row.FindControl("DropDownList1"); t1.Attributes.Add("onchange", string.Format("javascript:showPannel('{0}', '{1}')",p.ClientID, t1.ClientID )); } </code></pre> <p>but it is not working. The function is getting called, but its giving undefined when dropDown.options[dropDown.selectedIndex].value is alerted.</p> <p>I tried to do </p> <pre><code> Gridview1 = document.getElementById('&lt;%=GridView1.ClientID%&gt;'); var cell = Gridview1.rows[0].cells[2]; var dropdownlist = cell.childNodes[0]; var dropdownSelectedValue = dropdownlist.options[dropdownlist.selectedIndex].value; alert(dropdownSelectedValue); </code></pre> <p>but its not working either.</p> <p>Please help</p> <p>Thanks</p>
c# javascript asp.net
[0, 3, 9]
5,324,984
5,324,985
for loop and appending the set of result to div
<p>I want to append every 3 records to one div in a for loop. numberList is dynamic so we are not sure of the exact length. requirement is that pick 3 records and wrap it in div. For example if numberList.length is 7 then we should have 3 divs. first 2 div will contain 3 records and last div will have one record.</p> <p>How to go about this?</p> <pre><code>for (var j = 0; j &lt; numberList.length; j++) { number = numberList[j].Number; } </code></pre> <p>after every 3 records, take the result and append in one div</p>
javascript jquery
[3, 5]
814,194
814,195
Language redirect in java
<p>i have a page where i do not want to show a particular language e.g russian to the user as this language is currently in testing phase. But if a user has settings in firefox UNDER content tab to have russian as default language , this page shows up and i do not want to have this functionality , it should redirect to english Locale but when i explicitly mention in the URL as locale = russian it should come in russian only (FOR TESTING PURPOSE, I WANT THIS FUNCTIONALITY) </p>
java javascript
[1, 3]
2,372,969
2,372,970
Problems with float: it does not return the fraction
<p>I am puzzled that a float does not return the fraction. The code:</p> <pre><code>float max_stops; int maxBellows = 330; int lensFocal = 135; max_stops = (maxBellows / lensFocal ); </code></pre> <p>returns 2.0 instead of 2.44.</p> <p>Can you pls help me get this right?</p>
java android
[1, 4]
1,989,024
1,989,025
jquery onclick run
<p>I need to run all onclick events on page load. how can I do something like this:</p> <pre><code>$('.upload').foreach(function(){ //execute onclick for found element (ex: test(this, 'var') ) }); &lt;div class="upload" onclick="test(this, 'var')"&gt;text&lt;/div&gt; </code></pre>
javascript jquery
[3, 5]
2,342,340
2,342,341
Javascript or JQuery over scroll
<p>I have a table body</p> <pre><code>&lt;tbody id='displaylaps' class='scroll' style='width: 100%'&gt;&lt;/tbody&gt; </code></pre> <p>Which fills with data and scrolls when it reaches a certain vertical length. </p> <p>I wanted to have an over scroll effect like the effect after an iOS safari page ends and bounces back. Also needs to be iOS touch compatible. </p>
javascript jquery
[3, 5]
811,295
811,296
Retrieve data from database using asp.net (Incorrect Syntax near 'user')
<p>The error I am receiving is "Incorrect syntax near 'user'" - however, I cannot see anything wrong with my code - does anyone have any ideas?</p> <pre><code>protected void Page_Load(object sender, EventArgs e) { string db = ""; db = ConfigurationManager.ConnectionStrings["myConnection"].ConnectionString; SqlConnection con = new SqlConnection(db); con.Open(); SqlCommand cmd = new SqlCommand(); cmd.CommandText = "SELECT * FROM user"; cmd.Connection = con; SqlDataReader dr; dr = cmd.ExecuteReader(); while (dr.Read()) { Response.Write(dr[0].ToString()); Response.Write(dr[1].ToString()); Response.Write(dr[2].ToString()); Response.Write(dr[3].ToString()); } con.Close(); } </code></pre>
c# asp.net
[0, 9]
5,939,370
5,939,371
converting jquery to pure javascript
<p>I have a function that creates an image with the canvas object. The last line of the function says this:</p> <pre><code>$('body').css({ 'background-image': "url(" + Canvas.toDataURL("image/png") + ")" }); </code></pre> <p>I'm looking to convert this line into pure javascript to remove the jQuery dependency. Any suggestions?</p> <p>Thanks.</p>
javascript jquery
[3, 5]
1,662,293
1,662,294
Add shortcut to application's menu
<p>I am trying to create an application which adds a menu item to the android installed applications menu. I have been successful at creating homescreen menu but still want my shortcut to be added to the applications menu as well. Is this possible? if so, how can i accomplish this?</p> <p>Thanks</p>
java android
[1, 4]
1,885,893
1,885,894
setSelection jQuery plugin issue (JavaScript)
<p>I've been trying to build an "auto-complete" function for time input using setSelection jquery plugin. Everything seems fine except for the fact that when I try to input time like "1:00AM" the setSelection script selects it and then unselects it for some strange reason. If I throw an alert anywhere in the function, it also works well. I tried some time delays but to no avail. Everything else works just fine. Has anybody worked with setSelection before and encountered similar issue? </p> <p>Any ideas would be very welcome. Here is the link to the problematic script: <a href="https://www.findyournet.com/test/input.html" rel="nofollow">https://www.findyournet.com/test/input.html</a></p>
javascript jquery
[3, 5]
364,783
364,784
How do I find the nearest tbody then loop through its rows and hide them
<p>I have a table that is split up into several tbody's. The first row in each tbody has a button which will be used to hide all other rows in this tbody apart from the row with the button in it. </p> <p>Not sure how to achieve this.</p> <p>My HTML :</p> <pre><code>&lt;table&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td&gt;&lt;button class="hide_button_main"&gt; x &lt;/button&gt;&lt;/td&gt; &lt;td&gt;Label&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Zone 1&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Zone 2&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Zone 3&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Zone 4&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt; </code></pre> <p>Rows with zones 1 to 4 would be hidden but not the row with the label in it</p> <p>My Jquery:</p> <pre><code> $('.hide_button_main').click(function(e) { // var rows = $(this).closest('tbody').find('tr').length; var rows = $(this).closest('tbody'); rows.each(function() { alert('1'); }); }); </code></pre>
javascript jquery
[3, 5]
4,683,745
4,683,746
jQuery bind custom function to appended element
<p>I am trying to create a web app that will allow a user to define a custom JavaScript function and then add a button to their user interface that well preform that function.</p> <p>Here is a sample of the code</p> <pre><code>var customCommands = { command1: { text: 'Hello Console', cFunctionRun: function() { console.log('hello Console!'); } }, command2: { text: 'Hello World', cFunctionRun: function() { alert('hello World!'); } } } </code></pre> <p>Then I wrote a small function that loops though and builds the buttons and adds them to the user interface. The problem is when I append the elements to the user interface than click on the buttons nothing works...</p> <p>Here is one of the methods I tried</p> <pre><code>for (var cmd in customCommands) { command = customCommands[cmd]; button = $('&lt;button/&gt;').html(command.text).on('click', function(){ console.log(command.text); command.cFunctionRun(); } ); } buttonContainer.append(button); </code></pre> <p>Now my loop builds everything just fine and even the <code>.on('click')</code> works, but it always displays the text of the lasted added command?</p> <p>here is <a href="http://jsfiddle.net/nbnEg/" rel="nofollow">http://jsfiddle.net/nbnEg/</a> to show what happens.</p>
javascript jquery
[3, 5]
536,316
536,317
is there enter and leave event on TextBox - asp.net?
<p>Is there enter and leave event on an asp.net TextBox?</p> <p>I need that when i click on the TextBox, the TextBox color will be yellow and when I leave the color will be white.</p> <p>How can I do this?</p>
c# asp.net
[0, 9]
5,046,277
5,046,278
Emulator show's spinner value's tablet show's empty value
<p>In my application i use an MYSQL databank. And i try to load the value's from the Database into the spinner. In the (eclipse) emulator this works perfectally (all items get loaded into the spinners) .</p> <p>But when i try to run my application on my tablet (honeycomb 10.1) the value's from the database don't show up in the spinner. When i try to reach my database from the tablet everything works fine.</p> <p>I'm also using the AsynTask for getting the data so that should not be the problem i think?</p> <p>(The Code Below is working fine on the Emulator but when i load it on my honeycomb tab the data does not get loaded) And im using the AsynTask class to get the connectie to mysql</p> <p>Any advice?</p> <pre><code> // This Thread get's the reservation ID's Thread asyn = new Thread(){ public void run(){ try{ int klok = 0; while(klok &lt; 5000){ sleep(100); klok = klok + 100; } try{ // Ophalen van de Reservaties objecten lijst = mpr.get(); ArrayAdapter&lt;String&gt; AdapterCountries = new ArrayAdapter&lt;String&gt;(Materiaal.this,android.R.layout.simple_spinner_item); AdapterCountries.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); int lenLijst = lijst.size(); String[] temp = new String[lenLijst+1]; for(int x=0; x &lt; lenLijst; x++){ temp[x] = Integer.toString(lijst.get(x).getRes_id()); AdapterCountries.add(temp[x]); } s1.setAdapter(AdapterCountries); }catch(Exception ex){ ex.printStackTrace(); }finally{ //adapter.notifyDataSetChanged(); } }catch(InterruptedException ex){ ex.printStackTrace(); } } }; asyn.start(); </code></pre>
java android
[1, 4]
4,947,561
4,947,562
Include jQuery Using JS Shorthand
<p>So I'm working on a site, and we need to check if jQuery is defined before writing it to the page. I want to convert it to use JS conditional shorthand, but for some reason when I do that the statement does not execute. Here is my code:</p> <pre><code>Original (this works, tested): if (typeof jQuery == 'undefined') { document.write('&lt;script type="text/javascript" src="', JSPATH_REL_symc + 'jquery-1.4.2.min.js','"&gt;&lt;\/script&gt;'); } </code></pre> <p>That version works perfectly. Now I replaced it with this, and for some reason I'm having issues:</p> <pre><code>New w/Shorthand: (typeof jQuery == 'undefined') ? document.write('&lt;script type="text/javascript" src="', JSPATH_REL_symc + 'jquery-1.4.2.min.js','"&gt;&lt;\/script&gt;') : ''; </code></pre> <p>Any idea what is wrong with this syntax?</p> <p>Thanks.</p>
javascript jquery
[3, 5]
4,720,531
4,720,532
How to make more than one listview respond for different onItemClickListener?
<p>I'm using 4list views with class extending Activity. I have to perform different list item click function. Can i use the following method code for it? Any Help is really appreciated and thanks in advance.</p> <pre><code> public void onItemClick(AdapterView&lt;?&gt; adapter, View view, int index, long id) { switch(view.getId()) { case &lt;listview1 Id&gt; : //call method 1; break; case &lt;listview2 Id&gt; : //call method 2; break; case &lt;listview3 Id&gt; : //call method 3; break; } } </code></pre>
java android
[1, 4]
5,959,717
5,959,718
Explanation needed about linq queries
<pre><code>private bedrijf_modelDataContext dc = new bedrijf_modelDataContext(); public IList&lt;Afdeling&gt; selectAll() { var result = from a in dc.Afdelings select a; return result.ToList(); } </code></pre> <p>This code is supposed to return all the records from the Afdeling-table. This code works, but it comes from my teacher, and there is no explanation whatsoever as to how this works. Can somebody explain what this exactly does? Thank you.</p>
c# asp.net
[0, 9]
1,516,496
1,516,497
autocomplete display distinct items
<p>How do I display distinct items in the autocomplete list? I don't want the duplicates to show up in the list. I'm reading the data from an XML file.</p> <p>Here's my web service code:</p> <p>[WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [ScriptService]</p> <pre><code>public class WebService : System.Web.Services.WebService { [WebMethod] public string[] GetItemsList(string prefixText, int count) { List&lt;string&gt; suggestions = new List&lt;string&gt;(); using (XmlTextReader reader = new XmlTextReader(HttpContext.Current.Server.MapPath("flightdata3.xml"))) { while (reader.Read()) { if (reader.NodeType == XmlNodeType.Element &amp;&amp; reader.Name == "departurelocation") { string itemName = reader.ReadInnerXml(); if (itemName.StartsWith(prefixText, StringComparison.InvariantCultureIgnoreCase)) { suggestions.Add(itemName); if (suggestions.Count == count) break; } } if (reader.NodeType == XmlNodeType.Element &amp;&amp; reader.Name == "destinationlocation") { string itemName = reader.ReadInnerXml(); if (itemName.StartsWith(prefixText, StringComparison.InvariantCultureIgnoreCase)) { suggestions.Add(itemName); if (suggestions.Count == count) break; } } } } return suggestions.ToArray(); } } </code></pre>
c# asp.net
[0, 9]
1,094,721
1,094,722
Which is the better way to get string from BufferedReader
<p>I get <code>BufferedReader</code> from the following networking code.</p> <pre><code> URL url = new URL(request); HttpURLConnection httpUrlConnection = (HttpURLConnection)url.openConnection(); InputStream inputStream = httpUrlConnection.getInputStream(); bufferedReader = new BufferedReader(new InputStreamReader(inputStream)); </code></pre> <ol> <li>I was wondering, which way give higher efficiency in term of execution speed?</li> <li><p>Is 1024 size a good choice for Android? Or, is there any system constant value I can use?</p> <pre><code> int charRead = 0; char[] buffer = new char[1024]; StringBuffer stringBuffer = new StringBuffer(); while ((charRead = bufferedReader.read(buffer)) &gt; 0) { stringBuffer.append(buffer, 0, charRead); } </code></pre></li> </ol> <hr> <pre><code> String line = ""; StringBuffer stringBuffer = new StringBuffer(); while ((line = bufferedReader.readLine()) != null) { stringBuffer.append(line); } </code></pre>
java android
[1, 4]
4,941,010
4,941,011
sorting number via descending order without 0
<p>I need to make numbers in descending order but when it reaches 0, the number should turn into 9..</p> <p>for example, let say <code>num</code> is 2, the order should be <code>2, 1, 9, 8, 7, 6, 5, 4, 3</code></p> <pre><code>var num = 2; $(function() { $(".one").html(num); $(".two").html((num-1)%9); $(".three").html((num-2)%9); $(".four").html((num-3)%9); $(".five").html((num-4)%9); $(".six").html((num-5)%9); $(".seven").html((num-6)%9); $(".eight").html((num-7)%9); $(".nine").html((num-8)%9); });​ </code></pre> <p>But in the code there is 0 and negative numbers, how do i overcome that? </p> <p><a href="http://jsfiddle.net/yqGV7/" rel="nofollow">http://jsfiddle.net/yqGV7/</a></p> <p>Thank you for your assistance.</p>
javascript jquery
[3, 5]
3,496,919
3,496,920
How do you make a resizable rectangle for cropping images in android?
<p>I want to crop my image which is being displayed on an <code>ImageView</code>. How I want to go about it is that I want a re-sizable rectangle to be displayed on the image. That rectangle will have moveable corners (which I can drag around with touch) to increase/decrease its size. The image below illustrates a demo of something I would like to develop.</p> <p><img src="http://img192.imageshack.us/img192/8930/customcropbox.jpg" alt="Screenshot"></p>
java android
[1, 4]
1,920,044
1,920,045
Getting value of dynamically generated textfield
<p>I have a table that has been generated dynamically using PHP. The table has a few textfields which are being used to update the database based on the row. This question can be referred at: <a href="http://stackoverflow.com/questions/9726265/save-dynamically-generated-textfield-from-php">Complete question</a>, based on one for the answer i am using javascript which gets the textfield value when enter is pressed. The javascript being used is:</p> <pre><code>$("#details input").live('keypress', function (e) { var code = (e.keyCode ? e.keyCode : e.which); if (code == 13) { e.preventDefault(); var ourId = $(this).id; var updatedText = $(this).val; alert(updatedText); } }); </code></pre> <p>However for some reason <code>$(this)</code> isn't returning the expected result.</p> <p>Any help will be appreciated, thanks.</p>
javascript jquery
[3, 5]
2,202,434
2,202,435
Accessing ASP.NET controls dynamically from JavaScript
<p>here's what I mean:</p> <p>I have a few controls, for example, </p> <pre><code>&lt;asp:DropDownList ID="ddlDate1" runat="server" /&gt; &lt;asp:DropDownList ID="ddlDate2" runat="server" /&gt; &lt;asp:DropDownList ID="ddlDate3" runat="server" /&gt; </code></pre> <p>in my javascript, I want to do something like this:</p> <pre><code>for (i = 1; i &lt;= count; i++) { something[i] = document.getElementById("&lt;%= ddlDateRange" + i + ".ClientID %&gt;"); } </code></pre> <p>any way I can make this work, or any alternatives?</p>
javascript asp.net
[3, 9]
5,082,173
5,082,174
Jquery removing and adding active class to li nodes & issues with preventDefault
<p>Jquery Removing &amp; Adding 'Active' Class On LI Navigation Works With preventDefault, But Link No Longer</p> <p>Jquery removing an adding active class to li nodes not working</p> <p>I know it should be really basic to remove and add the active class to li's in order to highlight the current page's nav item, but I've been unable to get it to work.</p> <p>I find that I must use e.preventDefault() to make it work, but when I do the link doesn't work but the highlighted nav item works. If I remove the preventDefault() then it navigates but doesn't highlight. I should say that my nav is sitting in a header.php include file. Here's what I have:</p> <pre><code>&lt;ul class="myNav"&gt; &lt;li&gt;&lt;a href="index.php"&gt;Home&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="portfolio.php"&gt;Portfolio&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="about.php"&gt;About&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="contact.php"&gt;Contact&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; $('.myNav li a').click(function (e) { e.preventDefault(); $('.myNav li').siblings().removeClass('active'); $(this).parent().addClass('active'); //var url = $(this).attr("href"); //window.location = url; }); </code></pre> <p>I tried to send the page to the clicked url and this loads the correct page, but it removes the class! I'd like to solve this, but I'd also like to understand why it isn't working correctly.</p>
php javascript jquery
[2, 3, 5]
1,524,262
1,524,263
How to display something if variable is not set inside a each loop?
<pre><code>$.each(json.data,function(i,fb){ //some code here... if (msg.length &gt; 150) { msg = msg.substr(0,200)+"..."; } //more code here... }); </code></pre> <p>I have an issue here. If msg is not defined I got an error and I got nothing displayed on the browser.</p> <p>Possible Solution: create a default message for the cases where msg is not defined.</p> <p><strong>Try:</strong></p> <pre><code>if (msg = 'undefined') { msg = 'some default message'; } else if (msg.length &gt; 150) { msg = msg.substr(0,200)+"..."; } </code></pre> <p><strong>Issue:</strong> The above try didn't work because I get for each item, the same default message, instead of having the default message only for those cases were msg is no "set". </p> <p><strong>Request:</strong> Can I have your help in order to write the proper code so that, on each item, if msg is not defined show a default one, if otherwise, it's site, display it ?</p> <p>If you lack some information in order to proper help me, please, let me know. I'm really on a bad position right now. :s</p> <p>Thanks a lot, MEM</p>
javascript jquery
[3, 5]
3,601,357
3,601,358
How do I remove # sign from hash data? jquery?
<p>I need value of hash from url...</p> <pre><code>var hash = window.location.hash; </code></pre> <p>So how do I get rid of <code>#</code> sign?</p>
javascript jquery
[3, 5]
1,180
1,181
ASP.NET: Session expired after folder delete
<p>I am having code where i am moving files to another folder and deleting previous folders and files in an ASP.NET application. After deleting folder, my session is expired. How can I restrict to expire session values. </p>
c# asp.net
[0, 9]
2,134,690
2,134,691
htmlencode() for a specific tags only
<p>i have a long string dat can contain html tags applying htmlencode will encode all the tags but i want this method to leave some specific tags intact how is it possible</p>
c# asp.net
[0, 9]
4,223,727
4,223,728
foreach radio button show more info
<p>I am trying to make for each radio button, when it is clicked on to show the div with more infos about that clicked title, when another radio button is clicked then the to show info about that radio button and hide the other one that was clicked on:</p> <p>HTML:</p> <pre><code>&lt;input type="radio" id="1" /&gt; &lt;div class="event1"&gt; content.. &lt;/div&gt; &lt;input type="radio" id="2" /&gt; &lt;div class="event2"&gt; content.. &lt;/div&gt; &lt;input type="radio" id="3" /&gt; &lt;div class="event3"&gt; content.. &lt;/div&gt; </code></pre> <p>jQuery:</p> <pre><code>var i = 1; while(i &lt; 10) { $('.event' + i).hide(); $("#" + i).click(function() { $('.event' + i).show(); }); i++; } </code></pre>
javascript jquery
[3, 5]
2,866,151
2,866,152
Javascript iPhone code to download and save image in iphone memory from server
<p>What is the way to download and save image in iPhone memory from server in javascript?? Is it possible?? Thanks</p>
javascript iphone
[3, 8]
1,817,353
1,817,354
Javascript Gets the contents of the textarea of the distance from the border pixels
<p>How can I be sure the text in the input box, the number of pixels from the left box? It may have utf8, Chinese <img src="http://i.stack.imgur.com/NRreK.png" alt="enter image description here"></p>
javascript jquery
[3, 5]
1,875,662
1,875,663
why this jquery selecter gives me error?
<p>i am using this code ti dynamically select attributes of a element but it gives me an error in firebug</p> <p><strong>Error:</strong></p> <p><strong>uncaught exception: Syntax error, unrecognized expression: ''</strong> </p> <p>Here is my code:</p> <pre><code>jQuery('.mydata').click(function(){ var current_id=jQuery(this).attr('id'); var current_datatype=jQuery(this).attr('datatype'); var next_id=parseInt(current_id); next_id=next_id+1; next_id="'#"+next_id+"'"; var next_datatype=jQuery(next_id).attr('datatype'); //this line gives error }); </code></pre> <p>So please tell me a solution for it?</p>
javascript jquery
[3, 5]
2,532,134
2,532,135
Checking if an e-mail had already been added to a database
<p>I am editing an ASP form that is basically a newsletter subscription form. The issue is that I have no way of triggering an event alerting me if a user has already registered.</p> <p>I want to find a way to make the form check if that user's e-mail address exists within my database. If so, then just say, "You have already registered. Did you not receive a thank you email? Click here to receive the email again."</p> <p>As it stands, the user can register and they automatically get the Thank you form, but are not necessarily told whether they've already registered or not.</p> <p>EDIT: Sorry for not mentioning this earlier, but this database is managed using Microsoft's SQL Server. Yes, I am storing values using this method. Please let me know if I can include any more details -- I'm not very familiar with DBs.</p>
c# asp.net
[0, 9]
5,368,963
5,368,964
How to dynamically show further information with jQuery and PHP?
<p>I have list of courses from MySQL and when I click the course it should display the correct course description to the right and again when I click the next course, the previous should hide and get the current click course description, Here is the code I did</p> <p>jQuery</p> <pre><code>$(document).ready(function() { $("#toggle_value").click(function(){ $("$courseid").show("slow"); }); }); </code></pre> <p>PHP Code</p> <pre><code>$cour = get_records_sql('SELECT c.id, c.summary FROM mdl_course c'); echo '&lt;table style="background:white;border:2px solid blue"&gt;'; foreach($cour as $cou) { $coursename = $cou-&gt;fullname; $summary = $cou-&gt;summary; echo '&lt;tr style="border:1px solid #BACC82;"&gt; &lt;td&gt;&lt;div class="toggle_button"&gt;&lt;a href="javascript:void(0);" id="toggle_value"&gt;'.$coursename.'&lt;/a&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt; &lt;div id="div1" style="display:none;top:440px; border:0px solid #000;float:right;background-color:white; padding:5px;"&gt; } echo '&lt;/table&gt;'; </code></pre>
php jquery
[2, 5]
4,221,502
4,221,503
How to add a string to a text area with different colours?
<p>I am trying to work out how to write a function where I pass in a string and this string is added to a textarea. This I can do, but I want to parse that string and change the colour on different parts of the string.</p> <p>In other words, find the words "select", "where" and turn them blue. Then find the words "AND", "OR", "&lt;" and turn them grey and anything in between two single quotes to be the colour red.</p> <p>I am hoping for a simple function rather than using syntax highlighting libraries, I am not even sure they will work with strings that are dynamically generated.</p> <p>How can I do this? I am able to make use of JQuery if this makes things easier?</p> <p>Thanks all</p>
javascript jquery
[3, 5]
5,364,638
5,364,639
Problem with JQuery onClick Event
<p>Please someone let me know what the problem is here, it just wont work :(</p> <pre><code>function openLightbox(url) { alert('test'); $('#Lightbox').attr('href', url); $('#Lightbox').click(); } openLightbox('test.asp?url=12313'); </code></pre> <p>For some reason it will not work. When I change it to this ... it works!</p> <pre><code> $('#Lightbox').attr('href', 'manuallyseturl.asp'); $('#Lightbox').click(); </code></pre> <p>Has anyone got any ideas?!</p> <p>If I have an alert before the function I can see the alert, but for some reason the URL does not change. Just to give you a bit of background the onclick event triggers a lightbox which then opens.</p> <p>Odly when I have Javascript ready before any code, it says "Unexpected end of input"</p> <pre><code>$(document).ready(function(){ alert('test'); } </code></pre> <hr> <p>ANSWER:</p> <p>I figured it out, I needed to use Javascript onready in the function! For some reason if I didnt use this it would just error! How annoying!</p>
javascript jquery
[3, 5]
5,077,335
5,077,336
asp.net listview select onmouseover
<p>How to highlight a whole row of a listview when you mouse over it? For example if you hover over one row, the row's background colour changes. I asume it is the onmouseover attribute of tr?</p>
c# asp.net
[0, 9]
2,343,901
2,343,902
Message / confirm dialog
<p>I have a need for a confirm message box from a button click, but only on some conditions. I am cheking two values on the aspx.page, and if one is higher than another, I need a confirmation from the user. Are there any ( simple) way of doing this ? I have been reading about javascript and alert messages, but I cant seem to figure out this one.... I am using RadStudio 2007, .net application.</p> <p>Any help are appriciated. Anja</p>
asp.net javascript
[9, 3]
1,073,685
1,073,686
how to Disable print screen in web page using JavaScript
<p>i am developing a website, i want disable print screen so i searched in the net and i used a JavaScript to disable print screen. it worked fine but during loading of a page it asks for the permission to access the clipboard.</p> <p>the pop-up message that it shows,</p> <p>"do u want to allow this webpage to access your clipboard? If you allow this, the webpage can access the clipboard and read information that you've cut or copied recently.. "</p> <p>i want to avoid the above pop-up message and also disable print screen. Below is my JavaScript code.:</p> <pre><code> function AccessClipboardData() { try { window.clipboardData.setData('text', "Print Disabled"); } catch (err) { } &lt;body&gt; &lt;script language="JavaScript" type="text/javascript"&gt; setInterval("AccessClipboardData()", 300); var ClipBoardText = ""; if (window.clipboardData) { ClipBoardText = window.clipboardData.getData('text'); ClipBoardText = window.clipboardData.clearData('text'); if (ClipBoardText == "") { alert('Sorry you have to allow the page to access clipboard'); document.all("divmaster").style.display = "none" } } &lt;/script&gt; &lt;/body&gt; </code></pre> <p>can please help to solve that print screen and clip board problem.</p> <p>thanks in advance..</p>
javascript asp.net
[3, 9]
1,491,774
1,491,775
How to Implement Google direction in asp.net
<p>google map direction in asp.net. How can we achive</p> <p>How to Implement Google direction in asp.net</p>
c# asp.net
[0, 9]
2,019,340
2,019,341
Load external <script> without cache using Javascript
<p>I want to load an external javascript file into the page and make sure its not cached. I do not have access to php so I cant generate a random string after the filename.</p> <p>In PHP the script would look like this:</p> <pre><code>&lt;script src="http://site.com/cool.js?&lt;?php echo $randomnumber; ?&gt;"&gt;&lt;/script&gt; </code></pre> <p>Is there a way to do something like that using only javascript?</p>
javascript jquery
[3, 5]
5,185,096
5,185,097
Jquery Modal Pop Up
<p>I am using asp.net image button when we click the image button Modal popup will display. now My problem is when i click the button popup is coming but it post back to the server after that popup window is closed can u give the solution for this</p> <p>My Code is</p> <pre><code>&lt;asp:ImageButton ID="imgemail" runat="server" ImageUrl="~/images/images.jpg" /&gt; $("#imgemail").click(function() { $("#dialog").dialog("open"); }); </code></pre>
jquery asp.net
[5, 9]
313,474
313,475
Safely wiping data from Android device: Gutmann or others?
<p>I've been reading a few articles on Gutmann method of securely wiping data. I understood that the method is designed for <strong>hard disks</strong>. I want to write my tiny app that securely wipes data (there are a few on Google Play, I know) from either phone memory or SD card.</p> <p>My questions are</p> <h3>Question 1: Gutmann or others?</h3> <p>As for the above observation, is Gutmann algorithm both effective and efficient? I believe that it is indeed effective because it rewrites the data so many times that a technology like flash memory has no way to remember data 35-writes-older. I don't know if it's efficient: I mean, do I just need fewer random writes to achieve a result?</p> <h3>Question 2: do I really overwrite sectors?</h3> <p>A question that came into my mind is the following: if I <a href="http://www.java-forums.org/advanced-java/13328-file-overwrite-method.html" rel="nofollow">overwrite a file in Java</a>, does Linux kernel write new data on old sectors or does it allocate new sectors on physical media while deallocating the old ones? You know, this makes the difference...</p>
java android
[1, 4]
4,296,659
4,296,660
Change outerHTML in javascript
<p><code>$(editor[i])[0].outerHTML</code> has a value of:</p> <pre><code> &lt;p style="color: red;" data-mce-style="color: red;"&gt;some string&lt;/p&gt; </code></pre> <p>I want <code>data-mce-style="color: red;"</code> to disappear.<br> I'm doing that like this:</p> <pre><code>$(editor[i])[0].outerHTML.replace('data-mce-style="color: red;"', ''); </code></pre> <p>But it's not replacing it.</p>
javascript jquery
[3, 5]
4,687,938
4,687,939
Session variables vs local variables
<p>Whenever I have to store anything in the session, I have picked up the habit of minimizing the number of times I have to access the session by doing something like this:</p> <pre><code>private List&lt;SearchResult&gt; searchResults; private List&lt;JobSearchResult&gt; SearchResults { get { return searchResults ?? (searchResults = Session["SearchResults"] as List&lt;SearchResult&gt;); } set { searchResults = value; Session["SearchResults"] = value; } } </code></pre> <p>My reasoning being that if the object is used several times throughout a postback, the object has to be retrieved from the Session less often. However, I have absolutely no idea if this actually helps in terms of performance at all, or is in fact just a waste of time, or perhaps even a bad idea. Does anyone know how computationally expensive constantly pulling an object out of the session would be compared to the above approach? Or if there are any best practices surrounding this?</p>
c# asp.net
[0, 9]