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,565,500
3,565,501
Javascript, callback when object's attributes change?
<p>Functions in javascript are objects:</p> <pre><code>var x = function(){}; x.y = 1; console.log(x.y); //Prints 1 </code></pre> <p>Is there any way to call a function when y changes?</p> <p>My reason for doing this is that I'm trying to override jquery's "$" function so that I can benchmark performance. It works fine when the JS runs <code>$('mySelector')</code>. However, plugins that are created using <code>$.fn.myPlugin</code> will change the attributes in the object I overrided, rather than the original.</p>
javascript jquery
[3, 5]
4,473,042
4,473,043
how to edit column value before binding to gridview after retriving from database?
<p>After i retrieved a set of datatable from database, i need to edit the rows value before binding to the gridview. for example, a set of datatable is retrived from database. </p> <p>eg: [userid], [userEmail] --> 1 , [email protected]</p> <p>i would like to change "[email protected]" to "james" then bind it to gridview. Every rows of [userEmail] will be separated with the mail extension (@hotmail.com) ... how should i do..?</p>
c# asp.net
[0, 9]
351,223
351,224
Notify other activity of a preference changed
<p>I'm trying to have the main activity notified of a change in preferences in the PreferenceActivity but the onSharedPreferenceChanged is not firing when I change the preference.</p> <pre><code> SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); prefs.registerOnSharedPreferenceChangeListener(new OnSharedPreferenceChangeListener() { public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { Log.d("Dict", "PreferenceChanged: " + key); } }); </code></pre>
java android
[1, 4]
1,902,919
1,902,920
ASP.NET object tag and JavaScript
<p>i m using object tag on my .aspx page</p> <pre><code>&lt;object data="collapsibles.htm" height="400" width="300" /&gt; </code></pre> <p>in data attribute of object tag i refer the other HTML page on that HTML page one image that call the JavaScript function:</p> <pre><code>&lt;img src="" alt="ipl" style="border: none" onClick="Cal()"&gt; function Cal() { alert('hi All'); var i = $("#txtMail").val(); alert(i); } </code></pre> <p>Here 'txtMail' control is on my aspx page. I access it in my HTML page but it give it JvaScript error: 'undefined'.</p> <p>My question is: how i can access this control on my HTML page?</p>
javascript asp.net
[3, 9]
668,761
668,762
A misunderstanding of how this javascript is working
<p>I bind an event to a channel on the client side that waits for a message from the server and triggers the anonymous function in a callback, passing the message data in the <code>thing</code> parameter.</p> <pre><code>channel.bind('coordinates_sent', function(thing) { var x = thing.left; var y = thing.top; $(window).scroll(function(){ alert(x + " " + y); }); alert(x + " " + y); }); </code></pre> <p>The alert message outside of the <code>scroll</code> method works as expected. It alerts the new x and y coordinates of the data sent from the server right when the new message arrives. </p> <p>However, the alert message inside the scroll message behaves differently from how I would expect it to. If one message has been sent to the event listener, then the alert correctly displays the x and y coordinates from that message every time I scroll. However, if another message comes in, the alert displays first the original x and y coordinates from the first message, and then a separate alert displays the x and y coordinates from the most recent message.</p> <p>I'm having trouble understanding why this is happening.</p>
javascript jquery
[3, 5]
602,777
602,778
loading second option values when first value is selected with javascript
<p>Got a problem.</p> <p>I have these two javascripts:</p> <pre><code>&lt;script type="text/javascript"&gt; $(function () { function pad(n) { return n &lt; 10 ? '0' + n : n } var date = new Date(); var selectElement = $('&lt;select name="date" id="date" class="validate[required]"&gt;'), optionElement; for (var count = 0; count &lt; 90; count++) { var day = date.getUTCDay(); if (day == 1 || day == 2 || day == 3 || day == 4 || day == 5 || day == 6) { //formattedDate = pad(date.getUTCDate()) + '-' + pad(date.getUTCMonth()+1) + '-' + date.getUTCFullYear(); formattedDate = pad(date.getFullYear()) + pad(date.getMonth() + 1) + pad(date.getDate()); showDate = pad(date.getDate()) + '.' + pad(date.getMonth() + 1) + '.' + date.getFullYear(); optionElement = $('&lt;option&gt;') optionElement.attr('value', formattedDate); optionElement.text(showDate); selectElement.append(optionElement); } date.setDate(date.getDate() + 1); } $('#date').append(selectElement); }); &lt;/script&gt; &lt;script type="text/javascript"&gt; $(document).ready(function () { $("#date").change(function () { var value = $(this).children('option:selected').val(); $("#time").load("test.php", { value: value }); }); }); &lt;/script&gt; </code></pre> <p>So when I select the first value (here a date) the second javascript should return times from a query which is made in an php.</p> <p>If I tamper the script there are no values submitted from the first script to the second script.</p> <p>I need help here. Thanks.</p>
javascript jquery
[3, 5]
351,853
351,854
Why won't my javascript work?
<p>Here's my javascript code (backslashes are for escaping):</p> <pre><code>&lt;script type="text/javascript"&gt; $(function(){ //datepicker $(\'#start\').datepicker({ inline: true }); }); &lt;/script&gt; </code></pre> <p>And the relevant HTML:</p> <pre><code>&lt;input type="text" name="start" id="start" class="hasDatepicker" /&gt; </code></pre> <p>It's essentially identical to the example code that comes with jquery and jquery ui. I'm thinking it could be that everything is appended to a variable called $content and echoed out at the end instead of simply being HTML.</p> <p>I appreciate any answers to this conundrum.</p> <p>I should perhaps have been more visual about how my code is set up instead of explaining it at the end. This is generally how it looks:</p> <pre><code>$content .= '&lt;script type="text/javascript"&gt; $(function(){ //datepicker $(\'#start\').datepicker({ inline: true }); }); &lt;/script&gt;'; </code></pre> <p>My HTML is similarly added to $content:</p> <pre><code>$content .= '&lt;input type="text" name="start" id="start" class="hasDatepicker" /&gt;'; </code></pre>
javascript jquery
[3, 5]
4,076,423
4,076,424
c++ / c# pyramid scheme how to make it?
<p>I am looking for a c++ or c# code for a pyramid scheme (i level: x, second level x x...and so on). thx</p>
c# c++
[0, 6]
2,559,125
2,559,126
PHP Variables inside JQuery/Javascript
<p>I have some javascript/jquery code and need to some php into it be the syntax seems to be wrong...</p> <p>This is what I'm doing:</p> <pre><code>$.post("myphp.php?something=$phpvariablehere",{ etc.... </code></pre> <p>The result right now is that it's taking <strong><em>$phpvariablehere</em></strong> as a string and not the value of it.</p> <p>Anyone know the right syntax?</p>
php javascript jquery
[2, 3, 5]
3,073,030
3,073,031
Android Intent usage
<p>I am working developing a tab layout based RSS Feed reader app for my android. I have four different sites to get the feeds from and each feed should go into the separate tab. Now I have the app working fine but I was just wondering if there is a way to pass in the feed url while invoking the feed activity? </p> <p>I guess what I am after is to make my code more generic. When I invoke a new tab view using an intent I want to pass in the url for feed to the class being invoked in addition to the Class name and the intent. For example currently I have the following code for each RSS feed:</p> <pre><code>Intent i = new Intent(this, RSSReader.class); spec = tabHost.newTabSpec("Tab1").setIndicator("Tab1").setContent(i); tabHost.addTab(spec); </code></pre> <p>where RSSReader holds my url that would be displayed in "Tab1". Is there a way to tell RSSReader which url it is supposed to display based on the tab selected? I tried looking up the API but I couldn't find anything useful or may be I might have missed it. Any help in the matter would be appreciated!</p>
java android
[1, 4]
3,961,462
3,961,463
What is a $(function() { ... }) function and when is it called in the following example?
<p>I am using SharePoint Server 2007 Enterprise with Windows Server 2008 Enterprise. I am developing using VSTS 2008 + C# + .Net 3.5 + ASP.Net. I am learning the following code dealing with javascript, my confusion is for $(function(){...} part of code, when it will be called and what is its function? I did not see any code invokes this function.</p> <pre><code>&lt;!doctype html&gt; &lt;html lang="en"&gt; &lt;head&gt; &lt;title&gt;Test&lt;/title&gt; &lt;link type="text/css" href="tabcontrol/themes/base/ui.all.css" rel="stylesheet" /&gt; &lt;script type="text/javascript" src="tabcontrol/jquery-1.3.2.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; $(function() { $("#tabs").tabs(); }); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div class="demo"&gt; &lt;div id="tabs"&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="#tabs-1"&gt;tab1&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#tabs-2"&gt;tab2&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;div id="tabs-1"&gt; &lt;p&gt;tab1 info&lt;/p&gt; &lt;/div&gt; &lt;div id="tabs-2"&gt; &lt;p&gt;tab2 info&lt;/p&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>thanks in advance, George</p>
javascript jquery
[3, 5]
400,124
400,125
Can I refactor if - else with a switch or case statement in javascript?
<p>I have the following code:</p> <pre><code>var btns1 = { 'Submit': function (win) { submitHandler(oLink.$link, $('#main-form'), false); }, 'Submit &amp; Close': function (win) { submitHandler(oLink.$link, $('#main-form'), true); }, 'Close': function (win) { modal.closeModal() } } var btns2 = { 'Submit &amp; Close': function (win) { submitHandler(oLink.$link, $('#main-form'), true); }, 'Close': function (win) { modal.closeModal() } } if (oLink.title.substr(0, 4) == "Crea") { if (content.match(/data-RowKey="(.{3}).*/)) { oLink.title += " " + content.match(/data-RowKey="(.{3}).*/)[1] } var btns = btns1; } if (oLink.title.substr(0, 4) == "Edit") { var btns = btns1; } if (oLink.title.substr(0, 4) == "Dele") { var btns = btns2; } </code></pre> <p>Is there a way that I could refactor the code. What I was thinking was to put this into a function called "adminModalBtns", have it take oLink and content as a parameter and have it return btns. Would it be most clear to do this with if-else or a case statement?</p>
javascript jquery
[3, 5]
5,352,896
5,352,897
check if window is open and opens a new window only for once?
<p>i use the code below to open a new window when a user drops by my site using jquery document ready function.</p> <pre><code>&lt;script type="text/javascript"&gt; $(document).ready(function(){ window.open('link','title','width=460,height=500,status=no,scrollbars=yes,toolbar=0,menubar=no,resizable=yes,top=460,left=600'); return false }); &lt;/script&gt; </code></pre> <p>However , it keeps on popping out on every single page that have this code. What i want to do is only pop out this window ONCE for users that do not have this window opened. If a user have this window opened and it will no longer pop out a new one.</p> <p>So how can i do this??</p>
javascript jquery
[3, 5]
1,213,733
1,213,734
How to intercept all jquery ajax events?
<p>I have an big JavaScript application with a lot of ajax in there (third-party script). Now I need to intercept all ajax events, i.e. when a message from server comes back with transport text or message, i want this text / message to do replacements.</p> <p>problem: i tried with this, but it never reacts on any ajax event. It's from the jquery examples page and this #msg thing looks like a placeholder for <em>something</em>:</p> <pre><code>$("#msg").ajaxSuccess(function(evt, request, settings){ alert('ajax event'); $(this).append("&lt;li&gt;Successful Request!&lt;/li&gt;"); }); </code></pre>
javascript jquery
[3, 5]
4,957,760
4,957,761
ProgressBar inside SimpleAdapter
<p>I'm trying to add a ProgressBar to my row.xml view but I can't seem to make it work I keep getting</p> <pre><code>06-09 12:44:44.802: ERROR/AndroidRuntime(1012): java.lang.IllegalStateException: android.widget.ProgressBar is not a view that can be bounds by this SimpleAdapter ArrayList arr = new ArrayList(); HashMap map = new HashMap(); map.put("progress", 10); arr.add(map); String [] fieldNames = {"progress"}; int [] fieldIds = {R.id.progress}; SimpleAdapter adapter = new SimpleAdapter(this, arr, R.layout.row, fieldNames, fieldIds); list = (ListView) findViewById(R.id.list); list.setAdapter(adapter); &lt;ProgressBar android:id="@+id/progress" style="?android:attr/progressBarStyleHorizontal" android:max="100" android:progress="5" android:layout_width="fill_parent" android:layout_height="fill_parent" /&gt; </code></pre> <p>Does anyone have any idea what I'm missing?</p>
java android
[1, 4]
5,640,056
5,640,057
Android stutter on activity change
<p>I've got an android logging into my web service asynchronously, but when the task is complete, and I switch to the next activity, there is a stutter. This is annoying as there is a progress bar (in circle mode) on my activity and it pauses, restarts and then the activity is closed. This doesn't look all too good.</p> <p>Here is the code:</p> <pre><code>//Create the new intent. Intent i = new Intent(); //Set the intent to open the pin entry screen i.setClassName("com.visualdenim.passpad", "com.visualdenim.passpad.Pin"); Bundle bun = new Bundle(); //Set the data to go in the bundle bun.putString("login_info", args[0]); //Put the extras into the bundle i.putExtras(bun); //Start the credentials list activity startActivity(i); //Set the pretty animation overridePendingTransition(R.anim.slide_in, R.anim.slide_out); //Close this activity (so the user can't access the login screen once they are logged in) finish(); </code></pre> <p>I'm wondering; does all this need to excecute on the UI thread, Is there any way of speeding all that up, or can I stop the progress bar spinning to avoid it starting again?</p> <p>Thanks, I will tick the right answer!</p>
java android
[1, 4]
1,840,511
1,840,512
Converting HashMap into Array
<p>I have a HashMap which I want to convert into a array. Which the code below, I get following: [[2, 11, 10, 9], [value1, value2, value3, value4], [null, null, null, null], [null, null, null, null]] The "null" entries give me a null pointer exception. Why is it two times as big as it should be? I just want the real entries: [[2, 11, 10, 9], [value1, value2, value3, value4]]. What did I wrong?</p> <pre><code>String[][] test = getArrayFromHash(hashmap); public static String[][] getArrayFromHash(HashMap&lt;String, String&gt; hashMap){ String[][] str = null; { Object[] keys = hashMap.keySet().toArray(); Object[] values = hashMap.values().toArray(); str = new String[keys.length][values.length]; for(int i=0;i&lt;keys.length;i++) { str[0][i] = (String)keys[i]; str[1][i] = (String)values[i]; } } return str; } </code></pre> <p>Thanks!</p>
java android
[1, 4]
5,136,466
5,136,467
Remove a perticular div of specific text
<p>I have the following code in a php page</p> <pre><code>&lt;div class="vmenu"&gt; &lt;div class="first_li"&gt;&lt;span &gt;Add Shift&lt;/span&gt;&lt;/div&gt; &lt;div class="first_li"&gt;&lt;span&gt;Add Comment&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; </code></pre> <p>Now I want to remove the div contains text "Add Shift" on document ready</p>
javascript jquery
[3, 5]
4,084,590
4,084,591
Displaying tabular data in Android - TableLayout, custom Adapter or both?
<p>In the past when I have needed to display large data sets in a table, I've just looped over the data and on every iteration I'd inflate an xml layout representing a TableRow, obtain references to the child controls, set their properties from the data source and add the row to a TableLayout. When just displaying simple rows of data or items in a grid, I use an adapter. Am I doing this correctly, or is there a way to use an adapter to display tabular data with column alignment like in a TableLayout? Or, is there some way to apply the ViewHolder pattern to the way I'm manually adding rows to a TableLayout to avoid the extra calls to inflate xml and get references to child controls (findViewById)?</p>
java android
[1, 4]
3,818,969
3,818,970
add hyperlink to an image(background image)
<p>I'm a bit lost as to how to add a hyperlink to an image(background image) that is being called into the page with this HTML below:</p> <pre><code>&lt;div style="background-color: #fff; background: #fff url(/affiliate/uploads/images/subs_bg_4e1a7912cf9a79.22853644.jpg) no-repeat right top" class="bigshadow" id="wrapper"&gt;&lt;/div&gt; </code></pre> <p><strong>i need to add a hyper-link into the background image.</strong></p>
javascript jquery
[3, 5]
3,955,788
3,955,789
Building a data dictionary in web
<p>Not a dictionary for language, but data. I.e Car1[Make="Honda",Model="Accord",Colour="Red"]</p> <p>That's how I'd do it in Python, but by the look of things, it's harder to do on the web. I'm using PHP (not ASP).</p> <p>Has anyone had any experience with writing this kind of thing on web? I'm open to JS etc if needs be. I've seen a couple of hacks for PHP, but would like to know anything more suited.</p>
php javascript
[2, 3]
2,988,715
2,988,716
How to detect is application been showing?
<p>I have been developing Android application that use Activity with "download" button and Service for executing downloading in the background. And I have following task: to show message about downloading if application is currently displayed. How can I detect it? Is there standard Android OS functions for it? Thank you. </p>
java android
[1, 4]
1,353,525
1,353,526
ASP.NET Repeater - show part of data in column and full data in a tool tip
<p>In my ASP.NET project I want to show the first 20 characters (only a part of the full text) and then display the full text in a tool tip. I need to do because the description can be up to 500 characters long.</p>
c# asp.net
[0, 9]
3,894,734
3,894,735
preventDefault does not behave equal in different browsers
<p>I use jQuery preventDefault on a keydown event: <a href="http://jsbin.com/ixaqok/edit#javascript,html" rel="nofollow">http://jsbin.com/ixaqok/edit#javascript,html</a> When running the example code in Firefox and Opera the keypress event still is fired, but in Chrome, IE8 and Safari it's not.</p> <p>Why? Is preventDefault not supposed to work the same in all browsers?</p> <p>Thanks!</p>
javascript jquery
[3, 5]
3,077,613
3,077,614
Change asp:Label text from C# code behind
<p>I've been trying with this for an hour or so; just can't seem to figure out. I have an <code>asp:Button</code> on an aspx page, required to complete a couple of functions, one of which is to change the text of an <code>asp:Label</code>. This seems like it should be simple and other online posts indicate that I'm approaching the problem correctly but...</p> <p>The problem is simple but it's killing me. In an effort to debug/troubleshoot, I've stripped the code right back to very basics:</p> <pre><code>protected void Page_Load(object sender, EventArgs e) { allValidationMsg.Text = "Original text"; } protected void btnRegister_Click(object sender, EventArgs e) { allValidationMsg.Text = "Text changed"; } </code></pre> <p>When the button is clicked, nothing happens. I'm sure it's something simple that I'm missing.</p> <p>Update:</p> <pre><code>&lt;asp:Label id="allValidationMsg" runat="server" height="22px" ForeColor="Red"&gt;&lt;/asp:Label&gt; &lt;asp:Button class="navbutton" ID="btnRegister" runat="server" Text="Register User" OnClick="btnRegister_Click" /&gt; </code></pre>
c# asp.net
[0, 9]
1,707,721
1,707,722
How to remove class with this JS function
<p>This function is set up so it simply finds the -a's- within the class of menu-option-set, and says, upon click, add the class "selected" and remove the class "selected" from all others within that list.</p> <p>What I want to do is simply have it so if you click the item that already has the class of "selected" then it removes the class of "selected". I know it shouldn't be "return false;" I just have that as a placeholder because I can't figure out the proper coding.</p> <p>Thanks guys! :)</p> <pre><code>var $optionSets = $('.menu-option-set'), $optionLinks = $optionSets.find('a'); $optionLinks.click(function() { var $this = $(this); // Remove Class if already selected --&gt; this is the part that I need help with if ($this.hasClass('selected')) { return false; } var $optionSet = $this.parents('.menu-option-set'); $optionSet.find('.selected').removeClass('selected'); $this.addClass('selected'); });​ </code></pre>
javascript jquery
[3, 5]
1,542,753
1,542,754
jquery saving data in array
<p>I want to save and add on every click data to an array. I tried this </p> <pre><code>var data = []; var save = []; s=0; i=0; some called function(){ data[i++] = some result; data[i++] = some other result; } $('#someelement').click(function(){ save[s++] = data; console.log(save); // for debugging i = 0; data = ''; }); </code></pre> <p>The first save works, but after that I just empty arrays added. Any pointers ? </p>
javascript jquery
[3, 5]
2,827,212
2,827,213
GET parameter after routing with RouteTable
<p>I am using RouteTable from System.Web.Routing for routing. </p> <pre><code>RouteTable.Routes.MapPageRoute("gallery-handler", "Gallery/1234.ashx", "~/Handlers/Gallery.aspx?id=1234"); </code></pre> <p>How can i access GET parameter (id) in Page.</p>
c# asp.net
[0, 9]
480,666
480,667
How to remove link property when click on the link with javascript?
<p>I have a working code. What I want is when user click promo code link, the link property will be removed and will be non functional anymore. This is the working example <a href="http://jsfiddle.net/5DbN3/" rel="nofollow">http://jsfiddle.net/5DbN3/</a></p> <pre><code>&lt;script language="javascript"&gt; function toggle() { var ele = document.getElementById("toggleText"); var text = document.getElementById("displayText"); if(ele.style.display == "block") { ele.style.display = "none"; text.innerHTML = "Have a promo code?"; } else { ele.style.display = "block"; text.innerHTML = "Have a promo code?"; } } &lt;/script&gt; &lt;h1&gt;GET STARTED&lt;/h1&gt; &lt;form action="http://www....." method="post" accept-charset="utf-8"&gt; &lt;label for="zipcode"&gt; &lt;h2&gt;Enter your zip code:&lt;/h2&gt; &lt;/strong&gt; &lt;/label&gt; &lt;div&gt; &lt;input type="text" name="zipcode" id="zipcode" maxlength="5"/&gt; &lt;/div&gt; &lt;label for="promocode"&gt; &lt;a id="displayText" href="javascript:toggle();"&gt;Have a promo code?&lt;/a&gt; &lt;/label&gt; &lt;div id="toggleText" style="display: none"&gt; &lt;input type="text" name="promocode" id="promocode"/&gt; &lt;/div&gt; &lt;div&gt; &lt;input type="submit" name="zipsubmit" value="GO" /&gt; &lt;/div&gt; &lt;/form&gt; </code></pre>
javascript jquery
[3, 5]
1,274,423
1,274,424
How can I make a countdown timer in PHP?
<p>How can I make a countdown timer in PHP which starts at 40 seconds and counts in this format:</p> <blockquote> <p>40.59 - 40.48 - 40.47 - etc etc</p> </blockquote> <p>I also need a button that resets it.</p> <p>Is this possible in PHP? Do I need to use JavaScript?</p>
php javascript
[2, 3]
5,740,594
5,740,595
Using a string argument to represent an object
<p>If I have the following code:</p> <pre><code>TextBox txtUsername = new TextBox(); void setEnabled(string str, bool enable) { // use str to find the TextBox object // str.Enabled = enable; } </code></pre> <p>Is this kinda thing even possible?</p> <p>I want to be passing in 'Username' and then be prepending it with 'txt'.</p>
c# asp.net
[0, 9]
2,505,472
2,505,473
cms to implement survey module
<p>I haven't worked with content management systems .. As per my project requirements There are questionnaires added at back end and user takes up the survey and answers the questionnaire.. The questions added at back end needs to be versioned.. can anyone suggest a cms which suits the requirement preferably in java or php</p>
java php
[1, 2]
4,295,625
4,295,626
Pass php two dimensional array to javascript and access the values
<p>I can pass an array to javascript from php using Json_encode like this</p> <pre><code>initiate_database(json_encode($_SESSION["ONE_DIMENSION_ARRAY"]); </code></pre> <p>and access the same array easy like this</p> <pre><code>function initiate_databse(database) { var local_array = database; window.alert(local_array[0]); } </code></pre> <p>This will give me the first value of the array, However my problem is when I want to access two dimension array, I cannot access any value even the first one but when I run an alert on variable. It displays [[object Object],[object Object]]</p> <p>How do I access this values I have tried the following</p> <pre><code>window_alert(local_array[0][0]) window_alert(local_array[0]["name"]) </code></pre> <p>With no luck, Please help.</p> <p>Edit</p> <p>Two dimension array seemed a better choice of description</p> <p>I have a class which I created</p> <pre><code>class test_class { protected $name; protected $surname; } </code></pre> <p>I then put values in an array as follows</p> <pre><code>example test_class[] = array(); This is just an example to show what I do with the class. </code></pre> <p>I then transfer the array via json_encode to javascript, the problem is getting the variables of the class.</p> <p>I get undefined when I try getting the value of $name in javascript as follows</p> <pre><code>local_array[0]["name"] gives "undefined" local_array[0][0] gives "undefined" local_array[0] gives me [object Obejct] local_array gives me [[obeject Object],[],[]] </code></pre> <p>I think I have given all the info I can</p>
php javascript
[2, 3]
80,655
80,656
C# display pdf document in iframe in asp.net page
<p>how can i display pdf document in iframe in c# web page:i have a drowpdownlist linked with pdf files,what i need is when i select one item from this list ,iframe will populated with the corresponding pdf document</p>
c# asp.net
[0, 9]
5,774,851
5,774,852
get radio box value in jquery
<p>Am I under the wrong impression that jquery or JS can retrieve the values of radio buttons in a form? The reason i ask is because in my code the script i use to check for all fields in a form, does not seem to recognise the value in <code>id="contact2"</code> in the form, which is a radio group. I have posted my code at jsfiddle.net and would appreciate some feedback as to how I can correct this. Many thanks</p> <p>Fiddle: <a href="http://jsfiddle.net/xGrb9/" rel="nofollow">http://jsfiddle.net/xGrb9/</a></p>
javascript jquery
[3, 5]
2,421,659
2,421,660
Something in my initiation is causing the app to crash. I'm fresh out of ideas if anyone can help I will be greatfull
<p>The catlog says that the first for cycle completes and the crash happens at the second one. This is the <code>init</code> method for a very simple game.</p> <pre><code>private void init() { Resources res = this.getResources(); int x=R.drawable.crystal0000; for(int i=0;i&lt;=100;i++)// This for completes { Bitmap b=BitmapFactory.decodeResource(res, x+i); Log.d("crystalframes loaded", Integer.toString(i)); crystalframes[i]=Bitmap.createScaledBitmap(b, 20, 20, false); }// Nothing after this points goes trough x = R.drawable.frame0; for (int i = 0; i &lt; 10; i++) { Bitmap t = BitmapFactory.decodeResource(res, x + i); Log.d("frame", Integer.toString(i)); frames[i] = Bitmap.createScaledBitmap(t, 40, 40, false); } x = R.drawable.rframe0; for (int i = 0; i &lt; 10; i++) { Bitmap t = BitmapFactory.decodeResource(res, x + i); Log.d("frame", Integer.toString(i)); frames[i + 10] = Bitmap.createScaledBitmap(t, 40, 40, false); } // Code continues from the here but the crash is caused somewhere </code></pre> <p>in these lines</p>
java android
[1, 4]
5,195,825
5,195,826
How to stop link button refreshing the page
<p>In my code I'm using a link button called <code>updateLogButton</code> which shows/hides a div. Because I use a link button everytime its clicked focus is moved to the beginning of the page. How can I stop this default behaviour?</p> <p>Jquery snippet:</p> <pre><code>$('#updateLogText').hide(); $('#updateLogButton').click(function() { if ($('#updateLogText').is(':visible')){ //hide div if content is visible $('#updateLogText').fadeOut(); }else{ $('#updateLogText').fadeIn(); } }); </code></pre> <p>HTML code:</p> <pre><code>&lt;tr&gt; &lt;td&gt;&lt;a href="#" id="updateLogButton"&gt;Update Log&lt;/a&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td colspan="3" &gt; &lt;div id="updateLogText" style="width:100%;"&gt; &lt;?php echo $data['updates']; ?&gt; &lt;/div&gt; &lt;/td&gt; &lt;/tr&gt; </code></pre> <p><strong>EDIT:</strong> example of what i mean: <a href="http://jsfiddle.net/cF4Bb/7/" rel="nofollow">http://jsfiddle.net/cF4Bb/7/</a></p>
javascript jquery
[3, 5]
521,448
521,449
jquery class selection
<p>I am having a hard time trying to figure out how to properly select a class inside the menu. </p> <p>It worked fine until I put the menu in a ul. Can anyone tell me what is going on and how to fix it?</p> <p><a href="http://jsfiddle.net/nategines/7XrUk/" rel="nofollow">http://jsfiddle.net/nategines/7XrUk/</a> </p>
javascript jquery
[3, 5]
168,055
168,056
Use Jquery to get data value and supply it to a session variable
<p>I need help cause I am a total newb on this.</p> <p>I set up a session in my header:</p> <pre><code>session_start(); $_SESSION['catname'] = $catname; </code></pre> <p>Which I retrieve in my single pages:</p> <pre><code>$catname = $_SESSION['catname']; session_destroy(); </code></pre> <p>I have several divs, each with data type that can be used by jquery:</p> <pre><code>&lt;div class="mydiv1" data-category="cat1"&gt;&lt;/div&gt; &lt;div class="mydiv2" data-category="cat2&gt;&lt;/div&gt; </code></pre> <p>Is it possible to use jquery on click function to get "cat1" and "cat2" from data-category and use this to supply $catname for my session variable?</p> <p>Thank you!</p>
php jquery
[2, 5]
5,678,915
5,678,916
Complete CONNECTIVITY_SERVICE test
<p>My application connects to the internet onCreate, it does this in an AsyncTaks class and all works fine. I have some error checking in place to make sure there is internet available and works great if I say put my phone on Flight Mode.</p> <p>My problem is when I’m on WIFI, where I live the WWW drops out from time to time but the phone still thinks it’s connected. E.g.. the phone is still connected to the WIFI dongle but the WIFI dongle is not connected to the WWW, so when the application opens and tries to connect it gets an error and I get a force close.</p> <p>How can I do a complete internet connection check onCreate that will cover all bases???</p> <p>Cheers,</p> <p>Mike.</p>
java android
[1, 4]
1,601,911
1,601,912
How can I dynamically change text based on input field?
<p>How can I dynamically change a link based upon an input field in a form. For example, if I input <code>1.00</code> into the input field, I want to change the link to this:</p> <p><code>donate.php?amount=1.00</code></p> <p>Where the amount changes to the amount specified in the input field.</p> <p>I'm guessing its JavaScript which isn't my strongest point but any help would be awesome. :)</p> <p>Thanks</p>
php jquery
[2, 5]
1,710,395
1,710,396
Hiding radio button list items based on selection of a item in other radiobutton list using jquery
<p>In my scenario I have 2 radio button lists(asp.net server controls). If I select an item in my 1st radio button list then two items in the 2nd radio button list should not be visible.</p>
jquery asp.net
[5, 9]
739,884
739,885
focus() will not work
<p>I am at a loss here, never had a problem with this before.<br> I cannot get focus() to work at all in any browser. I'm using jquery and can't even get it to work with standard javascript. I tried adding the timeout as well but still nothing. All I get in the alert is "undefined".</p> <p>Here is the input</p> <pre><code>&lt;input type="text" name="SearchBox" id="SearchBox" class="SearchBox" /&gt; </code></pre> <p>and here is the jquery</p> <pre><code>$(document).ready(function(){ setTimeout(function(){ $("#SearchBox").focus(); }, 0); alert($("*:focus").attr("id")); }); </code></pre> <p>I've stripped the page down to just the above in case something was interfering with it but still no success. It has to be something simple I'm missing!!!!</p>
javascript jquery
[3, 5]
791,058
791,059
Add a property to already created Type at runtime C# ASP.NET
<p>I had a requirement of generating classes and its objects at runtime. Hence, looking at <a href="http://mironabramson.com/blog/post/2008/06/Create-you-own-new-Type-and-use-it-on-run-time-%28C%29.aspx" rel="nofollow">this article</a> I created the same. (using )</p> <p>I am storing all created types in a list.</p> <p>But now the other requirement is to add properties to already created Types.</p> <p>This is for the reason, if i want to use say Class A as a property Type in Class B and say Both in Class C.</p> <p>I read a lot of articles on the same but have not yet come to a solution</p> <p>Any Help will be appreciated.</p> <p>Thanks</p> <hr> <p>Actually, i am in process of developing a multitenant application like LitwareHR by Microsoft.</p> <p>This will be a system where admin can make sub sites with same escalation management functionality (like MS sharepoint)</p> <p>Everything is done except workflows!</p> <p>For data to be stored in tables, i am storing it in XML format.. </p> <p>Eg:</p> <pre><code>&lt;root tablename="UserInfo"&gt; &lt;column name=\"Name\"&gt;Miron&lt;/column&gt; &lt;column name=\"Company\"&gt;IBM&lt;/column&gt; &lt;/root&gt;" </code></pre> <p>Everything from controls on the page to events to validators to web parts gets created on runtime using XSLT. </p> <p>Here, the challenge comes when i need to use expression evaluator to apply workflows to it.</p> <p>Eg: <code>If UserInfo.Name == "Miron"</code></p> <p>Everything gets created on runtime, so have to retrieve table info as an object.</p> <p>Let me know if i am not clear!</p>
c# asp.net
[0, 9]
4,808,108
4,808,109
Simple way to obfuscate javascript code by PHP
<p>I want to give a free download to my web visitor but I will hide the download link until they click the facebook like button. After they like it then jquery will make the button active and add 'href' attribute to the tag, contains path to the file, so then user will be able to click the link and download the file. </p> <p>The problem is, user will be able to see the path easily when viewing source of the html in their browser. Is there any easy way in php (I put the javascript codes inside on PHP file) to make a the path is harder to read? </p> <p>It's fine when people will be able to deobfuscate it. I just want to make it harder to read for non advance user, so then people will consider to like the link instead of finding a way to deobfuscate the code.</p> <p>Thank you</p>
php javascript jquery
[2, 3, 5]
340,252
340,253
Android image resize
<p>I have images stored on sd card(size of each ~ 4MB). </p> <p>I want to resize each, than set it to ImageView. </p> <p>But I cannot do it using <code>BitmapFactory.decodeFile(path)</code> becouse Exception<br> <code>java.lang.OutOfMemoryError</code> is appeared. </p> <p>How can i resize image without loading it in the memory. Is it real?</p>
java android
[1, 4]
4,442,441
4,442,442
Multiple JavaScript Issue
<p>I include the following in my header</p> <pre><code>&lt;!-- scripts --&gt; &lt;script type="text/javascript" src="http://code.jquery.com/jquery-latest.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="./js/script.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="./js/jquery.infinitecarousel.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="./js/news.ticker.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="./js/jquery.autogrowtextarea.js"&gt;&lt;/script&gt; </code></pre> <p>but the autogrowtextarea dont work if the script.js,jquery.infinitecarousel.js and news.ticker.js are included, but if i remove those three lines my autogrow textbox function work, why can this be. thanks</p>
javascript jquery
[3, 5]
5,461,511
5,461,512
Android dialog crashes, when I try to change its image
<p>I've made my custom android dialogue, but when I try to dynamically change an imageview inside it, the application crashes.</p> <pre><code> Dialog dialog = new Dialog(this,R.style.myBackgroundStyle); dialog.setContentView(R.layout.dialog); dialog.show(); ImageView ivDialogLetter = (ImageView) findViewById(R.id.ivDialogLetter); ivDialogLetter.setImageDrawable(drwLetter); // &lt;- this line kills is. </code></pre> <p>Any ideas what might be the problem?</p> <p>Thanks!</p>
java android
[1, 4]
4,625,538
4,625,539
HttpURLConnection error: java.net.SocketTimeoutException: Connection timed out
<p>I am using simple urlconnection like this: </p> <pre><code> url = URL+"getClient&amp;uid="+cl_id; URL url = new URL(this.url); Log.d("Set++","get_t URL: "+ url); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); </code></pre> <p>its working fine, but sometimes i get this error:</p> <pre><code> error: java.net.SocketTimeoutException: Connection timed out </code></pre> <p>what could be the reason? I have only 4 clients... so i dont think that the server is overloaded with connections.</p> <p>the code: </p> <pre><code> try { URL = Settings.BASE_URL + "_interface.php?" + "key=" + Settings.KEY +"&amp;app_naam="+Settings.APP_NAAM+ "&amp;action=check&amp;setTime="+c; URL url = new URL(URL); if(D)Log.e("ChekTreadAanvr+url", URL); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); BufferedReader rd = new BufferedReader( new InputStreamReader(conn.getInputStream())); String response; if ((response = rd.readLine()) != null) { rd.close(); } if(D) Log.d("WebSaveThread+","DATARESIEVED: "+response); return response; } catch (MalformedURLException e) { if(D)Log.d("ERR","server chekc failure ++ "); return success = false; } catch (IOException ioex) { if(D)Log.e("ERR", "error: " + ioex.getMessage(), ioex); success = false; } return Boolean.toString(success); </code></pre>
java android
[1, 4]
549,038
549,039
C# - List all .aspx pages in a domain
<p>I'm trying to write a console app that lists all of the aspx pages in a domain, there's about 50 or 60 pages and I'm all out of ideas on how to list them.</p> <p>The pages are not hosted locally and I have no access to them apart from the login page, all I was given was the list of sites to output and so far, I've tried using the following approaches to no avail:</p> <p><a href="http://stackoverflow.com/questions/13415519/how-to-get-all-the-aspx-page-list-of-a-given-web-address">How to get all the aspx page list of a given web address</a></p> <p>Examples section here: <a href="http://msdn.microsoft.com/en-us/library/system.web.sitemapnode.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/system.web.sitemapnode.aspx</a></p> <p>I was thinking of using the HTTP classes in System.Web but this is the first time I've worked with .aspx and have very little knowledge of them. </p>
c# asp.net
[0, 9]
5,026,661
5,026,662
How to Overwrite first some bytes of a file with different bytes in android
<p>I have a problem that I want to overwrite first 2^21 bytes of a video file with another 2^21 bytes, but I don't know how to do that? Please suggest me the right solution for the same.</p> <p>Thanks in advance.</p>
java android
[1, 4]
2,583,421
2,583,422
Preventing the SearchView from collapsing
<p>I have a <code>SearchView</code> in my action-bar. When the user searches, I invoke my <code>AsyncTask</code> to begin fetching the data but after the data is retuned, the <code>SearchView</code>collapses.</p> <p>Here's my code that creates the search widget:</p> <pre><code>public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.search, menu); SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); SearchView searchView = (SearchView) menu.findItem(R.id.search).getActionView(); searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); if (this.objAdapter == null) { searchView.setIconified(false); searchView.requestFocusFromTouch(); } return true; } </code></pre> <p>I'd to prevent the user from collapsing the <code>SearchView</code>. I'd the search string to be visible at all times.</p> <p>How can I do this?</p>
java android
[1, 4]
4,572,373
4,572,374
how to prevent user from typing any non-numbers in the input field in real time using jquery?
<p>yes, as my question says..how to prevent the user from typing non-numeric characters in the input field? ..like e.g when they attempt to type alphabets or special characters, the cursor won't move at all inside the input field ?</p> <pre><code>&lt;input id="1stfield" name="1stfield" value="" readonly/&gt; </code></pre>
javascript jquery
[3, 5]
1,050,642
1,050,643
Javascript: clearTimeout seems to only suspend, not reset or clear?
<p>I am very new to JS and am trying to modify the JavascriptKit jQuery-based megamenu system to delay showing the menu until the mouse has been hovering over the anchor object for a specified time.</p> <p>The problem I am facing right now is that it seems that the clearTimeout that is called on mouseout only suspends the setTimeout, rather than canceling, clearing, resetting it. </p> <p>At this point I am just showing an alert after a setTimeout call. Currently I have the timeout interval set to 2000 for testing.</p> <p>As an example, since I have it set to 2 seconds delay right now, if I mouse over the object 4 times for 1/2 second, the 5th time I mouse over the object my test alert box appears instantly.</p> <p>I thought clearTimeout was supposed to completely destroy the timed event. Why does it appear to only pause the countdown?</p> <pre><code>teststuff:function(){ if(jkmegamenu.toggletest==1) { jkmegamenu.executetimedcommand() jkmegamenu.toggletest=0 } else { //jkmegamenu.executetimedcommandcancel() clearTimeout(jkmegamenu.teststuff); } }, executetimedcommand:function(){ if(jkmegamenu.toggletest==1) { alert('abcde') } }, canceltimedcommand:function(){ clearTimeout(jkmegamenu.teststuff); }, </code></pre>
javascript jquery
[3, 5]
5,778,350
5,778,351
A page should be opened only in a window
<p>I have a small application in PHP in which when a button (<code>type='button'</code> and not <code>type='submit'</code>) is clicked, a new window is opened and a page is loaded into that window. Some insertion operations into the database are performed on that page on the window using Ajax.</p> <p>The page which is loaded into the window should only be opened in a window. If the URL of that page is entered directly into the address bar of the web browser, the page must be protected and redirected to some other page, it may be a home page of the application. I tried using <code>window.opener.closed</code> but it doesn't suit this requirement.</p> <p>In PHP, I can check </p> <pre><code>if($_SERVER['REQUEST_METHOD'] == "GET") { header("location:Home.php"); } </code></pre> <p>But that will also redirect the page in the window to the Home.php page because I'm using Ajax on the <code>GET</code> request on that page.</p> <p>Is there a way to determine if a page can only be loaded into a window? In all cases, it must be prevented from being loaded.</p> <p>Thanks.</p>
php javascript
[2, 3]
5,446,733
5,446,734
a little complex Linq2SQl insert operation (Dynamic user control and page insertion)
<p>i am really trying to do this but i am failing to find a way.</p> <p>here is the scenario, i got a blog module i made for my clients, because it is a repeatative task, so i all i have to do is to just upload it to new client and he can start blogging, but some clients need extra custom fields, let us say he wants to add a phone number for each article author, or extra reference, but i don't want to implement it for each client because it is a custom requirement.</p> <p>now to do that i thought of creating a dynamic user control with this extra filed and this code in the user control for example</p> <pre><code>Blog bl = new Blog(); bl.ExtraRefrence = " http://www.something.com"; </code></pre> <p>load it into the blog management panel, but what i want to do is to have the ability to let user control use the data context in the main blog editing page, what i mean is that the main page will have the insert command, so how i let main page insert command see the dynamic user control value without creating 2 Blog objects one in page and one in user control.</p> <p>sorry if i am not clear, but seriously this killing me.</p>
c# asp.net
[0, 9]
1,407,673
1,407,674
JQuery Sync Selected Radio Button between 2 radio button groups
<p>I know it can be done with input boxes using keyup paste on JQuery but what about Radio buttons?</p> <p>Example:</p> <p>User Selects option from Area A (radio button) and it selects(syncs) area B</p> <pre><code>&lt;!--AREA A (Source) --&gt; &lt;input id="radio_A" name="radio_A" type="radio" value="Value1" /&gt; &lt;input id="radio_A2" name="radio_A" type="radio" value="Value2" /&gt; &lt;!--AREA B (Target)--&gt; &lt;input id="radio_B" name="radio_B" type="radio" value="Value1" /&gt; &lt;input id="radio_B2" name="radio_B" type="radio" value="Value2" /&gt; </code></pre>
javascript jquery
[3, 5]
1,454
1,455
How queries are sent back in an HttpRequest
<p>I'm going to try to use the <a href="http://msdn.microsoft.com/en-us/library/system.net.webclient%28VS.80%29.aspx" rel="nofollow">WebClient</a> object in .NET to grab the response querystring values sent back by the resource.</p> <p>I'm familiar with grabbing xml, json, etc. but typically I haven't worked with many NVP type of APIs in terms of grabbing the query immediately from an response sent back from a resource server-side. So <em>how is a query sent back, in the body of a response, header, what</em>? How do you grab it, with the stream object just like you do anything else?</p> <p>This questions relates to the environment I work in C# but really it relates to the web as a whole as well which is why I tagged this in multiple categories as a Request/Response is not MS specific however I am also at the same time trying to utilize the .NET WebClient object.</p>
c# asp.net
[0, 9]
5,547,319
5,547,320
Why do spaces appear in my string?
<p>I have this function below which returns all IDs of checked boxes on my page seperated by a comma. It works great but the problem is, it seems to put a lot of white space after each checkbox ID. I can't seem to figure out why?</p> <pre><code>/*Returns selected checkbox ID in string seperated by comma */ function get_selected_chkbox(){ var checked_string = ''; $('#report_table').find("input[type='checkbox']").each(function(){ if(this.checked){ checked_string = checked_string + this.id + ','; } }); alert(checked_string);//test1 ,test2 , return checked_string; } </code></pre> <p>Thanks all for any help</p>
javascript jquery
[3, 5]
296,624
296,625
how to display 3 items at each slide when pulling the data from db and not via static html?
<p>I was looking at the docs of this slider document</p> <pre><code>http://www.slidesjs.com/#docs </code></pre> <p>and i can't seem to find how to display 3 items at a slide e.g if I have a $data object and did a php foreach loop like e.g</p> <pre><code>foreach($data as $item){ //echo out ul li to display image of the data } </code></pre> <p>but if i do that, it only displays the 1 item at a slide..in a static html version.. there are 3 batch of <code>ul li</code> that displays 3 images at each slide e.g</p> <pre><code>&lt;ul&gt; &lt;li&gt;&lt;/li&gt; &lt;/ul&gt; &lt;ul&gt; &lt;li&gt;&lt;/li&gt; &lt;/ul&gt; &lt;ul&gt; &lt;li&gt;&lt;/li&gt; &lt;/ul&gt; </code></pre> <p>if am gonna include 3 batch of ul and li inside the foreach loop, it'll just produce redundant data </p>
php javascript jquery
[2, 3, 5]
582,991
582,992
Face recognition library in android
<p>I there any Face recognition sdk/library available that one can use in to android ?</p> <p>whenever i search on google i just came across Recognizr , so does anyone has any idea about sdk or something like that which helps the developer in developing face recognition application </p>
java android
[1, 4]
2,937,857
2,937,858
Real time web site using PHP or ASP.NET
<p>I'm looking for a way to put real time features into my web site.</p> <p>The idea is asynchronous communication between 2 people - like a chat session. If I use the chat example - I'd like the second person to know that the first one has sent a message to him, without refreshing or doing something active on the web page.</p> <p>Polling is not a good idea here - so is there any other solution? the back-end could be ASP.NET or PHP (ASP.NET preferred).</p> <p>Help would be much appreciated,</p> <p>Thanks,</p> <p>Roman</p>
php asp.net
[2, 9]
748,792
748,793
.each loop are not executed completely ... why ? ( code and log available )
<p>var idd;</p> <pre><code>$.each(data, function (i, items) { //1st each $.each(items, function (j, item) { // 2nd each console.log("Field:" + j + " Value:" + item); if (j=="sha_id"){ idd=item; } }); console.log("Items"); console.log("ID:" + idd); db.transaction(function (tx) { console.log("being inserted"); console.log("ID Inserting:" + idd); //then some database insertion query </code></pre> <p>This is sample upper part script </p> <p>Basically 1st .each will run 2 round and 2nd .each will run two round for each 1st .each</p> <p>So in console log I expect to see <br /> field .... value <br /> field ..... value <br /> Items <br /> ID : 2 <br /> being inserted <br /> ID Inserting : 2 <br /> field .... value <br /> field ..... value <br /> Items <br /> ID : 3 <br /> being inserted <br /> ID Inserting : 3<br /><br /></p> <p>But what i am getting is this </p> <p>field .... value <br /> field ..... value <br /> Items <br /> ID : 2 <br /> field .... value <br /> field ..... value <br /> Items <br /> ID : 3 <br /> being inserted <br /> ID Inserting : 3<br /> being inserted <br /> ID Inserting : 3<br /></p> <p>Why my db.transaction is not executed just after console.log("Items") at first as they are in the same loop. Is there any code error i should correct ?</p>
javascript jquery
[3, 5]
5,865,212
5,865,213
menu items doesn't work on click
<p>I want to add menu in my application,but it does not working. Menu's items display correctly but when i select one of them, then nothing happened. Also i want to show an alert dialog on item2. plz help me. I am new to android.</p> <p>thanks in advance</p> <p>i have tried this</p> <pre><code>public boolean onCreateOptionsMenu(Menu menu) { // TODO Auto-generated method stub MenuInflater in=getMenuInflater(); in.inflate(R.menu.activity_main, menu); return super.onCreateOptionsMenu(menu); } @Override public boolean onOptionsItemSelected(MenuItem item) { // TODO Auto-generated method stub Toast.makeText(getApplicationContext(), "ok", Toast.LENGTH_SHORT).show(); switch (item.getItemId()) { case R.id.item1: this.finish(); break; case R.id.item2: AlertDialog.Builder bb=new AlertDialog.Builder(this); bb.setMessage("Are you sure to exit?").setCancelable(false); bb.setPositiveButton("yes", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub } }); bb.setNegativeButton("No", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub } }); AlertDialog alrt=bb.create(); //alrt.setTitle("Are you sure to exit?"); alrt.show(); break; } return super.onOptionsItemSelected(item); } </code></pre>
java android
[1, 4]
4,067,669
4,067,670
can you tell how to bring the image in image view
<p>I am using camera in my application.Once i click the button to capture an image i need to get the same image in the image view which is placed right side of the preview immediately.Please tell me the code</p>
java android
[1, 4]
1,136,112
1,136,113
jQuery: clone input field without losing keyCode functionality
<p>Been trying to build jQuery support into a text input where pressing return duplicates the div container into the space right below it. What I can't figure out is how to focus on the input field inside the newly-created div automatically, and, even more frustrating, why that new input field loses the functionality to duplicate. In other words, pressing return only duplicates if you are in the originally-created input field.</p> <pre><code>$(document).ready(function(){ textboxes = $("input.data-entry"); if ($.browser.mozilla) { $(textboxes).keypress (checkForAction); } else { $(textboxes).keydown (checkForAction); } }); function checkForAction (event) { if (event.keyCode == 13) { $(this).clone().val('').appendTo('#form_container'); return false; } } </code></pre> <p>HTML</p> <pre><code>&lt;div id="form_container"&gt; &lt;input name="firstrow" type="text" class="data-entry"&gt; &lt;/div&gt; </code></pre>
javascript jquery
[3, 5]
3,497,259
3,497,260
Word wrap in multiline textbox after 35 characters
<pre><code>&lt;asp:TextBox CssClass="txt" ID="TextBox1" runat="server" onkeyup="CountChars(this);" Rows="20" Columns="35" TextMode="MultiLine" Wrap="true"&gt; &lt;/asp:TextBox&gt; </code></pre> <p>I need to implement word-wrapping in a multi-line textbox. I cannot allow users to write more then 35 chars a line. I am using the following code, which breaks at precisely the specified character on every line, cutting words in half. Can we fix this so that if there's not enough space left for a word on the current line, we move the whole word to the next line?</p> <pre><code>function CountChars(ID) { var IntermediateText = ''; var FinalText = ''; var SubText = ''; var text = document.getElementById(ID.id).value; var lines = text.split("\n"); for (var i = 0; i &lt; lines.length; i++) { IntermediateText = lines[i]; if (IntermediateText.length &lt;= 50) { if (lines.length - 1 == i) FinalText += IntermediateText; else FinalText += IntermediateText + "\n"; } else { while (IntermediateText.length &gt; 50) { SubText = IntermediateText.substring(0, 50); FinalText += SubText + "\n"; IntermediateText = IntermediateText.replace(SubText, ''); } if (IntermediateText != '') { if (lines.length - 1 == i) FinalText += IntermediateText; else FinalText += IntermediateText + "\n"; } } } document.getElementById(ID.id).value = FinalText; $('#' + ID.id).scrollTop($('#' + ID.id)[0].scrollHeight); } </code></pre> <h2>Edit - 1</h2> <p><strong>I have to show total max 35 characters in line without specific word break and need to keep margin of two characters from the right. Again, the restriction should be for 35 characters but need space for total 37 (Just for the Visibility issue.)</strong></p>
javascript jquery asp.net
[3, 5, 9]
477,441
477,442
How to constructing Javascript Array with predefined format
<p><strong>From AJAX Call i am constructing this data in my server</strong> </p> <pre><code>{data:[{one:"1",two:"2"},{one:"3",two:"3"}]} </code></pre> <p><strong>I am able to access this data using data.jobs[2].one;</strong></p> <p>My question is that , is it possible to construct a similar array inside javascript also I mean this way :</p> <pre><code>var data = [{one:1,two:2},{one:3,two:3}]; </code></pre> <p><strong>Please help , thank you very much</strong> </p>
javascript jquery
[3, 5]
1,262,858
1,262,859
How to insert text at the current caret position in a textarea
<p>On a function call from an image, I am trying to insert the alt tag value from the image into the textarea at the position where the caret currently is.</p> <p>This is the code that I currently have which inserts the alt tag value to the end of the text area.</p> <pre><code> $("#emoticons").children().children().click(function () { var ch = $(this).attr("alt"); $("#txtPost").append(ch); }); </code></pre> <p>The 2 things I have been having a problem with is determining the position of the caret, and creating a new string with the value of the textarea before the carets positon + the code I'm inserting + the value of the textarea after the carets position.</p>
javascript jquery
[3, 5]
3,321,938
3,321,939
jQuery animation - making an image visible from left to right
<p>I am trying to make an image hidden hidden using jQurey. I am using .hide() function. I am applying it to div containing the image which has to be hidden. Its not working for some reason. I have created a fiddle. </p> <p>Is it possible to to an animate so that the image becomes visible from right to left in say 1 sec.In other words animate the width from 0 to maximum value but the image should become visible from left to right. </p> <p><a href="http://jsfiddle.net/bobbyfrancisjoseph/rAqcP/15/" rel="nofollow">http://jsfiddle.net/bobbyfrancisjoseph/rAqcP/15/</a></p>
javascript jquery
[3, 5]
268,062
268,063
How to get last folder name from folder path in javascript?
<p>In javascript/jquery, given a path to a folder like:</p> <pre><code>"http://www.blah/foo/bar/" </code></pre> <p>or</p> <pre><code>"http://www.blah/foo/bar" (this one doesn't have a slash in the end) </code></pre> <p>How can you extract the name of the last folder? In this case it would be <code>"bar"</code>.</p> <p>Is there an easy way through a built in function?</p> <p>Thanks.</p>
javascript jquery
[3, 5]
5,266,081
5,266,082
coloring a substring in a label
<p>I have the following label element where I'd like the asterisk to be colored red.</p> <pre><code>&lt;label&gt; Lastname * &lt;/label&gt; </code></pre> <p>How can this be done using jQuery, or otherwise?</p>
javascript jquery
[3, 5]
3,369,136
3,369,137
trouble mixing jquery and js
<p>Hey guys I'm a noob to jquery and I've heard it's okay to mix jquery with pure javascript, but I'd like to know if that is what's causing the following code not to work or is it something else that I'm doing wrong?</p> <pre><code>var fnd_child = $('#thumb_slider').children().length; $(document).ready(function(){ $('#basic_div').innerHTML = fnd_child; }); </code></pre> <p>Nothing happens in in basic_div... it's just empty. I've even tried attaching this function to a button but still nothing happens. I just need to know how many children are in basic_div and then print that number out on the screen. Thanks!</p>
javascript jquery
[3, 5]
3,035,244
3,035,245
Onmouseover data keep autorefresh
<p>I have a code like this below :</p> <pre><code>$(document).ready(function() { $("#content2").load("post_rf.php"); // set your initial interval to kick it off var refreshInterval = setInterval(function() { $("#content2").load('post_rf.php?randval='+ Math.random()); }, 1500); // bind an event to mouseout of your DIV to kickstart the interval again $("#content2").bind("mouseout", function() { refreshInterval = setInterval(function() { $("#content2").load('post_rf.php?randval='+ Math.random()); }, 1500); }); // clear the interval on mouseover of your DIV to stop the refresh $("#content2").bind("mouseover", function() { clearInterval(refreshInterval); }); $.ajaxSetup({ cache: false }); }); </code></pre> <p>What I want to do is when <code>mouseover</code>, data keep autorefresh. In this case if I drag mouse into the area of <code>mouseover</code>, it stop auto refresh until I drag <code>mouseout</code> out the area of <code>mouseover</code>.</p> <p>So is it possible to set <code>onmouseover</code>, data will keep auto refresh ?</p>
php javascript jquery
[2, 3, 5]
5,774,784
5,774,785
Does Handler work between processes?
<p><strong>In RemoteService (separate process)</strong></p> <pre><code> catch (ConnectException c) { TweetViewActivity.h.sendEmptyMessage(0); } </code></pre> <p><strong>TweetViewActivity</strong></p> <pre><code> static public Handler h; class LooperThread extends Thread { public Handler mHandler; public void run() { Looper.prepare(); h = new Handler(new Handler.Callback() { @Override public boolean handleMessage(Message msg) { Log.e("TAG", "handleMessage"); return true; } }); Looper.loop(); } } </code></pre> <p>While does this code doestn't get control?</p> <pre><code>Log.e("TAG", "handleMessage"); </code></pre>
java android
[1, 4]
2,520,098
2,520,099
Given two objects, how can I update one objects properties based on another
<p>I am trying to match update an object's property based on another object's property. The property names must match. A very simple example of what I am trying to achieve would look like this:</p> <p>Given two objects:</p> <pre><code>var obj1 = { one: "1", two: "2", three: { threeDotOne: "3.1", threeDotTwo: "3.2", threeDotAny: "3.3" } } var obj2 = {threeDotAny: "3.4"} </code></pre> <p>updateObjectOneProperty(obj1, obj2)</p> <p>and the result would look like this:</p> <pre><code>var obj1 = { one: "1", two: "2", three: { threeDotOne: "3.1", threeDotTwo: "3.2", threeDotAny: "3.4" } } </code></pre> <p>Here I am assuming that there will only be ONE property with such a name in obj1, which is fine.</p> <p>Does anyone have any idea on how to do this?</p>
javascript jquery
[3, 5]
2,872,992
2,872,993
jQuery plugin using reveal prototype pattern
<p>I'm developing a jQuery plugin using the reveal prototype pattern, I'm having some trouble to instantiate my object. Below, the code of the plugin :</p> <pre><code>(function($) { var GammadiaCalendar = function(elem, options) { this.elem = elem; this.$elem = $(elem); this.options = options; }; GammadiaCalendar.prototype = function() { var defaults = { message: 'Hello world!' }, init = function() { this.config = $.extend({}, this.defaults, this.options); this.displayMessage(); return this; }, displayMessage = function() { alert(this.config.message); }; return { displayMessage : displayMessage }; }; GammadiaCalendar.defaults = GammadiaCalendar.prototype.defaults; $.fn.GammadiaCalendar = function(options) { return this.each(function() { new GammadiaCalendar(this, options).init(); }); }; })(jQuery) </code></pre> <p>I'm getting <em>GammadiaCalendar is not defined</em> when instantiating:</p> <p>var gc = new GammadiaCalendar('id');</p>
javascript jquery
[3, 5]
2,822,203
2,822,204
Get height of dynamically created element
<p>I created one div dynamically and tried to get its height. I didn't assign fixed height to it. But its content is assigned a fixed height. So I tried to get its render height. </p> <pre><code>$(function(){ $services = $(&lt;div id="services"&gt;&lt;/div&gt;); $img = $(&lt;img src="abc.jpg" height="100px" width="100px"&gt;); $a = $("&lt;a href="home.php"&gt;Go to home&lt;/a&gt;"); $services.append($img,$a); }); $(function(){ var height = $("#services").height(); }); </code></pre> <p>I got value of height as 0.</p> <p>So I can't render height of <code>div#services</code>.</p>
javascript jquery
[3, 5]
4,357,810
4,357,811
How to load a php file on page load (jQuery provided)
<p>Each article of my site has a unique ID number. When a user clicks to read an article I use a function to get the current's article ID, so the option of the same value in a drop down list to be selected automatically. </p> <p>For example if I click in the article with ID = 79</p> <pre><code>&lt;option value="0" &gt;Please Choose&lt;/option&gt; &lt;option value="97" &lt;?php echo $postid == '97' ? 'selected="selected"' : '';?&gt; &gt;This is 97&lt;/option&gt; &lt;option value="98" &lt;?php echo $postid == '98' ? 'selected="selected"' : '';?&gt; &gt;This is 98&lt;/option&gt; </code></pre> <p>my dropdown list will have "This is 97" option selected.</p> <p>The problem here is that I use a jQuery script that displays a form upon selection as below:</p> <pre><code>&lt;script language='JavaScript'&gt; $(document).ready(function() { $('#termid').change(function() { var val = $(this).val(); $('#reservationdetails').empty().addClass('loading').load('../kratisis/forms/' + val + '.php', function(){$('#reservationdetails').removeClass('loading') }); }); }); &lt;/script&gt; &lt;div id="reservationdetails"&gt;&lt;/div&gt; </code></pre> <p>When a user enters to read article 97, the selected option will be "This is 97" but the requested php file (from jQuery) will not be shown unless I choose 98 and then back to 97.</p> <p>My question is how to handle this? I mean how to show the additional php file when a user enters the article at first but replace it when the dropdown value is changed?</p> <p>I thought of using <code>&lt;?php include("") ?&gt;</code> but assuming that I am on 97 and click on 98 there will be 2 additional php files.</p> <p>Thank you for your ideas. </p>
php javascript jquery
[2, 3, 5]
148,767
148,768
asp.net unable to locate a resource file
<p>Im attempting to utilize some custom script and css files within an asp page. In Visual Studio 2010 I am not getting any warnings or errors as to the status of these files, but when I attempt to run the page, and I open the javascript console I get the error: </p> <pre><code>Failed to load resource: the server responded with a status of 404 (Not Found) </code></pre> <p>Here's how I am attempting to load the files in my ascx file:</p> <pre><code>&lt;script type="text/javascript" src="scripts/jquery.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="scripts/jquery.scripts.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="scripts/jquery.alerts.js"&gt;&lt;/script&gt; &lt;link href="styles/jquery.alerts.css" rel="stylesheet"/&gt; </code></pre> <p>Anyone know whats going on here, why the browser can't locate the files but visual studio can?</p>
javascript asp.net
[3, 9]
2,873,090
2,873,091
Using classes in android - working with Context and helper classes
<p>I am still newbie to android, please could someone help. I want to use methods from the Net class as follows:</p> <pre><code>package com.test; import android.app.Activity; import android.os.Bundle; import android.view.Window; import android.widget.TextView; public class MyApp extends Activity { /** Called when the activity is first created. */ private Net wifi; TextView textStatus; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.main); wifi=new Net(this); textStatus = (TextView) findViewById(R.id.text); textStatus.append("Your online status is "); if (wifi.isOnline()){ textStatus.append("online "+wifi.getInfo()); } else{ textStatus.append("offline "+wifi.getInfo()); } } </code></pre> <p>}</p> <p>and my Net class </p> <pre><code>import android.app.Service; import android.content.Context; import android.content.Intent; import android.net.ConnectivityManager; import android.net.NetworkInfo; import android.net.wifi.WifiInfo; import android.net.wifi.WifiManager; import android.os.IBinder; public class Net{ WifiManager wifi; ConnectivityManager cm ; NetworkInfo netInfo ; public Net (Context ctx) { cm = (ConnectivityManager) ctx.getSystemService(ctx.CONNECTIVITY_SERVICE); netInfo = cm.getActiveNetworkInfo(); wifi = (WifiManager) ctx.getSystemService(Context.WIFI_SERVICE); } public boolean isOnline() { netInfo = cm.getActiveNetworkInfo(); if (netInfo != null &amp;&amp; netInfo.isConnectedOrConnecting()) { return true; } else{ return false; } } public NetworkInfo[] getName(){ NetworkInfo[] name=cm.getAllNetworkInfo(); return name; } public String getInfo(){ // Get WiFi status WifiInfo info = wifi.getConnectionInfo(); return info.getSSID().toString(); } } </code></pre> <p>I believe I should not be extending my Net class with Activity?.... I am getting source not found error when run the app. Tnx in advance!</p>
java android
[1, 4]
382,021
382,022
hover out function
<pre><code>jQuery("#markets_served").hover(function(){ jQuery.data(document.body, "ms_height", jQuery(this).height()); if(jQuery.data(document.body, "ms_height") == 35) { jQuery(this).stop().animate({height:'195px'},{queue:false, duration:800, easing: 'easeOutQuad'}); jQuery("#btn_ms_close").css("display","inline"); } }); jQuery("#btn_ms_close").hover(function(){ jQuery.data(document.body, "ms_height", jQuery("#markets_served").height()); jQuery("#markets_served").stop().animate({height:'35px'},{queue:false, duration:800, easing: 'easeOutQuad'}); jQuery(this).css("display","none"); }); </code></pre> <p>Problem with hovering out. It wont work. It wont hover out when the mouse is out of the content that appears on hover.</p> <p><a href="http://uscc.dreamscapesdesigners.net/" rel="nofollow">http://uscc.dreamscapesdesigners.net/</a> - example at the bottom " Markets Covered"</p>
javascript jquery
[3, 5]
4,472,562
4,472,563
Sequential arithmetic operation in javascript
<p>I've a text input and user will write a string for example <code>10+20-10-2*2+4/2</code> and I want to do an arithmetic operation sequentially, which means I want to <code>(10+20)-(10)-(2)*(2)+(4)/(2)</code> and the result should be <code>20</code> according to above example.</p> <p>In other words I want to do the arithmetic operation from the left, sequentially. Can anyone help me on this or may be some idea would be nice too. Thanks.</p> <p><strong>Please ask me if need more information.</strong></p> <pre><code>$('#calculation').on('blur', function(e){ e.preventDefault(); var pattern=/^[-*/+0-9]+$/; value=$(this).val(); if(value.match(pattern)) { $(this).closest('tr').find('span.error').html(''); //$('#total').val(eval(value)); // No idea what to do } else { $(this).closest('tr').find('span.error').html('Invalid character'); } }); </code></pre>
javascript jquery
[3, 5]
3,596,441
3,596,442
JavaScript/jQuery validation for text box
<p>I have a texbox that is like this:</p> <pre><code>&lt;input type="text" size="30" name="form[id]" id="form_id"&gt; </code></pre> <p>I need a JavaScript function that will validate:</p> <ol> <li>No Spaces allowed.</li> <li>Only numbers, letters, dashes(-) and underscores(_) allowed and no other special character allowed.</li> <li>Shouldn't be empty</li> </ol> <p>On Submit when the user's input is violating a validation. An alert message should be displayed.</p>
javascript jquery
[3, 5]
5,984,384
5,984,385
Timeout for javascript execution
<pre><code>jQuery(document).click(function () { jQuery('.close-news').css('display', function(){return jQuery('#colorbox').css('display');}); }); </code></pre> <p>I have this script, which make my link appear\dissappear depends on state of #colorbox block. But somewhy link appear\dissappear not immediatelly, but after 2 click. Basically i have to click one more time in random area to make my script work I guess its because my html code isnt update fast enought to make . So how do i add some timeout for this script?</p>
javascript jquery
[3, 5]
586,153
586,154
How to know that provided device tokens are real?
<p>I'm developing server-side for IPhone app. This app has ability to subscribe on events (push notifications). Is it possible to know that provided devide token is real (to prevent spam)? I'm afraid that somebody can subscribe millions fake devices and my "push" service will be overwhelmed.</p>
c# iphone
[0, 8]
943,483
943,484
Get folder name from full file path - C#, ASP.NET
<p>How to get the folder name from the full path of the application?</p> <p>This is file path,</p> <p>"c:\projects\roott\wsdlproj\devlop\beta2\text"..</p> <p>Here "text" is the folder name.</p> <p>How can I get that folder name from this path?</p>
c# asp.net
[0, 9]
3,261,333
3,261,334
Javascript matching to see if an email or phone number has been supplied
<p>I created a contact form with a text area input only field, which allows the end user to fill out and include a method on how to be contacted. They can choose to enter an email, phone number or both within their message.</p> <p>I am using jQuery along with javascript to process the form and check if a contact method has been inputted into the message. Here is what I have and it is not getting the job done. Am I doing my matching on the value correctly?</p> <pre><code>var error = '' if (value == '' || value == 'Fill out this form and include an email or phone number to be contacted ...') { error = 'A message along with your contact details are required before sending.'; } else if (!value.match(/^[a-zA-Z0-9_\.\-]+\@([a-zA-Z0-9\-]+\.)+[a-zA-Z0-9]{2,4}$/) || !value.match(/^[0-9\-\(\)\ ]+$/)) { error = 'Your message should contain an email address or phone number.'; } </code></pre> <p>The first error checking works, the 2nd keeps giving an error even if I do enter an email or phone number or both into the message. Should I be breaking this apart and searching each word individually is that how you do it?</p>
javascript jquery
[3, 5]
4,239,711
4,239,712
jQuery Template Formatting with Comma
<p>I have the following template. I want to display the categories with a comma in between. How do I do it?</p> <p>Currently it is without comma using <code>Categories: {{each categories}} &lt;i&gt;${$value}&lt;/i&gt; {{/each}}</code></p> <p>Note: There should be no comma after the last item. Also all items should be displaying in one row (as it is currently)</p> <pre><code>&lt;script id="Script1" type="text/x-jQuery-tmpl"&gt; &lt;h1&gt;${postTitle}&lt;/h1&gt; &lt;p&gt; ${postEntry} &lt;/p&gt; {{if categories}} Categories: {{each categories}} &lt;i&gt;${$value}&lt;/i&gt; {{/each}} {{else}} Uncategorized {{/if}} &lt;/script&gt; &lt;script type="text/javascript"&gt; var blogPostsArray = [ { postTitle: "Learn jQuery", postEntry: "Learn jQuery easliy by following.... ", categories: ["HowTo", "Sinks", "Plumbing"] }, { postTitle: "New Tests", postEntry: "This is a test website" } ]; $("#blogPostTemplate").tmpl(blogPostsArray).appendTo("#blogPostContainerDiv"); &lt;/script&gt; </code></pre>
javascript jquery
[3, 5]
770,973
770,974
jquery Element to DOM Element returns empty string by function
<p>Why does this code:</p> <pre><code>function fn(el){ return $(el)[0].style.width }; fn('#someElementIdId'); // return -&gt; "" </code></pre> <p>But this code...</p> <pre><code>function fn(el){ return $(el).width() } ; fn('#someElement'); // return -&gt; correct width </code></pre> <p>I have tried different things, but all have the same result...</p> <p>How can I make the first code work?</p> <p><strong>CODE HERE :: <a href="http://jsfiddle.net/A2VpH/18/" rel="nofollow">http://jsfiddle.net/A2VpH/18/</a></strong></p>
javascript jquery
[3, 5]
3,416,090
3,416,091
get word click in paragraphs
<p>I have an HTML document with about 30,000 words in it. </p> <p>I'd like to be able to do something when a user clicks any word. For simplicity/concept right now, I'd just like to <code>alert()</code> that word.</p> <p>For example, in the paragraph about, if I were to click on "have" it should run <code>alert("have")</code>.</p> <p>I'm using jQuery.</p>
javascript jquery
[3, 5]
824,265
824,266
Java Threading Error IllegalThreadState thread already started
<p>Whenever I start my thread I always do this check. I did not find anywhere that I called start on thread without doing the check below</p> <pre><code>if (!myThread.isAlive()) myThread.start(); </code></pre> <p>Nevertheless, I end up with IllegalThreadStateException : Thread already started. This actually crashes my app (android). So is there some other check I need to do before starting up a thread?</p>
java android
[1, 4]
109,134
109,135
ASP.NET content display
<p>I am building a profile page in asp.net and it has two tabs(Horizontally), one for profile and one for settings. If a user navigates between tabs, he will see the settings page and the profile page. I know two ways to implement this.</p> <ol> <li><p>Code the page contents in the page and use javascript to hide them, while navigating through them. This type of method is inefficient as it will lead to performance issues and increase load time.</p></li> <li><p>Use onclick event handler and build the page using codebehind file. This is more efficient way, I can use javascript to rotate something to show that something is being processed and then call a last method in codebehind to hide the rotating Image.</p></li> </ol> <p>Besides these methods, Are there some other efficient ways to accomplish this?</p>
javascript asp.net
[3, 9]
5,580,162
5,580,163
difference between Immediately-Invoked Function and jQuery Immediately-Invoked Function
<p>i have read that <code>(function(){})();</code> is called immediately and doesn't need to be called. and <code>$(function());</code> is also immediately called.</p> <ul> <li>are they both and have same functionality ?</li> <li>does the Immediately-Invoked Function loaded after the document is completely loaded ?</li> <li>what is the actual funcitonality of <code>$(fucntion());</code> ?</li> <li>does <code>$(fucntion());</code> after the document is completely loaded ?</li> </ul>
javascript jquery
[3, 5]
555,377
555,378
Delay a ready function() in javascript or jquery
<pre><code>//this code animates the divs to the left after every 5 secs $(document).ready(function() { var refreshId = setInterval(function() { $('.box').each(function() { if ($(this).offset().left &lt; 0) { $(this).css("left", "150%"); } else if ($(this).offset().left &gt; $('#container').width()) { $(this).animate({ left: '50%' }, 500); } else { $(this).animate({ left: '-150%' }, 500); } }); }, 5000);) };​ </code></pre> <p>In the above code, whenever the page gets loaded the <code>div</code> elements keep sliding every 5 secs. But there is a button in my webpage which, when clicked, moves the <code>div</code> elements to the left or right respectively according to the button clicked. But the problem is the auto animation and animation occuring on buuton click sometimes overlap. So whenever I click the button I want to delay the auto animation in <code>document.ready</code> by 5 secs again.</p> <p>This is shown in this <a href="http://jsfiddle.net/9FPBA/2" rel="nofollow">jsFiddle</a>. When you keep clicking on the "left animation" or "right animation" buttons, the divs overlap sometimes. So I just want to delay the auto animation whenever I click the buttons.</p>
javascript jquery
[3, 5]
4,710,487
4,710,488
Use jQuery to change the background image effect
<p>I am trying to use jQuery to change the effect of my background picture.</p> <p>Here is my jquery:</p> <pre><code>$("#piceffect").change(function() { $('#backgroundpicture').css({'background-image': 'repeat'} }); </code></pre> <p>How would I go about getting the background image in my div "backgroundpicture" to repeat when the id "piceffect" changes. I have tried a lot and what I have above is the best that I can do. Any help would greatly be appreciated. Thanks!</p>
javascript jquery
[3, 5]
6,003,609
6,003,610
Jquery trigger() is not working on document ready
<p>I tried a lot of variations of this but it doesn't seem to work.</p> <pre><code>&lt;script type="text/javascript"&gt; $(document).ready(function(){ $('#slide_click').trigger('click'); }); &lt;/script&gt; </code></pre> <p>This should triggers a button with an onclick event when the document is ready</p> <pre><code>&lt;button id="slide_click" onclick="gotoSlide(&lt;?php echo $_GET["goto"] ?&gt;)"&gt;Trigger&lt;/button&gt; </code></pre> <p>The gotoSlide function needs an integer parameter, what it does is it should go to the specific slide on my gallery slider. But apparently it doesn't work. I can't seem to figure it out.</p> <p>I'm using a jquery plugin for the slider called Advanced Slider. Am I using the trigger() function correctly?</p>
javascript jquery
[3, 5]
2,905,946
2,905,947
Run SpeechRecognizer during call
<p>Is there a way to run SpeechRecognizer while being in a call? I have done it this way:</p> <ul> <li><code>BroadcastReceiver</code> handles change in phone state (e.g. offhook).</li> <li>the <code>SpeechRecognizer</code> is started in the current (main) thread, as it can only be started in the main thread. The application context is used for the recognizer (the current context, given to the broadcast receiver, can't start be used)</li> </ul> <p>But unfortunately, the person on the other side can't hear me (the speech recognition works fine though). In away, the recognizer has "consumed" my voice and doesn't send it over.</p> <p>I'm aware that doing things in the main thread during call is dangerous, but is there a way to run the recognizer somehow during call?</p> <p>Update: I am trying the <code>TelephonyManager</code> listener instead of a <code>BroadcastReceiver</code>, but some internal services blow with NPEs.</p>
java android
[1, 4]
3,743,029
3,743,030
javascript closure not working as it should
<p>see the first code:</p> <pre><code> var count = 0; (function addLinks() { var count = 0;//this count var is increasing for (var i = 0, link; i &lt; 5; i++) { link = document.createElement("a"); link.innerHTML = "Link " + i; link.onclick = function () { count++; alert(count); }; document.body.appendChild(link); } })(); </code></pre> <p>When the link gets clicked the counter variable keeps on increasing for each link element. This is the expected result.</p> <p>Second:</p> <pre><code>var count = 0; $("p").each(function () { var $thisParagraph = $(this); var count = 0;//this count var is increasing too.so what is different between them .They both are declared within the scope in which closure was declared $thisParagraph.click(function () { count++; $thisParagraph.find("span").text('clicks: ' + count); $thisParagraph.toggleClass("highlight", count % 3 == 0); }); }); </code></pre> <p>Here the closure function is not working as expected. On each click on the paragraph element, the counter <code>var</code> is increased but that increment is not displayed on click on second paragraph element? What is the reason for this? Why is this happening? The count variable is not increasing for each paragraph element.</p>
javascript jquery
[3, 5]
1,662,916
1,662,917
Is Dirty in ASP.NET Web Page
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/155739/detecting-unsaved-changes-using-javascript">Detecting Unsaved Changes using JavaScript</a> </p> </blockquote> <p>My Web application has 3 web forms ,I implemented the validations in my webpage.I want to implement isdirty functionality in my web application.I want to pop up a message box in my webpage when a user clicks on sign out(which is a loginstatus control) if there any changes made to the form.</p> <p>Environment: Asp.net VS2008 c#</p>
c# asp.net
[0, 9]