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 |
---|---|---|---|---|---|
3,316,740 | 3,316,741 | How to set focus on textbox on linkbutton click using javascript | <p>I have this java script function </p>
<pre><code>function showHideSearchPanel(dv) {
var Header = dv == 'Charts' ? 'ChartSearch' : 'ReportSearch';
var div = "ctl00_ContentPlaceHolder1_dv" + Header;
var panel = "ctl00_ContentPlaceHolder1_pnl" + Header;
var hiddenField = "ctl00_ContentPlaceHolder1_hdn" + Header + "Mode";
// I try to add this code in js but it not work
**var serchtextbox = document.getElementById("ctl00_ContentPlaceHolder1_txtSearchName");
if (serchtextbox != null) {
serchtextbox.focus();
}**
// I try to add this code in js but it not work
if ($("#" + div).attr('display') != 'block') {
window.status = 'Expanding contents....';
$("#" + div).slideToggle("slow");
$("#" + div).attr('visibility', 'visible');
$("#" + div).attr('display', 'block');
window.status = 'Done';
}
else {
window.status = 'Collapsing contents....';
$("#" + div).hide("slow");
$("#" + div).attr('visibility', 'hidden');
$("#" + div).attr('display', 'none');
window.status = 'Done';
}
$("#" + hiddenField).attr('value', ($("#" + hiddenField).attr('value') == 'On' ? 'Off' : 'On'));
</code></pre>
<p>}</p>
<p>This is my simple menu
<img src="http://i.stack.imgur.com/9HBcE.png" alt="My Search Menu"></p>
<p>When click on search button i want set focu on search textbox which is in below image
<img src="http://i.stack.imgur.com/jS5Ix.png" alt="Click on search table show"></p>
| javascript jquery | [3, 5] |
1,562,048 | 1,562,049 | fade in div on page load | <p>I need a div to fade in when the page loads.</p>
<pre><code><div id=monster></div>
</code></pre>
<p>Im already using jquery FYI.</p>
<p>Thanks in advance.</p>
| javascript jquery | [3, 5] |
2,218,607 | 2,218,608 | How to get the simple name of the ZipEntry? | <p>I would know if is it possible to get the simple name from a <code>ZipEntry</code>...</p>
<p>When I invoke the <code>getName()</code> of the Entry, I get a full path name.</p>
<p>I need get only the file's name.</p>
<p>Here I need get the simple name instead the full name with its root.</p>
<pre><code>public class ZipFileSample {
public static void main(String[] args) {
try {
ZipFile zip = new ZipFile(new File("C:\\Users\\Levi\\Desktop\\jessica.zip"));
for (Enumeration e = zip.entries(); e.hasMoreElements(); ) {
ZipEntry entry = (ZipEntry) e.nextElement();
//Here I need to get the simple name instead the full name with its root
System.out.println(entry.getName());
}
} catch (ZipException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
</code></pre>
| java android | [1, 4] |
1,372,664 | 1,372,665 | JS cookie variable lost after post | <p><strong>main.php:</strong></p>
<pre><code> <div id="test" class="test">
<?php include("data.php");?>
</div>
</code></pre>
<p><strong>data.php:</strong>
In this php, i have a few query, and then print some list...Each list in an own DIV tag, and all DIV tag is "closed" when the page is load, except the last one that the user opened. I use cookie to save the the DIV ID to know which i have to open when the page is reload.</p>
<p><em>JS PART:</em></p>
<pre><code> var test= $.cookie('test_cook');
$('div[class*="test"]').hide();
var op = $.cookie("test_cook");
alert(op);
$('div.test' + op).show();
$('input:image').click( function() {
var nr = $(this).attr('id').substr(7,2);
$('div.test' + nr).toggle(400);
$.cookie("test", nr, {expires:1 });
</code></pre>
<p>}); </p>
<p><em>PHP PART:</em> </p>
<p>In searctest.php a print some list what the user search for, and if they want, can send to database.</p>
<pre><code> include("searchtest.php");
</code></pre>
<p>If i reload, or close the page, then cookie is works well, the last opened DIV tag stay open. But after user make a search, and POST it, then the cookie variable will empty. </p>
<p>Could you suggest me something how can i bypass this?</p>
| php javascript | [2, 3] |
795,811 | 795,812 | How to disable writing to database if i made duplicate entry, and show warning in alertbox? | <p>I am a bit new with php, so I need help. On one page i have small form with firstname and lastname fields. On submit i send it to external .php script where i want to check if there is already person with same name in database. If there is already person with entered name in database, I want to cancel writing to database, and return to the html page. I have done this, but I want to display the JS messagebox "Person with this name already exists in db!", and if the writing to base was canceled, i want my input fields show last written values. I've been reading a lot of litertaure, and I'm lost. Thanks for help anyway :)</p>
<p>This is my form:</p>
<pre><code><form name="form" action="write.php" method="post" onSubmit="return Validate()">
Firstname: <input type="text" name="firstname">
Lastname: <input type="text" name="lastname">
<input type="submit">
</form>
</code></pre>
<p>My php code:</p>
<pre><code><?php
$con=mysqli_connect("localhost","root","","phptest");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
if (isset($_POST['firstname'])) {
$firstname = $_POST['firstname'];
}
if (isset($_POST['lastname'])) {
$lastname = $_POST['lastname'];
}
$duplicate=mysqli_query($con,"SELECT * FROM persons WHERE FirstName='$firstname'");
if(mysqli_num_rows($duplicate)>0)
{
die('Name already exists' );//I want that this message shows in html file, as alert
}
else{
$sql="INSERT INTO Persons (FirstName, LastName)
VALUES('$firstname','$lastname')";
$result=mysqli_query($con,$sql);
if (!$result)
{
die('Error: ' . mysqli_error());
}
}
header( 'Location://localhost/ivanda.php' ) ;
mysqli_close($con);
?>
</code></pre>
| php javascript | [2, 3] |
4,040,631 | 4,040,632 | Upload image/Photo from Iphone to webserver(ASP.net) | <p>I am pretty new in Iphone Apps.
How do I upload Image/Photo from my Iphone to webserver. At web server I am using ASP.net c#.</p>
<p>On Iphone i have image displayed on UIImage Control and that image I am getting from database from BLOB datatype column.</p>
<p>how do I save that image bytes to application folder and then send image file to webserver.</p>
<p>Please help me with the Iphone as well as ASP.net code.</p>
<p>Many Thanks. </p>
| asp.net iphone | [9, 8] |
3,237,795 | 3,237,796 | Can't create the sum of two values (2+2 isn*t 4 but 22)? | <p>sorry if this is a noob question, but well, I'm a noob.
I want to get the sum of the values of several text field into another text field. My code looks like this:</p>
<pre><code>$('.button').mouseup(function() {
var sum = $("#field1").val()+$("#field2").val();
$("#result").val(sum);
});
</code></pre>
<p>When I click the button the sum of 3+3 isn't 6 but 33. It just adds all numbers to the textfield. If I change the "+" into a "*" it works, 3*3 is 9.
Could somebody please tell me what I do wrong. Thank you.</p>
| javascript jquery | [3, 5] |
3,726,237 | 3,726,238 | How to detect 404 error in a url then set the url image to display:none using Jquery | <p>I have a table which repeats an image link to a file download for every row of data. I want to use Jquery or Javascript to detect if a image link returns a 404 error, meaning the file its trying to find doesn’t exist, then set the image link to <strong>display:none</strong> so its hidden.</p>
<p>Any help is much appreciated!</p>
<p>Jamie.</p>
<p>---Edit---</p>
<p>This is my url which needs to be set to hidden if it cant find the .igs file</p>
<p><code><a href="/path/to/file.igs"><img src="pic.jpg" alt="My Image Link"></a></code> </p>
<p>Unfortunately I cannot utilize server-side processing.</p>
| javascript jquery | [3, 5] |
1,296,684 | 1,296,685 | Android image file sent to php upload image file is application/octet-stream type and not image/jpeg? | <p>Hello all hope someone can can help- To fininsh my android app I just need to finish the class were the user can upload there image to the server(MySql).</p>
<p>All works well except except the format of the image is application/octet-stream rather than image/jpeg that is sent from my android app?
Is there anyway I can open the file application/octet-stream and change it to a image/jpeg type??</p>
<p>php file for upload...</p>
<pre><code>$fileName = $_FILES['uploaded']['name'];
$tmpName = $_FILES['uploaded']['tmp_name'];
$fileSize = $_FILES['uploaded']['size'];
$fileType = $_FILES['uploaded']['type'];
$fp = fopen($tmpName, 'rb');
$content = fread($fp, $fileSize);
$content = addslashes($content);
</code></pre>
<p>Works ok with a form upload form no problem there. But when used from the android app with the wrong image type it saves the blob file as empty 0, $fileSize shows the true size but when $content is created it shows nothing at all</p>
<p>177 rome 2.jpg image/jpeg 6876 [BLOB - 6.7 KiB] p (This is from a web page)
215 myImage.jpg application/octet-stream 1066 [BLOB - 0 B] (From phone)</p>
<p>Thx guys</p>
| php android | [2, 4] |
4,413,729 | 4,413,730 | document.getElementById() vs $() | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/4069982/document-getelementbyid-vs-jquery">document.getElementById vs jQuery</a> </p>
</blockquote>
<p>I am learning jQuery and javascript.</p>
<ul>
<li><p>I wonder why the <code>$()</code> function of jQuery does not replace the <code>document.getElementById()</code> function of javascript.</p></li>
<li><p>Isn't it the role of <code>$()</code> ?</p></li>
<li><p>If not, what's the role of <code>$()</code> ?</p></li>
</ul>
<p>I got to this question because <code>$().outerHeight</code> doesn't work.</p>
<p>Thank you.</p>
| javascript jquery | [3, 5] |
336,183 | 336,184 | Running c# code on button click in aspx | <p>I have an aspx page with a button on it. When the user clicks on a button, i have to run some c# code in a seperate .cs file. What is the way to do this? Currently i have a way of using form.action to forward the request to another aspx page but is there a way to run c # code upon a button press?</p>
<p>Thanks</p>
| c# asp.net | [0, 9] |
270,384 | 270,385 | Invalid key length: 16 bytes | <p>I am getting Invalid key length: 16 bytes on netbeans ide <code>keybyte</code> length is 16</p>
<pre><code>SecretKey deskey = new SecretKeySpec(keybyte, "DESede/ECB/NOPADDING");
//enter code here..
Cipher c1 = Cipher.getInstance("DESede/ECB/NOPADDING");
c1.init(Cipher.ENCRYPT_MODE, deskey);
</code></pre>
<p>but the same code works on android </p>
| java android | [1, 4] |
3,927,021 | 3,927,022 | Adding class in a <link> if no pathname is detected | <p>We want to add a class on our the first-child of the link when <strong>window.location.pathname</strong> is <strong>NULL</strong></p>
<p>the html code is</p>
<pre><code> <nav>
<a href="index.php">Home</a>
<a href="company.php">Company</a>
<a href="products.php">Products</a>
<a href="technical.php">Technical</a>
<a href="services.php">Services</a>
<a href="contactus.php">Contact Us</a>
</nav>
</code></pre>
<p>and the URL is <em>www.nicadpower.com/</em> doing</p>
<pre><code>window.location.pathname.substring(1);
</code></pre>
<p>Would not result anything except a <strong>NULL</strong>.</p>
<p>After detecting a NULL we want the <strong>$('nav a')</strong> first-child to add the <strong>class="current"</strong></p>
<pre><code> <nav>
<a href="index.php" class="current">Home</a>
<a href="company.php">Company</a>
<a href="products.php">Products</a>
<a href="technical.php">Technical</a>
<a href="services.php">Services</a>
<a href="contactus.php">Contact Us</a>
</nav>
</code></pre>
| javascript jquery | [3, 5] |
4,879,692 | 4,879,693 | Does ready() execute asynchronously? | <p>This is a common idiom:</p>
<pre><code><html>
<head>
<script>
(function($) {
$(document).ready(function(){
// some jQuery/JavaScript in here
}
})(jQuery);
</script>
</head>
....
</code></pre>
<p>So we using a JavaScript immediate function which executes some jQuery. Now usually, it is advised to put JavaScript down the end of the page to allow progressive rendering. My questions are:</p>
<ol>
<li>If you are using JavaScript in the head, what difference does it make if you make the function execute immediately?</li>
<li>Will <code>${document).ready(...)</code> block excution, or does it happen asynchronously?</li>
</ol>
| javascript jquery | [3, 5] |
104,865 | 104,866 | How to Run a jQuery or JavaScript Before Page Start to Load | <p>I have a script that I want to run before the page start to load. The script checks the value of a variable and depending on the value redirect the user to a new page.</p>
<p>I can successfully check the variable and redirect if needed but the page still loads and display empty page but then quickly redirects to the other page. I don't want that empty page to be displayed on the page at all before the redirect.</p>
<p>Thank you,
Ver</p>
| javascript jquery | [3, 5] |
5,250,514 | 5,250,515 | How can you reference code written in another language in the App_Code folder in ASP.Net? | <p>Due to legacy issues I have two folders under App_Code directory. One for VB.Net and another for C#. Problem is, I have a service in the C# folder that needs to leverage a class in the VB.Net folder but they dont seem to know about each other. Any ideas are welcome :)</p>
<p>Thanks in advance!</p>
<p>Trev</p>
| c# asp.net | [0, 9] |
5,993,984 | 5,993,985 | Jquery url replace | <p>How can I modify this:</p>
<pre><code>/services/type/single_dwelling/
</code></pre>
<p>to this:</p>
<p><code>/ajax/services/single_dwelling/development</code></p>
<p>Currently I have:</p>
<blockquote>
<p>linkUrl =
$(this).attr("href").replace(/(\/(services)\/)/,
"$1ajax/");</p>
</blockquote>
<p>Which outputs:</p>
<pre><code>/services/ajax/type/single_dwelling/
</code></pre>
<p>I'm a little confused.</p>
| javascript jquery | [3, 5] |
5,058,658 | 5,058,659 | Why is my jquery .each() function not working properly? | <p>I wrote this function:</p>
<pre><code>jQuery(document).ready(function() {
jQuery('input[type=text]').each( function(i) {
thisval = jQuery(this).val();
jQuery(this).blur( function() {
if (jQuery(this).val() == '') {
jQuery(this).val(thisval);
}
}); // end blur function
jQuery(this).focus( function() {
if (jQuery(this).val() == thisval) {
jQuery(this).val('');
};
});// end focus function
}); //END each function
}); // END document ready function
</code></pre>
<p>It's designed to get the value of an input, then if the user clicks away without entering a new value, the old value returns. This works properly with one of the inputs on the page, but not the others. However, when I remove the .blur and .focus functions and just use alert(thisval); it alerts the name of each input, so something is wrong with my function, but I can't figure out what. Any help?</p>
| javascript jquery | [3, 5] |
4,589,544 | 4,589,545 | Scrollable menu in a web page | <p>I have to create a menu whihc keeps moving based on the click on Next and previous buttons. What is the best method to achieve this.
a sample will help me alot.</p>
| jquery asp.net | [5, 9] |
4,978,938 | 4,978,939 | Write conditionals from data returned of an xml parse | <p>Can someone please help me understand how I would write this.</p>
<p>If i am parsing data from an xml file like:</p>
<pre><code>function parseXml(xml) {
$(xml).find("ITEM").each(function()
{
var foo= $("bar", this).text();
$("#container").append('<div>' + (foo) + '</div>');
});
}
</code></pre>
<p>How would I write a statement like if foo = hello then return goodbye and have that output but otherwise just return foo?</p>
| javascript jquery | [3, 5] |
634,246 | 634,247 | how to retrieve file type using jquery | <p>I have two textboxes. One is a normal textbox and another 'input type="file"'</p>
<p>when I click on the button I want a label to be updated with the textbox value and it's href pointing to whatever I have attached to the file type.</p>
<p>How can this be done using jquery.</p>
<p>Googled a lot but din't find any answer</p>
| javascript jquery | [3, 5] |
4,684,446 | 4,684,447 | Replacing only part of an iframe src | <p>I need to use javascript to change part of an iframe src, is there a way to change '500' to '800' in that iframe src? I tried the following code but it did not work. If anyone could help that'd be appreciated.</p>
<pre><code> function bigPhotosets() {
$('iframe.photoset').each(function(){
$(this).attr('src').replace('500','800');
$(this).attr('width').replace('500','800');
});
}
bigPhotosets();
</code></pre>
| javascript jquery | [3, 5] |
1,984,612 | 1,984,613 | How to control placement of control in code behind | <p>Is it possible to control the placement of a generated control in asp .net 2.0 (c#)?</p>
<p>So for example in my page_load I create a new Panel() and then do Form.Controls.Add(pnl). However I'm finding it renders right at the end of the form. </p>
<p>I would like it rendering as the first element in the form.</p>
| c# asp.net | [0, 9] |
4,176,097 | 4,176,098 | How to cast a STRING to a GUID | <p>I need cast a String to a Guid.</p>
<p>I am using this code but</p>
<pre><code>string myUserIdContent = ((Label)row.FindControl("uxUserIdDisplayer")).Text;
Guid myGuidUserId = new Guid(myUserIdContent); // PROBLEM HERE
MembershipUser mySelectedUser = Membership.GetUser(myGuidUserId);
</code></pre>
<p>I receive this error</p>
<blockquote>
<p>Exception Details: System.FormatException: Unrecognized
Guid format.</p>
</blockquote>
<p>Any other ways to do it?</p>
<p>Thanks</p>
| c# asp.net | [0, 9] |
5,412,916 | 5,412,917 | Setting User language for Localization/Globalization | <p>I need to select the language based on the user choice and set it for the entire session.
Can anybody suggest where do i need to do these settings and how can i do this?</p>
| c# asp.net | [0, 9] |
3,277,749 | 3,277,750 | Can't change css when using click in jquery | <p>I have a small demo:</p>
<pre><code><div class="box_content_height">
<strong>Height: </strong>
<input type="text" name="height" id="height" value="300" />px
<input type="submit" class="submit_advance" value="submit" />
</div>
</code></pre>
<p>And javascript</p>
<pre><code>$('.submit_advance').click(function() {
var height_css = $('#height').val();
$('ul.nav-scroll').css('max-height', height_css+'px');
});
</code></pre>
<p>When I type input = 500 is result css no change 500
How to result is </p>
<pre><code>.ul.nav-scroll {
max-height: valueofinput+px
}
</code></pre>
| javascript jquery | [3, 5] |
2,448,762 | 2,448,763 | How does JavaScript deal with function objects? See example | <p>I have a function like this</p>
<pre><code>function saveProfile(data, url, successFn) {
$.ajax({
dataType: 'json',
data: data,
url: url,
type: 'post',
success: function () {
successFn();
}
});
}
</code></pre>
<p>is there any difference to passing the successFn directly like this...</p>
<pre><code>function saveProfile(data, url, successFn) {
$.ajax({
dataType: 'json',
data: data,
url: url,
type: 'post',
success: successFn
});
}
</code></pre>
| javascript jquery | [3, 5] |
4,567,906 | 4,567,907 | How to marshal nested structure? | <p>I have three C++ structures that I need to send as parameters when calling a DLL method from C#.
I simplified them as the following:</p>
<pre><code>typedef struct
{
int data1;
int data2;
} A;
typedef struct
{
int numStructA;
A *pStructA;
int moreData;
} B;
typedef struct
{
TCHAR *pStr;
B structB;
} C;
</code></pre>
<p>The following is the C++ function I need to call from C#:</p>
<pre><code>int func(C *pStructC, int numStructC);
</code></pre>
<p>In my C# code, I define the structs as the following:</p>
<pre><code>[StructLayout(LayoutKind.Sequential, Pack = 1)]
private struct A
{
public int data1;
public int data2;
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
private struct B
{
public int numStuctA;
public IntPtr structA;
public int moreData;
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
private struct C
{
[MarshalAs(UnmanagedType.LPTStr)]
public string Str;
[MarshalAs(UnmanagedType.Struct)]
public B structB;
}
[DllImport("somedll.dll")]
private static extern int func(IntPtr pStructC, int size);
</code></pre>
<p>I tried to marshal the nested structures. However, the C++ function does not receive the data correctly. So far only the data that comes before the nested structure is sent correctly to the C++ function.
How can I marshal the nested structures so the C++ method receives the correct data? Thanks in advance.</p>
| c# c++ | [0, 6] |
4,498,930 | 4,498,931 | How to edit input file properties by using an android app? | <p>i want to make an app which can add the file properties of a song file that the user inputs. Like adding the Album name of the song.. i am still a newbie in android app development...
Thank you.</p>
| java android | [1, 4] |
5,647,873 | 5,647,874 | How to receive Application ID from C2DM? | <p>I have completed my application and launched in android market.Now I want to add notification. I registered in C2DM and received a mail.But I am so confused. Please anybody tell me the procedure for receiving Registration ID from C2DM?</p>
| java php android | [1, 2, 4] |
4,908,663 | 4,908,664 | C# web application - waiting for localhost | <p>I am struggeling with my web application. When I debug it using VS2008, it keeps on saying waiting for localhost in the web browser for ages !! I have restarted it, and still the same thing. I am implementing a web application that generates random numbers whenever a button is clicked, adds them up and shows the total. </p>
<p>I would really appreciate your recommendations. </p>
<p>Thanks !!</p>
<p>CODE:</p>
<pre><code> public partial class _Default : System.Web.UI.Page
{
private int RandomNumber(int min, int max)
{
Random random = new Random();
return random.Next(min, max);
}
protected void Button1_Click1(object sender, EventArgs e)
{
int number = RandomNumber(1, 10);
int number2 = RandomNumber(1, 10);
int total = number + number2;
Label1.Text = Convert.ToString(number);
Label2.Text = Convert.ToString(number2);
TextBox1.Text = Convert.ToString(total);
try
{
while (total <= 18)
{
int number3 = RandomNumber(1, 10);
total = number + number2 + number3;
Label4.Text = Convert.ToString(number3);
TextBox1.Text = Convert.ToString(total);
}}
catch (Exception ex)
{
Console.WriteLine(ex);
}
}
}
}
</code></pre>
| c# asp.net | [0, 9] |
4,425,120 | 4,425,121 | Procedural order of jQuery functions inside JS | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/3393751/what-does-asynchronous-means-in-ajax">What does Asynchronous means in Ajax?</a><br>
<a href="http://stackoverflow.com/questions/4982983/jquery-ajax-return-value">jQuery ajax return value</a> </p>
</blockquote>
<p>Trying to do a function that contains a jQuery function (<code>getJson()</code>) as part of it, but when I run it, my javascript function returns <em>before</em> calling the <code>getJson()</code>. I want to know why the getJson is not being called in order, and how to fix it.</p>
<pre><code>function getUsers(screen_name){
user_list=[]
var id_list =[]
$.getJSON(url, function(json)
{
//do stuff here, I have breakpoint #1 here
});
return user_list //breakpoint #2 is here
}
</code></pre>
<p>When running it from the console: <code>getUsers('myUser')</code> it firsts gets to breakpoint #2 and then to breakpoint #1.</p>
| javascript jquery | [3, 5] |
4,444,072 | 4,444,073 | How to generate numbers within a starting and ending range? | <p>I have a starting range and ending range, and I need to be able to generate numbers withing this range, and increment the returned number by the start range + 1 every time, but never generate the same number twice.</p>
<p>Not sure how to do this with C#, any help would be great.</p>
| c# asp.net | [0, 9] |
5,447,056 | 5,447,057 | JavaScript / jQuery setting a content to <div> not sticking after postback | <p>This is my code:</p>
<pre><code><asp:Button ID="btnSave" runat="server" OnClick="Save" CssClass="StylizedButton" resourcekey="btnSave" />
<div id="lbltot"></div>
</code></pre>
<p>JavaScript code: </p>
<pre><code>$(document).ready(function() {
$("#<%= btnSave.ClientID %>").click(function() {
var functionReturn = true;
var focusElement = null;
var tot = $("<%= lblTotal.ClientID %>").val();
var txt1 = $("<%= txt1.ClientID %>").val();
var txt2 = $("<%= txt2.ClientID %>").val();
var txt3 = $("<%= txt3.ClientID %>").val();
var txt4 = $("<%= txt4.ClientID %>").val();
var cal = parseInt(txt1) + parseInt(txt2) + parseInt(txt3) + parseInt(txt4);
if (cal == 100)
{ return true; }
else {
$("lbltot").html("Total must be equal to 100%");
focusElement = tot;
functionReturn = false;
}
});
});
</code></pre>
<p>On the client side validation, I have to check the value of the <code>TextBox</code>, and the total should be equal to 100. If true, I should allow it to execute. If not, I need to throw an error stating the total should be 100.</p>
<p>What happens is that, after triggering the submit button, it show the text message only until the postback, and then it disappears. This part:</p>
<pre><code>else {
$("lbltot").html("Total must be equal to 100%");
focusElement = tot;
functionReturn = false;
}
</code></pre>
<p>Is there any better way to display the error that persist?</p>
| javascript jquery asp.net | [3, 5, 9] |
4,285,924 | 4,285,925 | How to set jQuery this when calling a function? | <p>Using jQuery, I set a link tag's click handler like this:</p>
<pre><code>$('#lnk').click(handleClick);
</code></pre>
<p>handleClick does something like this:</p>
<pre><code>function handleClick() {
var $this = $(this);
...
}
</code></pre>
<p>Now I have a need to directly call handleClick() outside of #lnk being clicked. Is there a way for me to set <code>this</code> when calling handleClick?</p>
| javascript jquery | [3, 5] |
2,648,205 | 2,648,206 | How to autoscroll to the end of iframe using JavaScript (or jQuery)? | <p>I have the following code:</p>
<pre><code><iframe id="preview" onLoad="scrollToBottom()"></iframe>
</code></pre>
<p>My objective - When the frame reloads, the "scrollToBottom()" function is triggered, which will take the user to the end of the iFrame (instead of the beginning of the frame, which is by default). The code I have now is:</p>
<pre><code>function scrollToBottom() {
window.scrollTo(0, document.body.scrollHeight);
}
</code></pre>
<p>I know, somehow I have to figure/pass the scrollHeight of the iframe, but I am not sure how to do that. A solution in JavaScript or jQuery is what I want. There are a few solutions I saw here, but none of them are working for me. BTW...I don't need any animation or effects...just need a simple/plain solution.</p>
<p>Any help will be appreciated. Thanks in advance.</p>
| javascript jquery | [3, 5] |
4,777,536 | 4,777,537 | creating slide down menus in a while loop with dynamic data using jquery | <p>I use php to display a table of data drawn from my mysql database. I have a while loop that loops through each row and spits out the user data. </p>
<p>I want to have a more details button that when pressed will drop down a div box displaying "more details" about the user. The problem I've run into is when I create the div to hold the more details I can't figure out how to make it unique for each user. </p>
<p>When I click the more details link it always opens the top most div only... because my id's aren't unique. To make the div's unique I could just echo a count to them and the href but I'm not sure how to pass that into jquery as parameter so that when I click the more details link next to a users name it will display the more details div specific to that user.</p>
<p>I've been toying with the below code without much luck, help appreciated. Thanks.</p>
<pre><code> <script type = "text/javascript">
$(document).ready(function(){
$('a.moreDetails').click(function() {
$("#moreDetails").toggle('fast');
});
});
</script>
while()
{
user info... more details href
<div></div> to display below once more details href has been clicked.
}
</code></pre>
| javascript jquery | [3, 5] |
2,801,164 | 2,801,165 | Hiding a description in a dynamic table | <p>I have a table that is created using PHP and when you click on the name of the item I want the description to show.</p>
<pre><code><table border="1" bordercolor="#000000">
<tr class="trintial">
<th width="50px"><input type="checkbox" readonly="readonly" checked="checked" /></th>
<th width="300px">To-Do Item</th>
<th width="100px">Priority</th>
<th width="100px">Due Date</th>
</tr>
<?php
$i=0;
while ($i < $num)
{
$entrynum=mysql_result($result,$i,'todo.entry');
$f2=mysql_result($result,$i,'todo.item');
$f3=mysql_result($result,$i,'todo.priority');
$f4=mysql_result($result,$i,'todo.duedate');
$f5=mysql_result($result,$i,'todo.description');
?>
<tr id="<?php echo "row$entrynum"; ?>" class="trintial">
<td><input type="checkbox" onchange="change(this,<?php echo "row$entrynum"; ?>)" name="<?php echo "box$entrynum"; ?>" value="checked" /></td>
<td><?php echo $f2; ?></td>
<td><?php echo $f3; ?></td>
<td><?php echo $f4; ?></td>
</tr>
<?php
$i++;
}
mysql_close($con);
?>
</table>
</code></pre>
| php javascript | [2, 3] |
4,169,010 | 4,169,011 | Check if array is empty or exists | <p>For the first page load I need to check if there is <code>image_array</code> load last image, otherwise block preview buttons; alert user to push new image button; create empty array to put there images;</p>
<p>The problem is that <code>image_array</code> in the <code>else</code> fires all time. If array exists - it just overrides it, but alert dosent work.</p>
<pre><code>if(image_array.length > 0)
$('#images').append('<img src="'+image_array[image_array.length-1]+'" class="images" id="1" />');
else{
$('#prev_image').attr('disabled', 'true');
$('#next_image').attr('disabled', 'true');
alert('Please get new image');
var image_array = [];
}
</code></pre>
<p>UPDATE
Before loading html i have something like this</p>
<pre><code><?php if(count($images) != 0): ?>
<script type="text/javascript">
<?php echo "image_array = ".json_encode($images);?>
</script>
<?php endif; ?>
</code></pre>
| javascript jquery | [3, 5] |
490,440 | 490,441 | jQuery Syntax Meaning | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/1490853/how-do-you-read-this-javascript-code-var1-var2var3">How do you read this JavaScript code? (var1 ? var2:var3)</a><br>
<a href="http://stackoverflow.com/questions/6259982/js-how-to-use-the-ternary-operator">JS How to use the ?: (ternary) operator</a> </p>
</blockquote>
<p>I was looking at a website's code and found this:</p>
<pre><code>$.body = $('body');
$.scroll = ($.browser.mozilla || $.browser.msie) ? $('html') : $.body;
</code></pre>
<p>What is the second line saying? Looks like some sort of if statement</p>
<p>Thanks</p>
| javascript jquery | [3, 5] |
5,276,321 | 5,276,322 | php in javascript | <p>The javascript works fine without the php part but it needs to redirect and keep the link information how to do this ??</p>
<pre><code><script>
if(navigator.userAgent.indexOf("Firefox") != -1)
{
window.location = "demo2.php?skin=<?php echo $_GET["skin"]; ?>";
}
</script>
</code></pre>
<p>works :</p>
<pre><code><script>
if(navigator.userAgent.indexOf("Firefox") != -1)
{
window.location = "demo2.php?skin=<?php echo $_GET['skin']; ?>";
}
</script>
</code></pre>
| php javascript | [2, 3] |
4,179,221 | 4,179,222 | Adding in javascript on click? | <p>When someone clicks my price up button, I want the price to increase by .1 in the #priceInput box. This is just not working though.. what am I doing wrong?</p>
<pre><code>$("#priceUp").click(function(){
var xyz = parseInt($("#priceInput").val());
xyz=(xyz+.1);
$("#priceInput").val(xyz);
});
</code></pre>
| javascript jquery | [3, 5] |
1,120,010 | 1,120,011 | Call php from javascript and return an array from php to Javascript function | <p>I want to write a function in javascript which will call the Getfilename.php and Get the $filesArray that is return in javascript.</p>
<p>GetFilenme.php is another file and I am trying to access this from Config.html</p>
<p>PHP :
Getfilename.php </p>
<pre><code><?php
$dir = 'uploads/';
$dir = $_REQUEST['dir'] ;
$filesArray = array();
$Counter = 0;
$files = scandir($dir);
foreach ($files as &$file)
{
if ($file!='.' && $file!='..' )
{
$filesArray[$Counter] = $file;
echo $filesArray[$Counter].'<br>';
$Counter = $Counter + 1;
}
}
return $filesArray;
?>
</code></pre>
| php javascript | [2, 3] |
2,621,583 | 2,621,584 | Problem in variable declaration | <p>On page load i am setting the value of String variable <code>DB</code> as follows:</p>
<pre><code>protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
String DB = "";
DB = Session["db"].ToString();
}
}
</code></pre>
<p>I want to use the variable <code>DB</code> (i want to pass this value to a method <code>getpet()</code>) in another method which is:</p>
<pre><code>protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e)
{
if(DropDownList2.SelectedItem.Text=="0")
{
petres d = new petres();
String petitioner=d.getpet();
}
}
</code></pre>
<p>How can i use a variable declared in one method, in another method?</p>
| c# asp.net | [0, 9] |
928,641 | 928,642 | Get all div values of similiar id in a particular div | <p>I have a div structure like below </p>
<pre><code> <div id=main">
<input type="hidden" id="people_0_1_0" value="12"/>
<input type="hidden" id="people_0_1_1" value="12"/>
</div>
</code></pre>
<p>Now how to add all hidden input values in a variable. Thanks</p>
| javascript jquery | [3, 5] |
4,650,280 | 4,650,281 | why there is no power operator in java / c ++? | <p>While there is such operator - ** in Python , i was wondering why java and c++ havent got one too.</p>
<p>It is easy to make one for classes you define in C++ with operator overloading ( and i believe such thing is possible also in java) , but when talking about primitive types such as int, double and so on , you'll have to use library function like Math.power (and usaully have to cast both to double).</p>
<p>So - why not define such operator for primitive types ?</p>
| java c++ python | [1, 6, 7] |
4,450,465 | 4,450,466 | GridView with DataTable as source not autopaging or sorting | <p>Basically I'm setting my datasource on my gridview to a datatable that I filled in manually. Is there a way to get the gridview to autopage and sort? When I try to go to another page on the gridview it gives me an exception saying that the paging event is not being caught (meaning I don't have a method for the event). I have allow paging set to true as well.</p>
| c# asp.net | [0, 9] |
5,241,638 | 5,241,639 | jQuery Remove specific span based on id | <p>I want to be able to remove only spans which has an id that stars with the key word "junk_"</p>
<p>for example if I have </p>
<pre><code><span id="junk_8345">A</span>
<span id="valid_2972">B</span>
<span id="junk_9249">C</span>
</code></pre>
<p>The output should look like</p>
<pre><code><span id="valid_2972">B</span>
</code></pre>
<p>I've tried to use</p>
<pre><code>$("span:has(junk)").remove();
</code></pre>
<p>but it does not seem to work. I'm open to use regex expression with the replace function if I can accomplish the same goal. Any help would be greatly appreciated!</p>
| javascript jquery | [3, 5] |
1,829,787 | 1,829,788 | Function c++ ,equivalent in java | <p>I have the following problem, the following program is in c + +.;</p>
<pre><code>#include <stdlib.h>
#include <stdio.h>
#include <malloc.h>
typedef enum { TR, SYS, INT, BAT } TIPOS ;
typedef enum { LIBRE , EJECUCION , LISTO , BLOQUEADO } PCBestado ;
struct PCB {
int PID;
PCBestado estado ;
TIPOS tipo ;
int mem , dir ;long hora , totalCPU , UsoContCPU, consumidoCPU, consContCPU;
struct PCB * sig , *ant ;
};
struct PCB *libres = NULL;
// something
....
...
..
/// function for list
void iniPCBpool( int n )
{
int f ;
struct PCB ** p ,
*ant = NULL ;
for( p = &libres , f = 0 ; f < n ; f++ )
{
if( ( *p = (struct PCB *)malloc( sizeof( struct PCB ) ) ) == NULL )
terror("Sin memoria");
(*p)->ant = ant;
ant = *p ;
p = &(*p)->sig ;
}
*p = NULL ;
}
</code></pre>
<p>what I need is to make this code but in java.</p>
<p>Help me, please. Thanks.</p>
| java c++ | [1, 6] |
1,427,240 | 1,427,241 | How Do I pass Values into an imagebutton click event in c#? | <p>Trying to pass some values into an imagebutton click event, something like this:</p>
<pre><code><asp:ImageButton id="imagebutton1" runat="server" AlternateText="5 Star Luxury Villas in North Cyprus" ImageUrl="/download/1/luxury_villas.jpg" OnClick="ImageButton_Click('value1', 'value2')"/>
</code></pre>
<p>then in code behind:</p>
<pre><code> protected void ImageButton_Click(object sender, ImageClickEventArgs e, string value1, string value2)
{
Response.Write(Value2);
}
</code></pre>
| c# asp.net | [0, 9] |
719,370 | 719,371 | How to convert comma separated string into numeric array in javascript | <p>I have a one-dimensional array of integer in JavaScript that I'd like to add data from comma separated string, Is there a simple way to do this?</p>
<p>e.g : <code>var strVale = "130,235,342,124 ";</code></p>
| javascript jquery | [3, 5] |
2,696,433 | 2,696,434 | JQuery - CSS Editor? Is there one? | <p>Is there a JQuery plugin that has a css editor? What I mean is something like this:</p>
<p><a href="http://www.cssportal.com/css-style-editor/">http://www.cssportal.com/css-style-editor/</a></p>
<p>Kind of like the dreamweaver style editor.</p>
<p>If there isn't something like this, Its probably not that hard to create, eh? :)</p>
<p><strong>Update:</strong></p>
<p>To be more clear, I would like to create my own css editor (or use a JQuery one) to replace the one that tinyMCE uses: <a href="http://tinymce.moxiecode.com/tryit/jquery_version.php">http://tinymce.moxiecode.com/tryit/jquery_version.php</a></p>
<p>Click on the style editor in the tinyMCE.</p>
<p>I would basically want to recreate that in JQuery, but would probably need to do some php backend stuff to save the changes and put it back into the tinyMCE editor.</p>
| javascript jquery | [3, 5] |
2,217,969 | 2,217,970 | How do I call window.openDatabase from a webView hosted in an android application? | <p>I created a native Android app that basically hosts a webView control. That webView is then used to load a page that calls window.openDatabase from JavaScript. I can successfully confirm that the API exists by verifying window.openDatabase.</p>
<p>Calling this method returns a null when called in a hosted webView control. Calling the same method in the Android Browser returns an instance of the database.</p>
<p>Does anyone know the permessions in the manifest or settings on the webView control that need to be set to access the database? Is this even possible in a native app.</p>
| javascript android | [3, 4] |
3,397,862 | 3,397,863 | Is it possible to add an OR to a selector in jQuery? | <p>I current have a jQuery delegate that does something to all of the <code>input</code> selectors that are not <code>submit input</code> selectors. How do you add an <strong>OR</strong> so that it also handles another type like <code>select</code>? </p>
<p>Current function:</p>
<pre><code>$('#test_form').delegate("input:not([id*='_submit'])", 'blur', function(event) {
// Does something
});
</code></pre>
<p>Thanks!</p>
| javascript jquery | [3, 5] |
5,725,985 | 5,725,986 | How to compile ASP.NET 2.0 applications in medium trust | <p>I am using a .Net/C# script to upload XLS files and then dump in SQL SERVER.</p>
<p>It works great on Local server but doesnt on shared hosting space. Hosting is saying </p>
<p>"It seems you are using full trust in this application and we support medium trust on shared server, due to that reason you are getting this error message. Please recompile the application in medium trust and then check it."</p>
<p>I asked them how to recompile it Medium Trust, but they ask me to search on google, where i dont find any great help.</p>
<p>Shall i change something in web.config ?</p>
| c# asp.net | [0, 9] |
804,882 | 804,883 | Write to a file at a specific location on client side | <p>I'm creating a bit array from info gathered on my form, to be able to save and append it to a specific file on client side. I am able to prompt the user for them to save it, but I don't want to give them a choice of where to save the file. Is there anyway to force the save location, so all the user does it click a button and the file is appended to.</p>
| c# asp.net | [0, 9] |
1,106,803 | 1,106,804 | Show/ hide dynamic combobox | <p>I have two comboboxes which are generated by queries from mysql.</p>
<p>When user choose value in first combobox i need to display second combobox, but if nothing is choosen second combox should not be displayed.
The code:</p>
<pre><code><?php
echo "<form method= \"post\" name=\"formcombo\" action=''>";
echo "<select name='cat' onchange=\"reload(this.form)\"><option value=''>Choose main category</option>";
while($cat2 = mysql_fetch_array($query2)) {
if($cat2['category_id']==@$category)
{
echo "<option value='$cat2[category_id]'>$cat2[category_name]</option></br>";}
else
{
echo "<option value='$cat2[category_id]'>$cat2[category_name]</option>";
}
}
echo "</select></br>";
echo "<select name='subcat'><option value=''>Choose subcategory</option>";
while($cat = mysql_fetch_array($query1)) {
echo "<option value='$cat[subcat_name]'">$cat[subcat_name]</option>";
}
echo "</select>";
echo "<input type=\"submit\" value =\"Submit\">";
echo "</form>";
?>
</code></pre>
<p>I use javascript to generate combobox values:</p>
<pre><code><script type="text/javascript">
function reload(form){
var val=form.cat.options[form.cat.options.selectedIndex].value;
self.location='main.php?cat=' + val ;
}
</script>
</code></pre>
| php javascript | [2, 3] |
3,961,028 | 3,961,029 | How can I display the status of an upload in an element? | <p>How can I display the status of an upload in an element? For example, when I upload an image or other file, I was to display <code>Sending... (STATUS)</code></p>
| javascript jquery | [3, 5] |
2,549,621 | 2,549,622 | Asp.net connection | <p>i have an asp.net website where thers an apply button and the webpage uses microsoft sql. The problem is that when the user clicks the apply button for a very long time right about 80-100 times, the webpage usually seems to lose connection and takes forever trying to load the page, and then either says a connection is close or timeout error.</p>
<p>Any ideas? Only happens if the user clicks the apply button for a very long time, but if i wait for like 2-5 mins and reopen the browser, everything works fine again</p>
| c# asp.net | [0, 9] |
3,339,119 | 3,339,120 | Passing parameters from managed to unmanaged code | <p>I have to use a method from a library that has the following signature in the header file:</p>
<pre><code>NKREMOTELIB_API int __stdcall GetEvfFrame(
const unsigned char*& buffer,
size_t& size,
NKRemoteEvfDisplayInfo& displayInfo);
</code></pre>
<p>I am calling these from c# using the following:</p>
<pre><code>[DllImport("NKRemoteLib.dll")]
public static extern int GetEvfFrame(out IntPtr buffer, out IntPtr size, out NKRemoteEvfDisplayInfo displayInfo);
private void Test() {
IntPtr size = new IntPtr();
IntPtr buffer = new IntPtr();
NKRemoteEvfDisplayInfo displayInfo;
int res = GetEvfFrame(out buffer, out size, out displayInfo);
}
</code></pre>
<p>I have displayInfo defined as a struct in c# as well.</p>
<p>My question is where there is any significance to the ampersand in the function signature in the header file? Why size_t& instead of size_t or char*& instead of char*? </p>
| c# c++ | [0, 6] |
5,013,638 | 5,013,639 | ASP.NET POST function in C# code | <p>I have some html POSTing code that I'm trying to emulate in an C# event.</p>
<pre><code><FORM method=post name=agree action=http://1.1.1.1/agree.cgi>
<INPUT value=Agree type=hidden name=hdnAgree>&nbsp;
<INPUT value=Agree type=submit name=agree>
</FORM>
</code></pre>
<p>I heard you can also use the UploadString
The code below is not working</p>
<pre><code>WebRequest webRequest = WebRequest.Create("http://1.1.1.1/agree.cgi");
webRequest.Method = "POST";
webRequest.ContentType = "application/x-www-form-urlencoded";
string parameters = "name=agree";
byte[] bytes = Encoding.UTF8.GetBytes(parameters);
webRequest.ContentLength = bytes.Length;
Stream dataStream = webRequest.GetRequestStream();
dataStream.Write(bytes, 0, bytes.Length);
dataStream.Close();
</code></pre>
| c# asp.net | [0, 9] |
872,145 | 872,146 | conversion type | <pre><code>typedef wchar_t WCHAR buf[1024] ; // code from C++ dll
</code></pre>
<p>how to define above line of code in C# ? </p>
| c# c++ | [0, 6] |
2,216,463 | 2,216,464 | Calculate gesture distance in Android | <p>I'm trying to find a way to calculate the distance traveled during a Gesture. I can get the distance between two points using MotionEvent.ACTION_DOWN and MotionEvent.ACTION_UP or MotionEvent.ACTION_MOVE. But that doesn't account for moving in say, a circle. It would calculate 0 because you moved all the way back around. I'm looking for total distance traveled, preferably in pixels so I can manipulate it further, if needed.</p>
| java android | [1, 4] |
5,122,627 | 5,122,628 | TitlePageIndicator selected line footer to header | <p>I'm using the TabPageIndicator from Jake Wharton
My question: Is there any way to transform the tab footer line in a "header line"?
I'm using the indicator below the ViewPager and it would be nice to have the "selected line" on the top of my tab title.</p>
<p>Thanks in advance</p>
| java android | [1, 4] |
114,947 | 114,948 | Retry Popup on Ok | <p>I have not stated anywhere in my code nor JavaScript that the page should refresh upon clicking the OK button. But as the user clicks the OK button, the retry popup comes up.
I am not sure what is the reasoning behind this.</p>
<p>Here is my code for the OK button:</p>
<pre><code>protected void btn_ok_click(object sender, EventArgs e)
{
tree_items.Nodes.Clear();
TableClass.MainTable = new DataTable();
SqlConnection connection1 = new SqlConnection();
connection1.ConnectionString = ConfigurationManager.ConnectionStrings["A"].ConnectionString;
SqlCommand command1 = new SqlCommand("GetStuff", connection1);
command1.CommandType = CommandType.StoredProcedure;
command1.Parameters.Add(new SqlParameter("@Id", solution_id));
command1.CommandTimeout = 600;
SqlDataAdapter adapter1 = new SqlDataAdapter(command1);
connection1.Open();
adapter1.Fill(TableClass.MainTable);
GenerateTreeView(TableClass.MainTable);
adapter1.Dispose();
command1.Dispose();
connection1.Dispose();
}
</code></pre>
<p>Here is the JavaScript for OK button:</p>
<pre><code><asp:Button ID="btn_ok" runat="server" Height="32px" OnClick="btn_ok_click"
Text="OK" Width="100px" />
</code></pre>
<p>Please help.
Here is the GenerateTreeviw code:</p>
<pre><code>private void GenerateTreeView(DataTable table)
{
DataRow[] foundRows = table.Select("ParentId = -1", "OrderIndex");
TreeNode RootParentNode = null;
int j = 1;
foreach (DataRow i in foundRows)
{
string NewParentNodeName = i.Field<string>("Name");
string NewParentNodeKey = Convert.ToString(i.Field<int>("ItemId"));
RootParentNode = new TreeNode(NewParentNodeName, NewParentNodeKey);
i["OrderIndex"] = j;
j++;
GenerateChildNodes(table, NewParentNodeKey, RootParentNode);
tree_items.Nodes.Add(RootParentNode);
}
}
</code></pre>
| c# asp.net | [0, 9] |
3,952,560 | 3,952,561 | How do you get RowCount of GridViews ObjectDataSource | <p>I need to get the ObjectDataSource RowCount i've tried this</p>
<pre><code>System.Data.DataTable dt = (System.Data.DataTable)gview.DataSource
dt.Rows.Count
</code></pre>
<p>But i get object not set to an instance of an object</p>
| c# asp.net | [0, 9] |
5,237,042 | 5,237,043 | ajax jsonp request 503 response | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/4778363/display-jquery-ajax-503-error-response">Display jQuery $.ajax 503 error response</a> </p>
</blockquote>
<p>I am making a call to an api which is a bit temoermental. Alot of the time it is responding with a 503. My problem is that when this happens it none of the functions (complete, error, success) are triggered. I am looking for a way to log this in my code. Any ideas greatly appreciated</p>
<pre><code> $.ajax ({
url : engine.getQuery(),
dataType : 'jsonp',
success : entErrorFunction,
complete : entErrorFunction,
error : entErrorFunction
});
var entErrorFunction = function(){
console.log('test2');
};
</code></pre>
| javascript jquery | [3, 5] |
2,134,016 | 2,134,017 | How to handle AsyncTask failure | <p>Is there a specific way to handle failure in an AsyncTask? As far as I can tell the only way is with the return value of task. I'd like to be able to provide more details on the failure if possible, and null isn't very verbose.</p>
<p>Ideally it would provide an onError handler, but I don't think it has one.</p>
<pre><code>class DownloadAsyncTask extends AsyncTask<String, Void, String> {
/** this would be cool if it existed */
@Override
protected void onError(Exception ex) {
...
}
@Override
protected String doInBackground(String... params) {
try {
... download ...
} catch (IOException e) {
setError(e); // maybe like this?
}
}
}
</code></pre>
| java android | [1, 4] |
3,758,757 | 3,758,758 | How to display cash value in words using jQuery? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/7257575/number-to-word-jquery">Number to Word - jquery</a> </p>
</blockquote>
<p>I want to show the total billed amount in receipt in words also. How to achieve it using jQuery?</p>
<p>Ex.</p>
<pre><code>Item Qty Unit Price Line Price
------------------------------------------------------
Pen 2 100 200
Note Book 3 30 90
------------------------------------------------------
Total 290
In Words: Rupees Two Hundred and Ninety Only
</code></pre>
| javascript jquery | [3, 5] |
2,081,299 | 2,081,300 | Python and executing php files? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/2931061/start-local-php-script-w-local-python-script">Start local PHP script w/ local Python script</a> </p>
</blockquote>
<p>How do you execute a php file and then view the output of it?</p>
<pre><code>os.system("php ./index.php")
</code></pre>
<p>Does not work only returns <code>0</code></p>
| php python | [2, 7] |
1,668,086 | 1,668,087 | About php full calendar customization | <p>I am working on a <a href="http://arshaw.com/fullcalendar/" rel="nofollow">php full calendar</a> and would like to make some customization. is it possible for me to hide the contents, but just changing the color of the specific date and its cell?</p>
| php jquery | [2, 5] |
3,494,035 | 3,494,036 | variable assignment inside 'IF' condition | <p>in php, something like this is fine:</p>
<pre><code><?php
if ( !$my_epic_variable = my_epic_function() ){
// my epic function returned false
// my epic variable is false
die( "false" );
}
echo $my_epic_variable;
?>
</code></pre>
<p>I suppose is a shorter way of doing:</p>
<pre><code>$my_epic_variable = my_epic_function();
if ( !$my_epic_variable ){
die( "false" );
}
</code></pre>
<p>Can this be done is javascript? I've tried to no success, wasnt sure if there was some kind of special syntax or something</p>
| php javascript | [2, 3] |
3,749,900 | 3,749,901 | constructing js function name dynamically | <p>I want to call a function this way </p>
<pre><code>redBall(this);
</code></pre>
<p>but I want to dynamically construct from a string. I tried something like this but it's not working.</p>
<pre><code>var color = 'red';
color+'Ball'(this);
</code></pre>
| javascript jquery | [3, 5] |
3,209,850 | 3,209,851 | calling web service using current users credentials | <p>I have a web service which is on another server than my web server and that service requires a domain user to function. we have NTLM authentication and my application is a web part. whenever the user enters information and clicks submit the web service is called and it does its job. Can someone please tell me how can I call the web service while passing the users credentials to it.I need to have the credentials of the currently logged in user so that it can authenticate against the web service.</p>
<p>Also i tried the below thing but its not working</p>
<p>I tried to use <code>CredentialCache.DefaultNetworkCredentials</code> to pass to a
web service. From reading the help this should return the current user domain, username and password.</p>
<p><code>DefaultNetworkCredentials</code> is actually returning blank values e.g</p>
<pre><code>DefaultNetworkCredentials.Domain = ""
</code></pre>
| c# asp.net | [0, 9] |
4,020,322 | 4,020,323 | Traceview shows some methods arent being called for 200ms or more | <p>Traceview shows that updatePhysics() is being called every 10ms or so and it takes about 8ms to run. The methods that I call inside updatePhysics are only running once every 5 or 6 times updatePhysics() runs, however. Is this simply a bug of Traceview, or what is going on? My game is stuttering a fair amount, so I am trying to figure out what is causing it.</p>
<p>Traceview is generally showing that a lot of my methods go several hundred milliseconds without being called once, even though there appears to be no reason they shouldnt be called. Ideas?</p>
<p>Run Method:</p>
<pre><code> while (mRun)
{
Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
Canvas c = null;
try
{
c = mSurfaceHolder.lockCanvas(null);//null
{
time2 = System.nanoTime()/100000; // Get current time
float delta = (time2 - time1)/1000f;
if (mMode == STATE_RUNNING) updatePhysics(delta);
else updateMenus();
doDraw(c);
time1 = time2;
}
} finally
{
// do this in a finally so that if an exception is thrown
// during the above, we don't leave the Surface in an
// inconsistent state
if (c != null)
{
mSurfaceHolder.unlockCanvasAndPost(c);
}
}
}
</code></pre>
<p>Update Physics:</p>
<pre><code> private void updatePhysics(float delta)
{
updateScore(delta);
updateDifficulty();
}
</code></pre>
<p>EDIT: As you can see here, updateDifficulty is often not called for several hundred ms EVEN THOUGH updatePhysics is being called regularly... It makes no sense. <a href="http://i.stack.imgur.com/BU6Fv.png" rel="nofollow">Screenshot of traceview</a></p>
| java android | [1, 4] |
5,339,557 | 5,339,558 | nmap 5.21 and Python problems | <p>What does this mean and how can I fix it?</p>
<pre><code>root@bt:~# rpm -vhU http://nmap.org/dist/nmap-5.21-1.i386.rpm
Retrieving http://nmap.org/dist/nmap-5.21-1.i386.rpm
error: Failed dependencies:
/usr/bin/python is needed by nmap-5.21-1.i386
python >= 2.4 is needed by nmap-5.21-1.i386
root@bt:~# python -V
Python 2.5.2
root@bt:~# which python
/usr/bin/python
root@bt:~#
</code></pre>
| php python | [2, 7] |
4,610,889 | 4,610,890 | Compare years and month with jQuery | <pre><code>var onemonth = 3;
var oneyear = 2005;
var twomonth = 10;
var twoyear = 2000;
</code></pre>
<p>How can i split this and compare?
In this example is:</p>
<pre><code>var firstdate = onemonth + oneyear;
var seconddate = twomonth + twoyear;
if(firstdate < seconddate){
alert('error');
}
</code></pre>
<p>How is the best method for compare two date if i have only month and year?</p>
<p>LIVE: <a href="http://jsfiddle.net/26zms/" rel="nofollow">http://jsfiddle.net/26zms/</a></p>
| javascript jquery | [3, 5] |
1,451,463 | 1,451,464 | How can I create a regular expression to exclude a particular character string? | <p>I have a drop down list that is filled with items and I don't want the first item to be selected so how do I write a regular expression that doesn't match it (excludes it, triggers an error) in asp.net.</p>
| c# asp.net | [0, 9] |
4,133,395 | 4,133,396 | How to capture onfinish event of a video | <p>What I want to do is play a video after a user logs in, and then use javascript or jQuery to reload the current page with <code>GET</code> parameter <code>video_finished = 1</code>. Then if <code>GET['video_finished']</code> is true, go back to the homepage, else play the video. </p>
<p>I know how to handle PHP code, but don't know write javascript or jQuery to capture the <code>onfinish</code> event and reload the current page with <code>GET</code> parameter <code>video_finished = 1</code>. </p>
<p>Can anyone can help me? </p>
<p>Thanks</p>
<pre><code><p><strong><font color="red"><em><u>Amway - Optimal You </u></em></font></strong></p><br/><br />
<div style="width: 100%; width:640px;">
<cms:video src="https://s3.amazonaws.com/4af7/0d82f79f-38cf-447d-9aeb-eb7db3bbf874-OY_Incentive_Program__Supers.mp4" clipAutoPlay="1"/>
<br /><p><a href="/home">Go to Optimal You home page</a></p></div>
</code></pre>
| javascript jquery | [3, 5] |
4,990,638 | 4,990,639 | How to invoke jquery method in another jquery file | <p>How to invoke a jquery method which in another jquery method?<br>
<strong>For example:</strong><br>
In a.js, I define a variable <code>var url = "ssh";</code><br>
In b.js, I want to use url in a.js, how can I use? </p>
| javascript jquery | [3, 5] |
3,628,817 | 3,628,818 | Is it useful to put AudioRecord.getState() in a loop? | <p>I'm working with some code that calls the <a href="http://developer.android.com/reference/android/media/AudioRecord.html" rel="nofollow">AudioRecord</a> constructor:</p>
<pre><code>AudioRecord listener = new AudioRecord(list of parameters);
do {} while (listener.getState() != AudioRecord.STATE_INITIALIZED);
</code></pre>
<p>This code would seem to make sense if AudioRecord goes off in another thread and takes time to initialize. I'm not sure of this is the case though, and if it isn't it would seem a lot better to have the code just check and return an exception, lest an infinite loop is started at some point when initialization does actually fail (although I could just limit the number of checks to something finite).</p>
<p>Should I leave the code as it is or replace the second line with something like the following?</p>
<pre><code>if(listener.getState() != AudioRecord.STATE_INITIALIZED) {
throw new Exception("AudioRecord failed to initialize");
}
</code></pre>
| java android | [1, 4] |
4,594,878 | 4,594,879 | dynamic name for DropDownList in a GridView | <p>I have asp.net page where I am using a gridView with custom paging and within the gridview there is a DropDownList control and per-row control-based javascript that does a form submit and must refer to a unique DropDownList name pertaining to it's row. </p>
<p>Usually if I need to manipulate controls I have been accustomed to using the "on databinding to row" type of event to "FindControl". But in this case I cannot do this because the client script will only refer to this control after it is rendered.</p>
<p>In the grid view template area where the DropDownList is placed, I tried to output something of the sort:</p>
<pre><code>... ID='<%# Eval("myID") + "_ddl" %>' ...
</code></pre>
<p>..just as an example, but the compiler/parser said "Bark, Bark, growl Bark" you can't do this because an id for the DopDownList can't be assigned like this. I also attempted to assign the CLientID of the control on row databind, but it wouldn't allow that either because that is a write only property.</p>
<p>Is there any easy way to actually take control of the ddl name? I really want to avoid changing the structure of what is going. I don't need to find the ddl name, I actually need to make every ddl in each row unique. The onclick is actually coming from another control in its row. and Unfortunately the JavaScript is inline. The issue is that the javascript is looking for the ddl with a unique name and in grid view the names for the ddl are all the same. My question is how do I force a unique name ID for the ddl in a grid view. Can this be done. It won't allow me in the methods that i have mentioned above. </p>
<p>Some background on this is that, this data used to be in a plain table with no paging. I had to move it into a gridview and do a custom paging.</p>
<p>Advice is much appreciated..Thanks!</p>
| c# asp.net | [0, 9] |
1,206,610 | 1,206,611 | Java side scrolling game on android | <p>I'm trying to make an easy side scrolling game just to learn the ropes of game programming on android. I came up with a solution of how to make it but I don't really think it is the most elegant solution. I wanted to get some different ideas on how to implement my game, as I really have no other solution right now.</p>
<p>Here is a quick explanation of how it works..</p>
<p>I basically have blocks or objects fall from the top of the screen. The blocks are defined from a pre-defined string I create using a custom 'map-editor'.</p>
<p>I create all the blocks at compile time, position them on or off the screen and simply increment their coordinates with each iteration of the gameloop. </p>
<p>It is actually done a little bit better then that, but that gives a short easy explanation on the basic idea.</p>
<p>I heard from a few people that instead of incrementing each block position, have the blocks stay there and simply change the viewable area. That makes sense, but I have no idea how to do it.</p>
<p>Can anyone share some ideas or links on how I can implement something like this? I know my current solution isn't the greatest.</p>
<p>Thanks!</p>
| java android | [1, 4] |
3,716,897 | 3,716,898 | Simple android and ASP.NET mix | <p>I write an android application that send text data to asp.net webserver. I'm using next code to sent data via Http:</p>
<pre><code>try {
URL url = new URL(serverUrl);
connection = (HttpURLConnection)url.openConnection();
connection.setDoInput(true);
connection.setDoOutput(true);
connection.setUseCaches(false);
// Enable POST method
connection.setRequestMethod("POST");
connection.setRequestProperty("Connection", "Keep-Alive");
connection.setRequestProperty("Content-Type", "text/plain; charset=utf-8");
output = new DataOutputStream(connection.getOutputStream());
String finalUri = sendedUrl.replace("gaburl", "");
output.writeChars(finalUri);
//Toast.makeText(context, finalUri, 1000).show();
output.flush();
output.close();
}
catch(Exception e) {
Toast.makeText(context, e.toString(), 5);
}
</code></pre>
<p><strong>How I can receive and display data sending by</strong> <code>output.writeChars(finalUri)</code> <strong>method in ASP.NET application ?</strong> This process should executing like descripe bellow:</p>
<p>1)We have asp.net forms that are a target of sender's android method desripe earlier;</p>
<p>2)Forms should read string data that sent to it and display it.</p>
<p>Help please </p>
| c# android asp.net | [0, 4, 9] |
5,390,110 | 5,390,111 | How to check if enterkey is pressed in a TextBox in asp.net | <p>I have a asp.net Text Box which accepts date in the format MM/DD/YYYY. After entering the date i will hit enter key.if enter key i need to execute server side code.How can we achieve this ?</p>
<p>The problem with Text box is it will fire the Text Changed event only if it looses the focus.</p>
| c# javascript jquery asp.net | [0, 3, 5, 9] |
715,182 | 715,183 | Difference between passing ActivityName.this and passing this when we need to pass context | <p>I have seen a convention in android programming, that when forexample calling another activity from some activity:</p>
<pre><code>Intent i=new Intent(Caller.this,Called.class);
startActivity(i);
</code></pre>
<p>My question is why we write <code>Caller.this</code> instead of just writing <code>this</code>?</p>
| java android | [1, 4] |
420,081 | 420,082 | Create comma separate list for JavaScript from my Query | <p>Is there a quick easy way to write the results from the query below to just a comma separate list so between the open/close <strong>javascript</strong> tags that will appear:</p>
<p>72,Client contact name, 2860 eof
72,Contact Phone, 2888 eol
72,Email address, 2865 eol and so on?</p>
<pre><code><?php
$data = array();
$results = mysql_query('select account_id, display_name, id from field');
while($result = mysql_fetch_assoc($results)) {
$data[] = $result;
}
?>
<script language="javascript">
???????
</script>
</code></pre>
| php javascript | [2, 3] |
280,047 | 280,048 | Getting Initializing inflate state in log cat | <p>it is a android widget and i am trying to add custom fonts to it</p>
<p>This is my code</p>
<pre><code>public void updateAppWidget(Context context, AppWidgetManager appWidgetManager, int appWidgetId) {
String currentTime = (String) df.format(new Date());
RemoteViews updateViews = new RemoteViews(context.getPackageName(), R.layout.widget1);
updateViews.setImageViewBitmap(R.id.widget1label, buildUpdate(currentTime, context));
appWidgetManager.updateAppWidget(appWidgetId, updateViews);
}
public Bitmap buildUpdate(String time, Context context)
{
Bitmap myBitmap = Bitmap.createBitmap(160, 84, Bitmap.Config.ARGB_4444);
Canvas myCanvas = new Canvas(myBitmap);
Paint paint = new Paint();
Typeface clock = Typeface.createFromAsset(context.getAssets(),"batmfo.ttf");
paint.setAntiAlias(true);
paint.setSubpixelText(true);
paint.setTypeface(clock);
paint.setStyle(Paint.Style.FILL);
paint.setColor(Color.WHITE);
paint.setTextSize(65);
paint.setTextAlign(Align.CENTER);
myCanvas.drawText(time, 80, 60, paint);
return myBitmap;
}
</code></pre>
<p>i this there is something wrong with buildupdate()</p>
<p>whats wrong here eclipse show no errors.</p>
| java android | [1, 4] |
3,799,266 | 3,799,267 | How to find out the TabSelection | <p>Dear All,
I have using the code for developing tabs</p>
<pre><code> $(document).ready(function() {
$('#container-1').tabs();
}
....
<div id="container-1">
<ul>
<li><a href="#fragment-1"><span>Home</span></a></li>
<li><a href="#fragment-2"><span>Contact</span></a></li>
</ul>
</div>
...
It works fine! need The Tab Click Event ,If it is Home Tab Click I have to alert();
How to achieve this!.Please help me!
</code></pre>
| javascript jquery | [3, 5] |
4,085,500 | 4,085,501 | Insert json values in to dropdown box | <pre><code> var g_Year = [
{ Year: "2011" },
{ Year: "2011" },
{ Year: "2010" },
{ Year: "2012" },
{ Year: "2011" },
{ Year: "2012" }
];
fxnDrop = function () {
$.each(g_Year , function (index, Ele) {
var iYear = g_Year [index].Year,
sHtmlYear = '<option value="' + iYear + '">' + iYear + '</option>';
$("#DropDown_Year").each(function (index, Ele) {
$("#DropDown_Year").append(sHtmlYear);
if (Ele.value != iYear) {
$("#DropDown_Year").remove(sHtmlYear);
}
});
});
}
</code></pre>
<p>Here Im having multiple years, My goal is to display particular year only one time in the dropdown box.For Eg:2011 has to display only one time in the dropdown box. Can any one help me to do this. Im getting multiple 2011 values in dropbox.</p>
| javascript jquery | [3, 5] |
2,339,019 | 2,339,020 | how to pass data from javascript to winforms user control | <p>I have a windows user control hosted in IE.</p>
<p>how can i paas input from webpage ( propably from javascript ) to win forms user control</p>
<p>can any one help me in solving this problem.</p>
<p>it is urgent.</p>
<p>Thanks.</p>
| asp.net javascript | [9, 3] |
4,487,168 | 4,487,169 | How to pass values aspx file to class.cs file | <p>We can pass a value From aspx to aspx file using session, querystring and so.on.But i want to pass a value from aspx to class.cs file .In class.cs file i want to get that value. how to get thet value. can any body help me. Thank in advance.</p>
| c# asp.net | [0, 9] |
4,061,782 | 4,061,783 | jquery resize window to fit contents | <p>I have a simple popup window that shows <code>300x300px</code> picture, I set up the size of the window to be <code>350x350px</code>, but depending on the browser I either get scroll bars or extra white space. Is there some jQuery function that would resize the browser window just to fit the content without any scroll bars or white space, no matter what browser?</p>
<p>Help me out!!</p>
| javascript jquery | [3, 5] |
4,377,392 | 4,377,393 | How can I make my anchor tag (this) | <p>I've run into a small problem, Ive got a page full of anchor tags and when 1 of them is selected an animation begins, my only problem right now is that I havent defined the anchor tag as (this) so when a series of anchors are selected each of them perform the animation, im not sur right now how I can change the a tag to this though?</p>
<p>My code so far is: </p>
<pre><code>$('a').bind('click', function(e){
$ajax = $('<div id="ajax"></div>');
$ajax.prependTo('#container');
$('html, body').animate({ scrollTop: 0 }, 'fast', function(){
$ajax.animate({ height: 300 }, 'slow', function(){
$preloader = $('<div id="preloader"></div>').hide();
$preloader.prependTo('#ajax').fadeIn('normal');
});
});
e.preventDefault();
});
</code></pre>
| javascript jquery | [3, 5] |
2,834,454 | 2,834,455 | Calling javascript __dopostback function, from C# in windows application | <p>I want to call "__dopostback" function, in my c# program, in my program I want to read a web page content. But in the main web page, the links that I want to read their content are called by __dopostback, function in javascript, for example the function that page call when I click on the button is:</p>
<pre><code>javascript:__doPostBack(ctl00$MainContent$GridView1,Page$2)
</code></pre>
<p>Now, how I can call this function from my c# program, note that my program is a windows application not an asp.net application!</p>
| c# javascript | [0, 3] |
2,522,241 | 2,522,242 | javascript and php web design | <p>I have a question about the way I should build my website. What if the user has javascript disabled, then all the client side programming will be disable. </p>
<p>Should I rely on php at first, and then just add the javascript/jquery/ajax just in case.</p>
<p>Also how could I make partial requests, so that one part of the page is posted back while the other part of the page doesnt refresh (for example, navigating through a list of products on the page through a pager , without the whole page refreshing, like a gridview). How to achieve that?</p>
<p>Sorry, if i was confusing</p>
| php javascript | [2, 3] |
5,976,558 | 5,976,559 | Automate slider with jquery? | <p>I have a slider that slides images across on the click of a button using the following function</p>
<pre><code>$(document).ready(function (){
$('#button a').click(function(){
var integer = $(this).attr('rel');
$('#myslide .cover').animate({left:-720*(parseInt(integer)-1)})
$('#button a').each(function(){
$(this).removeClass('active');
if($(this).hasClass('button'+integer)){
$(this).addClass('active')}
});
});
});
</code></pre>
<p>Is it possible to automate this using jquery? </p>
<hr>
<p>Just found this oly unsure how I would go about implementing it....</p>
<pre><code>setInterval(function() {
// Do something every 2 seconds
}, 2000);
</code></pre>
| javascript jquery | [3, 5] |
3,702,782 | 3,702,783 | PHP code on C++ | <p>I would like to know how this code would look in C++:</p>
<pre><code><?php
$read=fread(fopen('cookie.txt', 'r'), filesize('cookie.txt'));
$pattern = "/[a-f0-9]{32}/";
preg_match($pattern, $read, $matches);
echo $matches[0];
?>
</code></pre>
| php c++ | [2, 6] |
351,044 | 351,045 | Replace a substring in C# | <p>I have the following string, "Last Run: 2011-10-03 13:58:54 (7m 30s ago) [status]" and I would like to replace "7m 30s" (it is not a fixed string) with another string I have generated. How can I do that with string manipulation in C#? </p>
| c# asp.net | [0, 9] |
1,498,441 | 1,498,442 | Spherical Geometry library for Java/Python | <p>Is there a good Spherical Geometry library for Java/Python? I'm looking for something similar to this <a href="http://googlegeodevelopers.blogspot.com/2011/01/little-help-with-spherical-geometry.html" rel="nofollow">http://googlegeodevelopers.blogspot.com/2011/01/little-help-with-spherical-geometry.html</a>. I need to be able to perform distance, heading, area calculations; would be nice if I can also do intersection and union of areas. </p>
| java python | [1, 7] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.