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 |
---|---|---|---|---|---|
2,117,624 | 2,117,625 | How to parse a url from a String in android? | <p>I want to parse the url from a String in android. The example String is </p>
<pre><code>"This is a new message. The content of the message is in 'http://www.xyz.com/asd/abc' "
</code></pre>
<p>I want to parse the url <code>http://www.xyz.com/asd/abc</code> from the String without using the subString method.</p>
<p>Regards
Paru </p>
| java android | [1, 4] |
1,192,656 | 1,192,657 | if the IF statement is true view new activity | <pre><code> if(res.equals("5510"))
checkback.setText("Correct version");
//
else
checkback.setText("Incorrect version, please update. \n Your current version is " + getString(R.string.versioncode));
</code></pre>
<p>How do i get it so that if the IF statement is true then it'll start and view mainactivity.class?</p>
<p>I put intent in but when i did it showed up with a bunch of errors</p>
| java android | [1, 4] |
4,991,601 | 4,991,602 | Jquery toggle span text in trigger | <p>I'm so close to figuring this out, i think. I'm new to javascript, but here's my situation.</p>
<p>I've got some lists hidden by default. Clicking on the headers displays the lists. I want the span in the header to change from '+' to '-' to hide and show respectively. </p>
<p>The problem i'm running into is the span changes for both headers, instead of just the one being clicked. </p>
<pre><code> <div>
<h3 class = "trigger"><span>+</span>Heading 1</h3>
<ul class = "toggle">
<li>Line One</li>
<li>Line Two</li>
<li>Line Three</li>
</ul>
</div>
<div>
<h3 class = "trigger"><span>+</span>Heading 2</h3>
<ul class = "toggle">
<li>Line One</li>
<li>Line Two</li>
<li>Line Three</li>
</ul>
</div>
</code></pre>
<p>And here is the accompanying javascript for it. </p>
<pre><code>$(".trigger").click(function(){
$(this).next(".toggle").slideToggle(function(){
$('span').text(
$('.toggle').is(':visible') ? '-' : '+');
});
});
</code></pre>
<p>Here is a <a href="http://jsfiddle.net/toddj/sWvbq/3/" rel="nofollow">jsfiddle</a></p>
| javascript jquery | [3, 5] |
512,967 | 512,968 | Android location manager compilation error | <p>I'm trying to retrieve an instance of a LocationManager class (do get some GPS related information). I have used wrote a simple class to do so, but it end up giving me an error </p>
<pre><code>Cannot make a static reference to the non-static method getSystemService(String) from the type Context
</code></pre>
<p>here's my class</p>
<pre><code>public class LocationManagerHelper {
static Location location = null;
public static Location getLocation () {
LocationManager manager = (LocationManager) Context.getSystemService(Context.LOCATION_SERVICE);
if(manager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
Location location = manager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
} else {
System.out.println("Provider is disabled");
}
return location;
}
}
</code></pre>
<p>Thanks.</p>
| java android | [1, 4] |
3,989,403 | 3,989,404 | Using jQuery's getJSON() method | <p>So I was reading through the code on Malsup's twitter <a href="http://malsup.com/jquery/twitter/" rel="nofollow">plugin</a> and I noticed he'd written his own method to handle jsonp but with timeouts and errors. I can only assume the built in jQuery method 'getJSON' doesn't have this functionality even though it clearly works fine.</p>
<p>So, should I continue to use Malsups version in my projects where I'm making JSONP requests or just stick with jQuery's method. I have emailed Malsup and Paul Irish to ask about why it was necessary to write this but I didn't hear back. Can't blame 'em really:)</p>
<pre><code>$.getJSONP = function(s){
s.dataType = 'jsonp';
$.ajax(s);
// figure out what the callback fn is
var $script = $(document.getElementsByTagName('head')[0].firstChild);
var url = $script.attr('src') || '';
var cb = (url.match(/callback=(\w+)/) || [])[1];
if (!cb)
return; // bail
var t = 0, cbFn = window[cb];
$script[0].onerror = function(e){
$script.remove();
handleError(s, {}, "error", e);
clearTimeout(t);
};
if (!s.timeout)
return;
window[cb] = function(json){
clearTimeout(t);
cbFn(json);
cbFn = null;
};
t = setTimeout(function(){
$script.remove();
handleError(s, {}, "timeout");
if (cbFn)
window[cb] = function(){
};
}, s.timeout);
function handleError(s, o, msg, e){
// support jquery versions before and after 1.4.3
($.ajax.handleError || $.handleError)(s, o, msg, e);
}
};
</code></pre>
| javascript jquery | [3, 5] |
3,357,077 | 3,357,078 | Return array in Java | <p>I have my primary class running, and I wanted to run a separate class to shuffle numbers, then return the shuffled numbers into my primary class. In my shuffle class I have the return statement... but now what do I do? How do I use the random order of my int array in my primary class?</p>
<p>Here is my shuffle class:</p>
<pre><code>public class Shuffle {
public static int[] getShuffle() {
int[] cards = new int[52];
ArrayList<Integer> cards_objs = new ArrayList<Integer>();
for (int i = 0; i < cards.length; i++) {
cards_objs.add(i);
}
Collections.shuffle(cards_objs);
for (int i = 0; i < cards.length; i++) {
cards[i] = cards_objs.get(i);
}
return cards;
}
</code></pre>
<p>}</p>
<p>I am making a card game(if you cant tell);</p>
<p>I wanted to use this shuffle class so that the cards are shuffled... but no card appears more than once.</p>
<p>when I return cards, how do I use them in my game class?
for example if the first number in the array is 1, then the card is Ace of clubs,
if the number is 2, then the card is Ace of diamonds. and so on...
I apologize for not posting enough information... I am new to java (as you can tell)</p>
<p>all help will be greatly appreciated,</p>
<p>-Steve</p>
<p>EDIT:
I found out what my problem was, I don't think I made it clear enough what my question was. Nonetheless thank you all for your help, it gave me ideas on different ways to approach this project. </p>
| java android | [1, 4] |
3,629,834 | 3,629,835 | Difference between document.createElement('script') vs jQuery .getScript | <p>I've been having an issue getting <code>.getScript</code> to work in some odd cases.</p>
<p>For instance, this works to load the scripts only when needed.</p>
<pre><code>function twitterSDK() {
$jQ.getScript('http://platform.twitter.com/widgets.js');
}
function diggShare() {
$jQ.getScript('http://widgets.digg.com/buttons.js');
}
function buzzShare() {
$jQ.getScript('http://www.google.com/buzz/api/button.js');
}
</code></pre>
<p>However it doesn't seem to work on a few scripts that I wrote. If I call <code>.getScript</code> to fetch this JS file I've uploaded to Pastebin ( <a href="http://pastebin.com/GVFcMJ4P" rel="nofollow">http://pastebin.com/GVFcMJ4P</a> ) and call <code>tweetStream();</code> nothing happens. However, if I do the following it works:</p>
<pre><code>var twitter = document.createElement('script');
twitter.type = 'text/javascript';
twitter.async = true;
twitter.src = '/path-to/tweet.js';
$jQ('.twitter-section').append(twitter);
tweetStream();
</code></pre>
<p>What am I doing wrong? Any help would be awesome, thanks!</p>
<p>P.S. Which method is faster or more efficient?</p>
<p><strong>Note: My code isn't hosted on pastebin, I just uploaded the contents of the .js file that is on my server to that site so it is easy to share. I am not leeching of pastebin for hosting ;)</strong></p>
| javascript jquery | [3, 5] |
992,059 | 992,060 | How do you randomly generate X amount of numbers, between the range of Y and Z in JavaScript? | <p>For example I would like to generate 5 <strong>unique</strong> numbers between 1 & 10. The results should be 5 numbers from 1 to 10(for example 2 3 4 8 10).</p>
| javascript jquery | [3, 5] |
4,693,016 | 4,693,017 | jQuery beforeScroll event | <p>Is there a beforeScroll event in jQuery? Or can this type of event be replicated at all?</p>
<p>We have a scenario where we need perform an event before a div with overflow:scroll has been scrolled. The problem with using the .scroll event is that this is raised after the div has been scrolled rather than before. </p>
| javascript jquery | [3, 5] |
2,089,905 | 2,089,906 | How can I set/store cookie when anchor clicked | <p>I am trying to use Cookie so that a default style OR a specific style is applied in reference to the anchor tag clicked, even when the browser is closed/reopen.
So if the user clicked the second link, close or refresh the browser and reopen, than the style should still be active, if it is their first time the default should apply.
This is a little over my turf. </p>
<p><strong>Here is the HTML:</strong></p>
<pre><code><a id="default" href="#/">Default Style</a>
<a id="style2" href="#/">Style 2</a>
<a id="style3" href="#/">Style 3</a>
<ol>
<li><span>Hello World</span></li>
</ol>
</code></pre>
<p><strong>JQuery: (Compliments of StackOverflow)</strong></p>
<pre><code><script type="text/javascript">
$('#default').on('click',function(){
$('ol li span').removeClass(function() {
return $(this).attr('class');
}).addClass('default');
});
$('#style2').click(function(){
$('ol li span').removeClass(function() {
return $(this).attr('class');
}).addClass('style2');
});
$('#style3').click(function(){
$('ol li span').removeClass(function() {
return $(this).attr('class');
}).addClass('style3');
});
</script>
</code></pre>
<p><strong>CSS:</strong></p>
<pre><code><style type="text/css">
.default{
color: #333;
}
.style2{
color: #999;
}
.style3{
color: #800;
}
</style>
</code></pre>
| javascript jquery | [3, 5] |
243,271 | 243,272 | Loop through All Objects of a Class | <p>Let's say I have some class called <code>loopObject</code> and I initialize every object through something like <code>var apple = new loopObject();</code> Is there anyway to loop through all objects of a class so that some function can be performed with each object as a parameter? If there isn't a direct method, is there a way to place each new object into an array upon initialization?</p>
| javascript jquery | [3, 5] |
3,159,976 | 3,159,977 | jQuery: animate to height of div | <p>I have this function:</p>
<pre><code>function fixedFeeSize(i){
var num1 = $('#num' + i);
if (num1.hasClass("extended")) {
num1.stop(true, true).animate({height: '59px'},500);
num1.removeClass("extended");
}else{
var height = 0;
num1.animate({height: '360px'},500);
num1.addClass("extended");
}
return null;
}
</code></pre>
<p>Which expands / contracts a div, however I am struggling to get it to expand to the height of the div as each div (there will be 10+) is going to be different heights.</p>
<p>I tried <code>num1.animate({height: 'auto'},500);</code> which has not worked.</p>
| javascript jquery | [3, 5] |
3,370,500 | 3,370,501 | copy events from one elm to other using jquery | <pre><code> ==dom is like this==
<a href='javascript:void(0)' id='link1'>elm with events bound initially</a>
<a href='javascript:void(0)' id='link2'>elm to which events are bound in future</a>
====js==
$(function(){
$('#link1').bind('click',function(){alert('do something to make me happy');})
});
//now some time in future i want to copy all events bound on link1 to link2
//iam doing it as written below
// please suggest some better way if possible or available
var _elmEvents = $(#link1).data('events');
if (_elmEvents) {
$.each(_elmEvents, function (event, handlers) {
$.each(handlers, function (j, handler) {
$('#link2').bind(event, handler);
});
});
}
</code></pre>
| javascript jquery | [3, 5] |
681,804 | 681,805 | javascript array passed to post into PHP array | <p>How do you process a javascript array in PHP, when you're posting it.
Here's what I am doing:</p>
<pre><code>$(".action_btn").live('click', function() {
var friends = new Array();
$(this).parents('.friends_rec').find('input:checked').each(function(k) { friends[k] = $(this).val(); });
var comment = $(this).parents('.friends_rec').find('textarea').val();
$.post("update.php",
{ uid: <?php echo $_SESSION['uid']; ?>, mid: <?php echo $_GET['mid']; ?>, friends: friends, comment: comment },
function() {
});
}
});
</code></pre>
<p>Question is, in update.php, what should I do to iterate this friends array?</p>
| php javascript | [2, 3] |
3,176,604 | 3,176,605 | Handle "press enter key" on android | <p>I created a little app that has a search bar. now I want to know if I can handle the situation when a user press the enter key. so the app can call the buttonOnClickListener() that actually perform the search?</p>
| java android | [1, 4] |
1,204,264 | 1,204,265 | How do I reference the "title" given the id? | <pre><code>var data = {};
data.event = [
{
"id":"998",
"title":"Foo",
"thumb":"",
"source":""
},
{
"id":"999",
"title":"Bar",
"thumb":"",
"source":""
}
]
</code></pre>
<p>Given that id=998 I need to extract the value of the "title" and I'm a bit lost as to the proper syntax.</p>
| javascript jquery | [3, 5] |
3,667,738 | 3,667,739 | Error with MediaPlayer | <p>I am trying to make music play in my app and have a song play after the first one has finished but i get some errors that i cannot resolve any help?</p>
<pre><code>public class Music {
int count;
String[] titles = new String[] { "title1.mp3", "title2.mp3", "title3.mp3", "title4.mp3" };
public void GameMusic(){
count = 0;
MediaPlayer mp = MediaPlayer.create(this, R.raw.title1);
mp.start();
}
void onCompletion(MediaPlayer mp){
mp.stop();
if (count == titles.length -1) {
count = 0;
}
mp.setDataSource(titles[count]);
count++;
mp.prepare();
mp.start();
}
}
</code></pre>
<p>The errors are on:</p>
<pre><code> MediaPlayer mp = MediaPlayer.create(this, R.raw.music);
</code></pre>
<p>(The method create(Context, int) in the type MediaPlayer is not applicable for the arguments (Music, int)</p>
<pre><code> mp.setDataSource(titles[count]);
</code></pre>
<p>(Unhandled exception type IOException)</p>
<pre><code> mp.prepare();
</code></pre>
<p>(Unhandled exception type IOException)</p>
<p>Any help would be appreciated.</p>
| java android | [1, 4] |
1,354,765 | 1,354,766 | Styling a list item with a child | <p>I've been going around in circles for hours, I keep getting errors with this code :</p>
<pre><code>$('div.colA div.region-sidebar-left div.menu-block-wrapper').find('li').each(function() {
if ($(this).find('> ul').size() > 0) {
$(this).addClass('has_child');
}
});
</code></pre>
<p>All it is supposed to do is find all the <code><li></code> with a child of <code><ul></code> and give it a class. Simple.</p>
<p><a href="http://jsfiddle.net/simcox90/mEMmN/" rel="nofollow">http://jsfiddle.net/simcox90/mEMmN/</a></p>
| javascript jquery | [3, 5] |
3,629,557 | 3,629,558 | How to add attribute when onclick event in asp.net | <p>Hi how can i add attribute into a button when button is clicked?</p>
<p>this is the attribute <code>dojotype="dijit.form.Button"</code></p>
<pre><code>void ButtonLogin_OnClick(object sender, EventArgs e)
{
// the add attribute
}
</code></pre>
<p>this is my button</p>
<pre><code><button id="ButtonLogin" runat="server" onServerClick="ButtonLogin_OnClick" jsid="ButtonLogin" style="float: right;
padding: 5px 15px 0px 0px;">
Login</button>
</code></pre>
| javascript jquery asp.net | [3, 5, 9] |
5,319,678 | 5,319,679 | Send array from jQuery(ajax) to PHP | <p>class <code>email</code> is an array of email addresses. How do i get the array in jQuery and then send the data with AJAX to send.php along with class <code>title</code> and <code>message</code>?</p>
<pre><code> <input type='text' size='30' class='email' value='[email protected]' />
<input type='text' size='30' class='email' value='[email protected]' />
<input type='text' size='30' class='email' value='[email protected]' />
<input type='text' size='30' class='title' value='testing title' />
<input type='text' size='30' class='message' value='testing message' />
<script type="text/javascript">
$(function() {
var title = $('.title').val();
var message = $('.message').val();
var dataString = 'title=' + title + '&message=' + message;
$.ajax({
type: "POST",
url: "send.php",
data: dataString,
success:function () {
}
});
});
</script>
</code></pre>
<p>send.php</p>
<pre><code><?php
$email = $_POST['email'];
$title = $_POST['title'];
$message = $_POST['message'];
foreach($email as $value) {
//send email
}
?>
</code></pre>
| php jquery | [2, 5] |
553,347 | 553,348 | update datatable inside a dataset | <p>I want to know how to update a Datatable which is inside a dataset.I have a datatable in which i have details of some item.Now i want to add this into a dataset for some purpose and update it.Give me some suggesions to solve this..</p>
<p>this is my code:</p>
<pre><code> DataRow dr;
dr = Basket_DataTable.NewRow();
Basket_DataTable.Rows.Add(dr);
dr["PId"] = getPId.ToString();
dr["ProductName"] = getProductName.ToString();
dr["ImagePath"] = getImagePath.ToString();
dr["ProductPrice"] = getProductPrice.ToString();
dr["Quantity"] = getQuantity.ToString();
dr["ProductDescription"] = getProductDescription.ToString();
dr["TotalPrice"] = getProductPrice.ToString();
Basket_DataTable.AcceptChanges();
</code></pre>
<p>Basket_DataTable is my datatable which i need to add to a dataset and update.. </p>
| c# asp.net | [0, 9] |
2,353,075 | 2,353,076 | Abstract class with static methods. Is that correct? | <p><strong>Task</strong>: I want to use some methods for many classes. Methods are same, so there is no need to implement them for each class. In my case - I work with android SDK and I send http request to server.</p>
<p><strong>Problem</strong>: There is idea to use construction like this:</p>
<pre><code>class abstract MethodsCarrier{
public static void method1(){ /*something*/ }
public static int method2(){ /*return something*/ }
}
</code></pre>
<p>It works, there is no problems. But I'm not sure about making this class abstract. Is it's a right way at all?</p>
| java android | [1, 4] |
1,049,786 | 1,049,787 | Javascript / JQUery Dynamic Variable Access | <p>I have a javascript variable which is referencing a complex object (it is a slideshow control but that's not important)</p>
<pre><code>e.g.
var slideshow = new SlideShow();
</code></pre>
<p>Because i have multiple slideshows on the page and I want to make accessing certain operations generic/reuse code in different pages. </p>
<p>I WANT TO BE ABLE TO ACCESS DIFFERENT VARIABLES CONTAINING DIFFERENT INSTANCES OF THE SLIDESHOWS IN THE SAME JAVASCRIPT ROUTINE. THE VARIABLE USED IS DIFFERENT DEPENDING ON WHAT SLIDESHOW IS BEING CONTROLLED AT THE TIME.</p>
<p>So instead of </p>
<pre><code>slideshow.playSlides();
</code></pre>
<p>do something like</p>
<pre><code>[dynamically get reference to variable containing slideshow].playSlides();
</code></pre>
<p>I've looked into this before in JavaScript and not found a solution, I'm wondering if this can be done in JQUERY somehow?</p>
| javascript jquery | [3, 5] |
3,569,453 | 3,569,454 | Checks if a value exists in an array input value by jquery | <p>I want check if id in array value input:cheched <code>3</code>, <code>alert (true)</code> else <code>alert (false)</code>. I tried as following js code, but don't work for me. </p>
<p>How can fix it?</p>
<p><strong>DEMO:</strong> <a href="http://jsfiddle.net/VAwHR/4/" rel="nofollow">http://jsfiddle.net/VAwHR/4/</a></p>
<p><strong>HTML:</strong></p>
<pre><code><input value="3" type="text" id="seeid">
<div class="paginate">
<input name="ch[]" type="checkbox" value="1" checked>
<input name="ch[]" type="checkbox" value="2">
<input name="ch[]" type="checkbox" value="3" checked>
<input name="ch[]" type="checkbox" value="4">
</div>
<input type="submit" class="sub">
</code></pre>
<p><strong>JQUERY:</strong></p>
<pre><code>$('.sub').click(function(){
var seeid = $('#seeid').val();
var db = $('.paginate :checkbox:checked').map(function (i, n) {
return $(n).val();
}).get();
alert($.inArray(seeid, db))
})
</code></pre>
| javascript jquery | [3, 5] |
144,522 | 144,523 | smart keyboard in jQuery | <p>SO I have need to develop online keyboard using jQuery or anything else that can help me achieve following.</p>
<ol>
<li>When I type any letter , it can check against bunch of words and keep only those Keys enable which are possible. </li>
</ol>
<p>For example. In my word collection I have word "Hello". When I type "H" on the keyboard...it should only keep "e" "l" "o" keys enabled and everything else should be disabled.</p>
<p>Is there a Name for such keyboards ? Any Examples would be appreciated. Currently I am planing to do this using jQuery and AJAX. I can keep my word collection on server and then do a look up on every kep press.</p>
<p>Ved</p>
| javascript jquery | [3, 5] |
5,681,511 | 5,681,512 | PHP ' inside " inside ' | <p>I have some code to display a thumbnail on hover over an image.</p>
<pre><code><div onmouseover="document.getElementById('logo').style.display='block';"
onmouseout="document.getElementById('logo').style.display='none';">
<img src = "img.jpg"/>
</div>
</code></pre>
<p>This time I want to choose the image to display instead of the static "img.jpg", which will be stored in variable $filename and then I want to append that to another jquery variable $result:</p>
<p>I tried this but there's confusion with single quotes:</p>
<pre><code>$result.= '
<div onmouseover="document.getElementById('logo').style.display='block';"
onmouseout="document.getElementById('logo').style.display='none';">
<img src = "images/' . $filename.'"/>
</div>
';
</code></pre>
<p>The confusion arises with single quotes around 'logo', 'block' and 'none'. How do I include single quotes in such situation?</p>
| php jquery | [2, 5] |
1,380,602 | 1,380,603 | How can i create new Contact in Android by Java? | <p>I am using Android 3.1 platform and i just want to create new contact on my Emulator using java.I couldn't find any working example.Please help me</p>
| java android | [1, 4] |
1,307,072 | 1,307,073 | I have a title like Virtual Team Resources then i need its short code like VTR | <p>I have a title like Virtual Team Resources then i need its short code like VTR
If Title Virtual Team then ShortCOde will be VTE
i have implement this but still some issues like
if user enter title Virtual T then short code will ?</p>
<p>My Code------</p>
<pre><code>function EnterShortCode() {
debugger
var ProjectShortCode = "";
var Arr = $("#txtProjectTitle").val().rtrim().split(" ");
for (i = 0; i < Arr.length; i++) {
if (Arr[i] != "" && Arr[i] != null) {
ProjectShortCode += Arr[i].substring(0, 1);
if (i == Arr.length - 1) {
if (ProjectShortCode.length == 1) {
if (Arr[i] < 3) {
}
else {
ProjectShortCode = ProjectShortCode + Arr[i].substring(1, 3);
}
}
else if (ProjectShortCode.length == 2) {
if (Arr[i] < 2) {
}
else {
ProjectShortCode = ProjectShortCode + Arr[i].substring(1, 2)
}
}
}
}
}
ProjectShortCode = ProjectShortCode.toUpperCase();
alert(ProjectShortCode);
}
</code></pre>
| javascript jquery | [3, 5] |
5,335,475 | 5,335,476 | Does jQuery's .load() always automatically execute scripts? | <p>I noticed if you <code>.load(url)</code> and the url is a page that contains scripts, those scripts are automatically executed. Is there a way to call <code>.load(url)</code> without the scripts executing, then perhaps execute them later? They seem to execute even if I've used <code>.load(url)</code> on an element that hasn't been appended to the document.</p>
| javascript jquery | [3, 5] |
5,837,486 | 5,837,487 | How can i close all the IE browser windows that I opened in JavaScript | <p>How can i close all the IE browser window in asp.net,</p>
<p>I am opening many windows..from javascript by window.open()...
I need to close all the windows by clicking the button in main page(parent window).</p>
<p>some times we have open in in c# it self</p>
<pre><code>btnShow.Attributes.Add("onclick", @"var windowVar=window.open('" + sAppPath + @"', 'parent');windowVar.focus(); return false;");
</code></pre>
<p>at the time how can i put in array in javascript.</p>
<p>How can i do it?</p>
| asp.net javascript | [9, 3] |
5,753,539 | 5,753,540 | Saving File on Long Click | <p>I have an app that plays mp3's. I want to make it so when you long click/press on the button it will save the mp3 file to there ringtones directory. Also want a toast notification if possible. Could someone shoot me into the right direction? </p>
<p>Thanks</p>
<p>EDIT:
This is what I have so far</p>
<pre><code> @Override
public boolean onLongClick(View arg0) {
Toast toast = Toast.makeText(AkaliMain.this, "Saved",5000);
toast.setGravity(Gravity.CENTER, 0, 0);
toast.show();
return false;
}
});
</code></pre>
<p>EDIT 2:
This is what I have now. Cant even get it to compile.</p>
<p><a href="http://pastebin.com/raw.php?i=EijmBrSL" rel="nofollow">http://pastebin.com/raw.php?i=EijmBrSL</a></p>
| java android | [1, 4] |
1,487,178 | 1,487,179 | Finding words within a paragraph of text | <p>I have a <code><p></code> tag and within the tag, there is a paragraph of text. </p>
<pre><code><p>"Hello Lorem ipsum Hello dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex Hello ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecatHello cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum Hello.</p>
</code></pre>
<p>Within the <code><p></code> tag, there is a chunk of text. Within the text, there are a few "<em>Hello</em>". I want to loop through the whole chunk of text inside the <code><p></code> tag and find <strong>all</strong> the "<em>Hello</em>" string and wrap those "<em>Hello</em>" strings that are found with an html tag.</p>
<p>Is there a way, through jQuery's selector, that I could loop through all the text within the <code><p></code> tag, find all the words that is exactly "Hello", wrap the word with a <code><strong class="test"></code> tag?</p>
| javascript jquery | [3, 5] |
2,105,518 | 2,105,519 | jquery question regarding text change | <pre><code><script type="text/javascript">
$(function () {
var text3;
$('.HideButton').click(function () {
text3 = $('#MessageText').text;
var theButton = $(this);
$('#disclaimer').slideToggle('slow', function () {
theButton.val($(this).is(':visible') ? 'Hide' : 'Show');
});
$('<p>' + text3 + '</p>').addClass("new").insertAfter('#disclaimer');
return false;
});
});
</code></pre>
<p>updated...code above doesnt change the buttons text</p>
<p></p>
<pre><code><p id="disclaimer" > DDDDDDDDDDDDDDDDDDDDDDDDDD</p>
<asp:Button ID="Button1" CssClass="HideButton" runat="server" Text="Hide" />
</code></pre>
<p>I want the text of the button to change each time i press on it..But it doesnt</p>
<pre><code><p id="disclaimer" >
<input id="MessageText" type="text" />
</p>
<asp:Button ID="Button21" CssClass="HideButton" runat="server" Text="Hide" />
</code></pre>
<p>As message typed in the textbox..it should appear while "#disclaimer disappear</p>
| javascript jquery asp.net | [3, 5, 9] |
1,199,175 | 1,199,176 | Adding 'type' attribute to a script tag loaded by a dll | <p>I have a menu control that is coming from a dll, I just need to reference it. Its old so the script tag that is <strong>injected</strong> into the page has the 'language' attribute. I looking for a way to add a 'type' attribute after the page has loaded.</p>
<p>I tried:</p>
<pre><code>$("script").attr("type", "text/javascript");
</code></pre>
<p>but it doesn't work ... any suggestions, or is it even possible?</p>
| javascript jquery | [3, 5] |
4,253,977 | 4,253,978 | Can't find what's wrong in this code | <p>I have the following script which brings up a dialog on my screen telling me there has been an error:</p>
<pre><code><script type="text/javascript">
var myFunc = function()
{
var html='<div class="cs-body">explanation of the error</div>';
$(html).csDialog();
return false;
};
</script>
</code></pre>
<p>I want this dialog to pop-up when my php script returns a "1" value for $error, like this:</p>
<pre><code>if ($error==1) {
echo "<script type='javascript'>$(document).ready(myFunc)</script>";
}
</code></pre>
<p>Even if I leave the if-clause and just echo the script it doensn't do anything. Can somebody tell me what I'm missing here?</p>
<p>Thanks in advance! </p>
| php javascript | [2, 3] |
4,400,749 | 4,400,750 | How to Find my website Visitor Region Code, IP and City Through simple javascript please no Google Analytics or other Software | <p>I want to Know how can i find Region of Visitor and IP adress through java script Region and City is on high priority these ones are not working</p>
<pre><code> <script type="text/javascript">
$(document).ready(function () {
$("#hdnCountryCode").val(geoip_country_code());
$("#hdnCountyName").val(geoip_country_name());
$("#hdnCity").val(geoip_city());
$("#hdnRegionCode").val(geoip_region());
$("#hdnRegion").val(geoip_region_name());
$("#hdnLatitude").val(geoip_latitude());
$("#hdnLongitude").val(geoip_longitude());
(function(){
$("#btnV").click();
return false;
});
});
</script>
</code></pre>
| javascript jquery | [3, 5] |
4,376,024 | 4,376,025 | how can i chain these functions so that when once completes, the next fires? | <p>If I have a div that I clear the contents of, but then want to put something new in it's place, how can I string these functions so that one only fires after the previous one completes</p>
<pre><code>$('#nner_container').fadeOut(300, function(){
$('#header_div').after('<div id="inner_container" style="dispay:none"></div>');
//when this insertion of inner_container completes, fill it with some content
//and when that completes, fadeIn inner_container
});
</code></pre>
<p>most jquery functions seem to take additional functions as a final parameter, which I thought was used for exactly this purpose. But not so with <code>after()</code>. Or am I doing something incorrect.</p>
<p>Thanks</p>
| javascript jquery | [3, 5] |
2,066,001 | 2,066,002 | setTimeout vs setInterval in javascript | <p>Hi can we change setInterval to setTimeout function, it is working fine I want to know can it is done with setTimeout</p>
<pre><code><head>
<script type="text/javascript">
$(function() {
var current = $('#counter').text();
var endvalue = 50
$('a').click(function() {
setInterval(function() {
if (current === endvalue) {
} else {
current++;
$('#counter').text(current)
}
}, 50)
})
})
</script>
</head>
<body>
<div id="counter">0</div>
<a href="#">Click</a>
</body>
</code></pre>
| javascript jquery | [3, 5] |
3,108,028 | 3,108,029 | how to update Sr. No. COLUMN after removing a TR from TABLE | <p>i have a table like </p>
<pre><code><table>
<tr>
<td>Sr. No.</td>
<td> Name</td>
<td>$nbsp;</td>
</tr>
<tr>
<td>1</td>
<td>abc</td>
<td>remove button</td>
</tr>
<tr>
<td>2</td>
<td>xyz</td>
<td>remove button</td>
</tr>
<tr>
<td>3</td>
<td>def</td>
<td>remove button</td>
</tr>
</code></pre>
<p></p>
<p>onclick of ' remove button ' i send ajax request & after successful response i remove the respective TR using $('#id_of_tr').remove();.</p>
<p>till here everything goes fine but now i want to update Sr. No.s of each row. Because Initially order is 1 2 3 , when i remove second row then it becames 1 3 which i want to update it to 1 2.</p>
<p>I hope this would help. </p>
| javascript jquery | [3, 5] |
2,723,478 | 2,723,479 | What does this expression of jquery mean $("div[id*='box']")? | <p>Does below expression mean it will give me all the div objects which have id containing the word box in it? </p>
<pre><code>$("div[id*='box']")
</code></pre>
| javascript jquery | [3, 5] |
1,573,176 | 1,573,177 | Illegal Character error in jQuery - regardless of function content | <p>First of all, I've done my research and I did find a bunch of simialr questions. However, I didn't find an answer that applies to my problem. All the examples I found were related to unescaped characters, single/double quote mishaps and the like. I on the other hand am getting this error on the following function:</p>
<pre><code>$('.seq_input').blur(function(){
//var id = $(this).data('id');
//var index = parseInt($(this).val()),
//element = $("#test-list li").eq(id).remove();
//$("#test-list li").eq(index - 1).before(element); // -1 because users like 1 based indices
alert('what?');
});
</code></pre>
<p>As you see I commented out everything and just left an alert, and I'm still getting the error, pointing to the last line of the function. It couldn't have anything to do with other functions because I just added this one alone at the end of my current Javascript.</p>
<p>Can someone please tell me what's going on here? Why on Earth would a function that just alerts something (or even if it doesn't do anything) give an error?</p>
<p>NOTE: error is shown as soon as the page is loaded</p>
| javascript jquery | [3, 5] |
5,152,365 | 5,152,366 | Search & Replace Whole HTML Strings with jQuery | <p>I'm having some trouble searching & replacing an entire string of HTML. </p>
<p>My example in this fiddle is me trying to replace an entire div tag with all of its classes & markup:</p>
<p><a href="http://jsfiddle.net/LqkNE/" rel="nofollow">http://jsfiddle.net/LqkNE/</a></p>
<p>As you can see, there are two little issues-- one with an ampersand that's causing me problems too.</p>
<p>Can someone help me out with what I'm doing wrong?</p>
| javascript jquery | [3, 5] |
3,689,151 | 3,689,152 | Choosing a plotting library for web/browser application | <p>I am looking for a plotting/graphing library (mostly to do line plots) for my application. I have been looking at JavaScript APIs (like Google's) but I found them to be slowing down things at client side (I am plotting a quite large number of points). I also found that with client-side libraries, the performance was quite varied depending on the user's computer. With moving to a server-side library I would cut down on this variance, and would have more control over data flow (my data is in a MySQL database).</p>
<p>I have then looked at some PHP-based plotting libraries, but a lot of them seem to be "forgotten" (no new version for years). I have been eying pChart, but it has not had an update in almost two years.</p>
<p>First, what would you recommend: server-side or client-side approach? </p>
<p>Second, what library would you recommend. Paid libraries are definitely an option, as I don't mind paying for quality software that would cut down on my development time.</p>
<p>Thanks,</p>
| php javascript | [2, 3] |
4,344,974 | 4,344,975 | Display a widget on an activity | <p>Does anyone know the Java to display a widget on an activity? I've came across a couple apps that have done this (i.e., <a href="https://play.google.com/store/apps/details?id=com.smart.taskbar&feature=search_result#?t=W251bGwsMSwxLDEsImNvbS5zbWFydC50YXNrYmFyIl0." rel="nofollow">Smart Taskbar</a>).</p>
| java android | [1, 4] |
5,872,289 | 5,872,290 | Passing a PHP variable to another page via jQuery | <p>EDIT: I can put the question in a shorter way that perhaps focuses more closely on the real problem:</p>
<p>Is there a way to keep PHP Sockets alive over multiple pages? That is, can I store the connection (the socket object) in any way?</p>
<p>I want to save a socket connection between two PHP pages where the other page is loaded via jQuery ajax. I tried it with sessions and so far got this on my main page:</p>
<pre><code>$sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
$res = socket_connect($sock, $host, $port);
session_start();
$_SESSION['sock'] = $sock;
</code></pre>
<p>I then load a page with jQuery:</p>
<pre><code>$("#" + in_name + "_holder").load("set_setpoint.php", {name:in_name, value:in_value});
</code></pre>
<p>And in set_setpoints.php:</p>
<pre><code>session_start();
require_once("sock_funcs.php");
echo $_SESSION['sock'];
</code></pre>
<p>I only get '0', but what I should get is something like "Resource id #xxx". Maybe sessions is the wrong way?</p>
| php jquery | [2, 5] |
2,416,629 | 2,416,630 | Arrange DIV in circle and rotate them facing outwards | <p>Basically I've managed to layout my DIV elements into a circle shape but I've not managed to work out how to calculate the deg of rotation need to have them face OUTWARD from the center of the circle.</p>
<pre><code>$(document).ready(function(){
var elems = document.getElementsByClassName('test_box');
var increase = Math.PI * 2 / elems.length;
var x = 0, y = 0, angle = 0;
for (var i = 0; i < elems.length; i++) {
var elem = elems[i];
// modify to change the radius and position of a circle
x = 400 * Math.cos(angle) + 700;
y = 400 * Math.sin(angle) + 700;
elem.style.position = 'absolute';
elem.style.left = x + 'px';
elem.style.top = y + 'px';
//need to work this part out
var rot = 45;
elem.style['-moz-transform'] = "rotate("+rot+"deg)";
elem.style.MozTransform = "rotate("+rot+"deg)";
elem.style['-webkit-transform'] = "rotate("+rot+"deg)";
elem.style['-o-transform'] = "rotate("+rot+"deg)";
elem.style['-ms-transform'] = "rotate("+rot+"deg)";
angle += increase;
console.log(angle);
}
});
</code></pre>
<p>does anyone have to knowledge on how I can do this.</p>
<p>Cheers -C</p>
| javascript jquery | [3, 5] |
1,949,013 | 1,949,014 | Sending text box values from my website to gmail to login into the gmail | <p>I have two text boxes in my webpage as username and submit button.</p>
<p>1)Firstly user needs to give username,password,then presses the submit button.</p>
<p>2)After pressing submit button,I want to send those username and password values to gmail website for logging into gmail..</p>
<p>3) Means,user will be logging into gmail without visiting gmail login page...</p>
| php javascript | [2, 3] |
5,319,644 | 5,319,645 | JQuery: Why is this Load More Functionality not working? | <p>Trying to implement a simple "load more" functionality with jquery. The idea is to use it in the same way as one does pages. Click and a certain number of posts loaded from the database show up.</p>
<p>I have the following javascript:</p>
<pre><code>$(function(){
var count = 0;
var num = 20;
$("#contents").load("posts.php");
$("#more").click(
function(){
var count = 0;
var num = 20;
$("#contents").load("posts.php");
$("#more").click(
function(){
$(".loading").show("fast");
count += num;
$.post("posts.php", {'page': count}, function(data){
$("#contents").append(data);
$(".loading").hide("slow");
});
}
);
</code></pre>
<p>and the following file posts.php</p>
<pre><code><?
echo "hello";
?>
</code></pre>
<p>And I have another file page.php with </p>
<pre><code> <div id="contents"></div>
<div class="loading"><span style="text-decoration: blink;">LOADING...!</span></div>
<button id="more">More..</button>
</code></pre>
<p>When i click the "More Button" though nothing happens even though I'm just trying to print out a simple hello world here. I have loaded the javascript in the head of the file like</p>
<pre><code><script type ="text/javascript" src ="javascript/load.js"></script>
</code></pre>
<p>Other javascript functionality I've implemented is working fine. Is there something to add to the "loading" or "contents" elements in page.php?</p>
| php javascript jquery | [2, 3, 5] |
701,596 | 701,597 | Need help on text expander jQuery plugin | <p>I am trying to use this text expander/collapse jQuery <a href="http://plugins.learningjquery.com/expander/demo/index.html" rel="nofollow">plugin</a> to only display first snippets of text, but if I load this in the page the whole text would show up first and then when the plugin is fully loaded in to the browser it would collapse down(I could visually see this process). Is there any technique that you can teach me so that only collapsed text would display first?</p>
<p>Here is the plugin I am trying to use:
<a href="http://plugins.learningjquery.com/expander/demo/index.html" rel="nofollow">http://plugins.learningjquery.com/expander/demo/index.html</a></p>
| javascript jquery | [3, 5] |
907,468 | 907,469 | HttpResponse returns a 502 Error, doesn't appear to hit endpoint | <p>I'm working on an application that uses HttpResponse for network calls. </p>
<p>Occasionally (about 30% of the time) network calls seem to fail with a 502 returning from the server. When checking the server logs, It appears that the server never received the request. </p>
<p>The logic doesn't seem bad, however, and it does work most of the time. I am communicating to the server via JSON.</p>
<pre><code>HttpClient client = new DefaultHttpClient();
HttpPost method = new HttpPost( BASE_URL + endpoint )
...add json entity
method.addHeader( "content-type", "application/json" );
method.addHeader( "accept", "application/json" );
</code></pre>
<p>....call below function w client/method</p>
<pre><code>protected HttpResponse invoke( HttpClient client, HttpUriRequest method ) throws ServiceException {
HttpResponse response = null;
try {
response = client.execute( method );
} catch ( //catch statements here ....)
int status = response.getStatusLine().getStatusCode();
//status = 502
}
</code></pre>
<p>The interesting thing about this call failing is that it's the exact same call across devices, and the server it's hitting is 20 feet away, although it does happen on a different server located in another state.</p>
<p>I can't see why it works sometimes but not others.</p>
| java android | [1, 4] |
3,883,233 | 3,883,234 | Looking for some information in getting Java to communicate with a website | <p>I was wondering if one could write a Java application and put it on a website and then have it running so that when a user used your website it could interact with some html/javascript page which would communicate with the Java program.</p>
<p>So basically, the html5 would be used to display the java program but all the logic and everything else would be server side in Java.</p>
<p>I don't want to use a java applet since it requires users getting a security warning and most browsers do not autorun a java application. I just think it would look cleaner and work nicer.</p>
<p>Does anyone know anything about this and could give me a little abstract just to point me in the right direction so I can learn more?</p>
<p>Thanks</p>
| java javascript | [1, 3] |
2,709,139 | 2,709,140 | Finding an item in a repeater control? | <p>This one might be simple, but here it is anyway.</p>
<p>I have a <code>List<Object></code> that I bind to a repeater. The repeater binds all of the fields to textboxes <strong><em>except <code>Id</code></em></strong>. In my web page, whenever a user adds a new item, I create a new <code>Object</code> in my list with a unique <code>Id</code> and rebind my repeater.</p>
<p>At a certain point in my code, I am trying to read the textbox controls from the repeater and put them into my <code>List<Object></code>. However, I need access to the <code>Id</code> field to know which List item to insert into. How can I get the specific <code>Id</code> while I'm going through the repeater?</p>
<p>I know I can just create a hidden field with the Id in the repeater control and get it that way, but is there a cleaner way to do this?</p>
<p>Example: </p>
<pre><code>if (DependentRptr.Items.Count > 0)
{
for (int count = 0; count < DependentRptr.Items.Count; count++)
{
int did = (form.UserId + (count + 1)); //I'm trying to get the id of this field here.
...get control info...
var temp = AddedDependents.ToList().Find(p => p.Id == did); //here is where I search with the id
}
}
</code></pre>
| c# asp.net | [0, 9] |
3,067,732 | 3,067,733 | DataSet.Relations in c#.net | <p>Hello Experts
I have a repeater and questions and answers table. For each Question there can be multiple answers.</p>
<p>I have radiobuttonlist in Gridview Control. On Row data bound event it will hit database multiple times based on question id to fetch answers.</p>
<p>how to use datarelations for this purpose.</p>
<p>Thank a lot</p>
| c# asp.net | [0, 9] |
3,494,827 | 3,494,828 | PHP Arrows, Java Equivalent | <p>I am just starting to research and learn PHP. I have a decent background in Java and I am trying to draw some correlations. One of the completely unfamiliar symbols I saw in PHP was the ?object access seperator? <code>-></code> as seen in this example: </p>
<pre><code> <?php
class SimpleClass
{
// property declaration
public $var = 'a default value';
// method declaration
public function displayVar() {
echo $this->var;
}
}
?>
</code></pre>
<p>From what I have researched, it appears that the object access separator is equivalent to the dot notation used in Java. Such as in the example:</p>
<pre><code>public class SimpleClass
{
// property declaration
public String val = "a default value";
// method declaration
public void displayVar()
{
System.out.println(this.val);
}
}
</code></pre>
<p>Is this a safe assumption to make? Are there additional uses of this operator?</p>
| java php | [1, 2] |
198,416 | 198,417 | Share sourcecode between android- and javaprojects | <p>There is a class, that compiles with the <code>android platform</code> and the <code>jdk</code>. Now, the idea is, to use that class in two projects, one is a android one and the other result in a java application.</p>
<p>So, I cretae a project with two modules, one for the android and one for the java solution. All works fine, with copy&paste the class-source between the two modules, but that is not very comfortable to use.</p>
<p>So, the question is, how it can be done without copy&paste. I would prefer a intellij solution, but I am willing to change to eclipse if needed.</p>
<p>Thanks for all answers.</p>
| java android | [1, 4] |
2,736,211 | 2,736,212 | define an array of input control in aspx.cs | <p>i have an input control of type file.</p>
<pre><code><input id="FileUpload1" type="file" runat="server" size="35" />
</code></pre>
<p>there are four input controls like this and in aspx.cs file i m trying to make an array of these ids..</p>
<p>i have made an array </p>
<pre><code>HtmlInputFile[] fl = new HtmlInputFile[4] { FileUpload1, FileUpload2, FileUpload3, FileUpload4 };
</code></pre>
<p>but it gives me an error..how can i get the value of these inputs.</p>
| c# asp.net | [0, 9] |
5,775,771 | 5,775,772 | How to enqueue callbacks before jQuery is loaded? | <p>I switched to using Require.JS in an app and immediately faced this problem:</p>
<p>I used to use inline JS to initiate certain calls once certain part of DOM is loaded. Now apparently jQuery loads only after those calls are executed, thus resulting in errors because jQuery ($) is undefined.</p>
<p>What's the best way to enqueue callbacks for jQuery before it's loaded? I need them to fire either immediately if jQuery is already loaded, or immediately once it's loaded.</p>
| javascript jquery | [3, 5] |
665,385 | 665,386 | Using JQuery how to check if any checkboxes are checked and then set the first to checked if none are? | <p>Using JQuery how to check if any checkboxes are checked and then set the first to checked if none are checked. </p>
<pre><code>var Checked = $('.ProductImageGallery').find(".DfaultCheckbox:selected);
if (Checked == null) { $('.DfaultCheckbox:first').attr('checked', true) }
</code></pre>
| javascript jquery | [3, 5] |
5,159,000 | 5,159,001 | A good performance alternative to PHP - String/File Manipulation | <p>I have a project that is done but needs better performance. </p>
<p>The gist of the project is that I'm taking XML and converting it to CSV files. The files represent data to be loaded into a Database.</p>
<p>Right now I'm using PHP to unzip the zip file that contains the XML. Then I parse, convert to CSV, and rezip. </p>
<p>It's been fine till now but the XML files are getting HUGE now. So much that processing takes a little more than a day. I'm also doing some manipulations in there somewhere to the files, like rearranging columns and trims.</p>
<p>What alternatives do you suggest that would help me improve performance? </p>
<p>I've thought about writing this parser in C++ but I'm not sure of what route to take. Similar questions have been asked but this is more of a performance issue I suppose. Should I switch languages for performance, stick with PHP and optimize that, should I try to make this parser parallel so more than one file can be done at a time?</p>
<p>What would you suggest?</p>
| php c++ | [2, 6] |
4,360,515 | 4,360,516 | pop up window close | <p>how to close the pop up window and focus to the main calling window of that pop up.</p>
| php javascript | [2, 3] |
323,792 | 323,793 | Parse a JavaScript file through PHP | <p>I have a JavaScript file where I would like to include some php code.
The problem is that I have a few defines on PHP that I would like to use on JS as well.</p>
<p>Is there any way of including a .js file in HTML allowing the server to first interpret it (before downloading to the client) using php?</p>
<p>Thanks :)</p>
| php javascript | [2, 3] |
5,145,497 | 5,145,498 | smart keyboard in jQuery | <p>SO I have need to develop online keyboard using jQuery or anything else that can help me achieve following.</p>
<ol>
<li>When I type any letter , it can check against bunch of words and keep only those Keys enable which are possible. </li>
</ol>
<p>For example. In my word collection I have word "Hello". When I type "H" on the keyboard...it should only keep "e" "l" "o" keys enabled and everything else should be disabled.</p>
<p>Is there a Name for such keyboards ? Any Examples would be appreciated. Currently I am planing to do this using jQuery and AJAX. I can keep my word collection on server and then do a look up on every kep press.</p>
<p>Ved</p>
| javascript jquery | [3, 5] |
5,311,198 | 5,311,199 | Using jquery to select an item from a select list based on the label | <p>So if I have a select list of lets say dates that looks like </p>
<pre><code><option value="624e70cb-2796-4029-bd09-2642abaa54b4">1989</option>
<option value="ff591d9a-e8a4-4280-829b-9307b7b41912">1988</option>
<option value="f2e9e756-7c59-4883-89b5-9c8cccf85ad6">1987</option>
<option value="c65d6a65-441f-4cb5-9e6d-d9de58efb060">1986</option>
<option value="27aa2cd0-f77a-48c0-83f3-5348d5a7239f">1985</option>
<option value="50e375c0-a1fa-405e-8ec9-a3f220041a39">1984</option>
</code></pre>
<p>if I have a string that holds the value 86 is there a good way to select:</p>
<pre><code><option value="c65d6a65-441f-4cb5-9e6d-d9de58efb060">1986</option>
</code></pre>
<p>with jquery?</p>
| javascript jquery | [3, 5] |
3,946,449 | 3,946,450 | How to input \t from asp.net | <p>I'm trying to input a control character from an asp.net form. For example I want a user to be able to enter \t into a text box and it be \t not \ \t (The space is there as one of them gets escaped if I put them together). What's the best way to go with this? I've been staring at it continuously now for quite a while and the answer isn't jumping out at me. Thanks.</p>
<p>Update:</p>
<p>Thanks guys, but I've just answered myself.</p>
<p>I've just found in Regex the static Unescape method, so in my web app I am now doing:</p>
<p>(Where tb is an asp.net TextBox)</p>
<pre><code> var inputText = tb.Text;
if (inputText.Length == 2)
{
var escaped = System.Text.RegularExpressions.Regex.Unescape(inputText);
if (escaped.Length == 1)
{
var character = escaped.ToCharArray()[0];
if (char.IsControl(character))
{
inputText = character.ToString();
}
}
}
</code></pre>
| c# asp.net | [0, 9] |
4,840,480 | 4,840,481 | Change javascript according to window width | <p>I think this is quite simple but after 2 days of trying I'm still clueless. Basically, I need to run one set of commands if the screen is over 767 pixels wide and another if the screen is under 767 pixels.</p>
<p>When the screen is wider than 767 pixels, I want to:</p>
<pre><code><script type="text/javascript">
var jsReady = false;//for flash/js communication
// FLASH EMBED PART
var flashvars = {};
var params = {};
params.quality = "high";
params.scale = "noscale";
params.salign = "tl";
params.wmode = "transparent";
params.bgcolor = "#111111";//change flash bg color here
params.devicefont = "false";
params.allowfullscreen = "true";
params.allowscriptaccess = "always";
var attributes = {};
attributes.id = "flashPreview";
swfobject.embedSWF("preview.swf", "flashPreview", "100%", "100%", "9.0.0", "expressInstall.swf", flashvars, params, attributes);
<!-- and much more code... -->
</script>
</code></pre>
<p>When the screen is narrower than 768 pixels, I want to run:</p>
<pre><code><script type="text/javascript">
jQuery(function($){
$.supersized({
//Background image
slides : [ { image : 'img/some_image.jpg' } ]
});
});
</script>
</code></pre>
<p>That's right... For desktops and tablets, I want to show a full-screen video background. For smaller screens (less than 767 pixels), I want to show a single still image background.</p>
| javascript jquery | [3, 5] |
3,385,482 | 3,385,483 | Displaying byte array as image using JavaScript | <p>I am trying to display an image (byte array) using purely JavaScript.</p>
<p>How can I achieve this in ASP?</p>
| javascript asp.net | [3, 9] |
2,436,223 | 2,436,224 | Handling array value in JS | <p>I have a problem with my arrays in JavaScript. I can't seem to get the value correctly.</p>
<p>I create my array in PHP like this:</p>
<pre><code>$data = Array();
$get = mysql_query("SELECT x,y,sid FROM table WHERE uid='1'");
while($row = mysql_fetch_assoc($get)){
$data[$row['x']] = Array();
$data[$row['x']][$row['y']] = $row['sid'];
}
$data = json_encode($row)
</code></pre>
<p>EDIT The json_encode comes out as "false" /EDIT</p>
<p>I then assigned this $data to a JS variable as sdata.</p>
<p>So then i try to get the value in JS but its not working. I get an undefined error.</p>
<p>This is my Javascript:</p>
<pre><code>var i = 1;
var j = 5;
if(sdata["x"] == i && sdata["y"] == j){
alert(sdata["x"]["y"]["sid"]);
}
</code></pre>
<p>Its meant to alert me the value of "sid" but i get:
Undefined </p>
<p>Any ideas where my mistake is?</p>
| php javascript | [2, 3] |
751,093 | 751,094 | progress bar(animated GIF image) when page loads or some background process is going on:: | <p>I want to have an animated GIF image to appear or load whenever my .aspx page (for my appln) is loaded or postaback or some background process is going on::</p>
<pre><code><div id="WaitDialog" style="left: 480px; top: 255px; position: absolute">
<img src="http://developers.sun.com/docs/web-app-guidelines/uispec4_0/progress_graphics/asynch-1F.gif" />
<FONT size=3 class="text3" ><font color="black">Loading, Please Wait.</font></FONT>
</div>
function ProgressBar()
{
var dialog = document.getElementById("WaitDialog");
dialog.style.visibility = 'hidden';
scrollTo(0,0);
}
</code></pre>
<p>........ this animated image should load just like as browser progress bar progresses and if I perform any validations in database (DB operations say), then also the image should load...</p>
<p>1) I'm not using AJAX for my application so I dont want AJAX to come into picture too... </p>
<p>2) the image should appear as when the page started loading... </p>
<p><strong>i.e.</strong> Something is goin in progress in tha background and the .gif image should load</p>
<p>How can i write the code accordin to tht as now i have a Javascript function ProgressBar() which i invoke by having onSubmit="ProgressBar()" in <em>body</em> tag.....</p>
<p>Can any1 help me in this ?</p>
| c# asp.net | [0, 9] |
966,185 | 966,186 | Random iexplore crashes when debugging (ASP.NET) | <p>I have a web application I am developing that seems to crash completely at random when clicking links on any page. When this happens, I'm told 'An unhandled win32 exception occured in iexplore.exe'. When I try to debug, it says one is already attached.</p>
<p>What could this be relating to? I know without code it will be hard, but this seems like a very strange error to occur at random.</p>
| c# asp.net | [0, 9] |
1,837,077 | 1,837,078 | Java Thread Message Passing | <p>I'm writing an Android app. I have a main method, which creates and runs a new Thread using an anonymous inner Runnable class. The run() method, when it's done, calls a method on it's parent class (in the main thread) that calls notifyDataSetChanged() so that the main thread can redraw the new data. This is causing all kinds of trouble (ViewRoot$CalledFromWrongThreadException).</p>
<p>The thing is, this method being called from the worker thread is on the class that's created in the UI thread. Shouldn't that be running on the UI thread? Or am I missing something?</p>
<p>Here's some code about what I'm talking about:</p>
<pre><code>public class Mealfire extends Activity {
@Override
public void onCreate(Bundle icicle) {
(new Thread() {
public void run() {
// Do a bunch of slow network stuff.
update();
}
}).start();
}
private void update() {
myAdapter.notifyDatasetChanged();
}
}
</code></pre>
| java android | [1, 4] |
4,292,341 | 4,292,342 | How to do Trim operation in javascript | <p>I need to trim a text that has been entered in a text box using Java Script
before saving it in DB in asp.net.</p>
<p>Thanks</p>
| javascript asp.net | [3, 9] |
5,551,513 | 5,551,514 | Android project using java and C++ together | <p>Anybody have one example of a android project using a same time C++ and Java together, for example, one normal android project build on eclipse and in there add a cpp class and using this cpp class on java class...</p>
<p>say I have a class Foo on C++</p>
<pre><code>class Foo{
...
}
</code></pre>
<p>and I have a class MyActivity on Java</p>
<pre><code>public class MyActivity extends Activity{
...
}
</code></pre>
<p>how to i instance the Foo class on MyActivity class?...</p>
<p>thanks a lot for all.</p>
| java android c++ | [1, 4, 6] |
2,698,400 | 2,698,401 | jquery addClass doesn't work | <p>the jquery</p>
<pre><code>$(document).on('click', '#fun', function (e) {
var $this = $(this);
var request = $.ajax({
url: "example.php",
type: "POST",
data: {bla: blabla},
dataType: "html"
});
request.done(function(msg) {
if(msg)
{
$this.addClass("btn btn-info btn-small marked");
$("#isMarked", $this).val(msg)
}
else if(!msg)
{
$this.addClass("btn btn-small unmarked");
$("#isMarked", $this).val(msg);
}
});
</code></pre>
<p>and the button</p>
<pre><code><a id='fun' class='btn btn-info btn-small marked' href='#'>fun</a>
</code></pre>
<p>example.php will return a value either 0 or 1 (indicate true or false)
so the msg will be 0 or 1</p>
<p>the addClass in else if(!msg) can't works. I can't find the problem. any idea?</p>
| javascript jquery | [3, 5] |
2,934,563 | 2,934,564 | Play audio and Redirect to page after some time | <p>I am working on a project,I have to implement a functionality that on page load I have to play an audio file and while playing after some seconds redirect to some other page. I have used tag and it's onplaying event,but its not working. Can any one suggest any alternative?Its not even hitting the function and showing no error in console
Below is my code</p>
<pre><code><embed src="contents/MP3/abc.mp3" height="0"
width="0" autostart="TRUE" onplaying="return RedirecttoSite();"></embed>
function RedirecttoSite() {
setTimeout(window.location.href = "/Default.aspx", 1000);
}
</code></pre>
<p>What should be altenate solution to achieve this</p>
| javascript asp.net | [3, 9] |
3,626,147 | 3,626,148 | Jquery to modify all anchor tag href on a page and extract key request parameters from href attribute | <p>hi i need to replace all the href's in my page by a onclick event which has few of the parameters from the query string </p>
<p>here is a sample anchor tag</p>
<pre><code><a href="google.com?businessunit=Products&dataSegement=BOTH_PERIOD&endDate=12%2F06%2F2011&d-49489-s=8&d-49489-p=1&d-49489-o=2&catid=3">Demo Anchor</a>
</code></pre>
<p>another sample</p>
<pre><code><a href="google.com?businessunit=Products&dataSegement=BOTH_PERIOD&pubgrpid=6&endDate=12%2F06%2F2011&d-49489-s=8&d-49489-p=1&d-49489-o=2&marketid=1analysisType=conversion&catid=3">Another sample</a>
</code></pre>
<p>i need to extract the values of d-49489-s, d-49489-p, d- 49489-o and
change anchor tag to something like </p>
<pre><code> <a href="#" onclick="callMethod(d-49489-s,d-49489-p, d-49489-o )">
</code></pre>
| javascript jquery | [3, 5] |
1,667,936 | 1,667,937 | How can i stop this countdown on mouseleave? | <p>Here is the code:</p>
<pre><code>//Mouseover start countdown
$("#icon_no_1").mouseover(function()
{
$(this).fadeTo("slow", 0.23);
//Countdown
var counter = 0;
var interval = setInterval(function() {
counter++;
// Display 'counter' wherever you want to display it.
if (counter == 1) {
//Display 1
$('#login_icon_1').fadeIn();
//Fade in
}
if (counter == 2) {
//Display 2
$('#login_icon_1').fadeOut(750);
//Fade in login icon 2
$('#login_icon_2').fadeIn();
}
if (counter == 3) {
//Display 3
//Display 2
$('#login_icon_2').fadeOut(500);
//Fade in login icon 2
$('#login_icon_3').fadeIn();
}
if (counter == 4) {
//Display 4
//Display 2
$('#login_icon_3').fadeOut(500);
//Fade in login icon 2
$('#login_icon_4').fadeIn();
}
if (counter == 5) {
//Display 2
$('#login_icon_4').fadeOut(500);
//Fade in login icon 2
$('#login_icon_5').fadeIn();
//Display 2
$('#login_icon_5').fadeOut(1000);
}
if (counter == 6) {
counter = 7;
window.location.replace("/wahalu/index.php/login_advisor.php");
}
}, 1000);
}
);
$("#icon_no_1").mouseleave(function()
{
counter = 0;
$(this).fadeTo("slow", 1);
$('#login_icon_1').hide();
$('#login_icon_2').hide();
$('#login_icon_3').hide();
$('#login_icon_4').hide();
$('#login_icon_5').hide();
}
);
});
</code></pre>
| javascript jquery | [3, 5] |
5,218,698 | 5,218,699 | Referencing javascript libraries locally or externally? | <p>We are currently developing an ASP.NET MVC application which will be deployed on a corporate intranet, with a slightly-modified customer facing version available on the public internet.</p>
<p>We're making use of a number of external javascript libraries (e.g. jQuery) and a discussion has come up regarding referencing the libraries - should we reference them from an external source (e.g. via the Google load jQuery method) or keep our own version locally and reference from there?</p>
<p>The project manager is a little concerned about having a 'dependency' on Google (or whoever) if we reference from there, and thinks that having our own copy of the library makes us more independent. On the other hand, I have heard there are a number of advantages to letting someone else host the library - for example, they handle versioning for us, Google aren't going anywhere anytime soon...</p>
<p>(for the purpose of the discussion assume the intranet we're hosting on has external access - obviously if it turns out it doesn't the decision is very much made for us!)</p>
<p>So. Does this matter? And if so, what should we do and why?</p>
<p>(I appreciate this is subjective - but it would be very useful to get advice from anyone with experience or thoughts on the matter. Not sure if this is a candidate for community wiki or not, let me know if I should have put it there and I'll know for future!)</p>
<p>Thanks :)</p>
| javascript asp.net jquery | [3, 9, 5] |
2,424,218 | 2,424,219 | Periodically autosave form | <p>How to implement a periodical save of a form in the background? Same kinda thing that gmail does. </p>
| javascript jquery | [3, 5] |
5,582,529 | 5,582,530 | Retrieve the position of a clicked button? | <p>Well, everything is on the question. I have a clickEvent on one of my button and i want to retrieve the position of this button when i click on it.</p>
<p>Actually i retrieve the position event.pageX but it's not really what i want...</p>
<pre><code><script type=text/javascript>
$( "#dM1").click( function(event) {
dropMenu('dropMenu1', event.pageX);
});
</script>
</code></pre>
| javascript jquery | [3, 5] |
5,497,055 | 5,497,056 | login to google with http POST | <p>Think google have a limitation for user , so users have to login to download a file , I want to login to a site like google with http post and after that download a file .</p>
<p>how to login to site like google with http POST ? </p>
| c# asp.net | [0, 9] |
5,040,728 | 5,040,729 | Jump to an anchor link on function complete in jQuery? | <p>I have a simple slidetoggle function that opens onclick. What I'd like to do is jump the user down to the bottom of the page following the opened div. Basically, wait for the slidetoggle to complete - then imagine clicking my jump link to pull the viewport down. Here's my code.</p>
<pre><code> $('#clickme').click(function() {
$('#form-area').slideToggle('slow', function() {
// Animation complete
// what can i put here that's like my standard jumpto?
});
});
<a href="#form-bottom" id="clickme">Click here</a>
<div class="main" id="form-area" >
Stuff
</div>
<a name="form-bottom"></a>
</code></pre>
| javascript jquery | [3, 5] |
3,717,747 | 3,717,748 | jquery listening to events | <p>I have a function A that does something (calls a web service in ajax request) and I have another function that is plugged in a calendar and that triggers on different events (click on day changes date, click on month changes calendar month... pretty typical calendar stuff).</p>
<p>The calendar works with classes: when the user clicks on a day item, the function that handles this event first determines the attr('id') of the calendar that fired this event and then works on the calendar with this ID. There could be several calendars on the same page. When the user clicks on a date on a certain calendar, I want function A to execute. I could simply call function A from the calendar click functions by hard-coding the ID of the calendar and if the function executes on calendar ID xyz then do the regular things AND also call function A.</p>
<p>In general terms, what I want to do is create a jquery event listener that calls function A when a certain event is raised on one of my calendars. Something "listen to this function being executed on calendar xyz and when you hear something, call function A". How do you setup an event listener like this in jquery?</p>
<p>Thanks for your suggestions.</p>
| javascript jquery | [3, 5] |
801,106 | 801,107 | How to set datasource of listbox from generic list of class | <p>How can I bind List to the datasource of a Listbox? I want to to set the visible property Name.</p>
<p>Here is my class and list:</p>
<pre><code> public class Users
{
public string Name { get; set; }
public DateTime Data { get; set; }
public int Id { get; set; }
public Users()
{
Name = null;
Data = DateTime.Now;
Id = 0;
}
public Users(string N,DateTime dateTime, int id)
{
Name = N;
Data = dateTime;
Id = id;
}
}
</code></pre>
<p>Here is how I try to bound the datasource:</p>
<pre><code> ListBox1.DataSource = ((List<Users>) Application["Users_On"]);
ListBox1.DataBind();
</code></pre>
| c# asp.net | [0, 9] |
4,390,072 | 4,390,073 | Adding an input name upon creation of new table row | <p>I have an order form I had put together for a client, you can view it <a href="http://www.tdidesign.com/designerorderform.php" rel="nofollow">here</a>.</p>
<p>As you can see it creates a new row with 5 input fields (per row). Here's my problem, I have this form outputting the form in html format to the clients email for office use. I need to add a "unique name" for each input in the newly created row in order to pass that to the processing and out to the email.</p>
<p><a href="http://www.tdidesign.com/js/jquery.tables.js" rel="nofollow">Here is the JS file for adding rows</a></p>
<p>I know this has to be triggered by the $addRowBtn but I have been at this for awhile now and everything I have tried has just broken the form.</p>
<p>I've tried this example but to no avail:</p>
<pre><code>thisRow.find("input.ClassName").attr("name","newName" + num);
num++;</code></pre>
<p>I will buy the first person that helps with this a cup of coffee or something! It's bugging the ever living crap out of me!!</p>
| javascript jquery | [3, 5] |
2,221,692 | 2,221,693 | JQuery/Javascript Reordering rows | <p>I have a aspx page that looks something like this:</p>
<pre><code><tr id="Row1">
<td>Some label</td>
<td>Some complex control</td>
</tr>
<tr id="Row2">
<td>Some label</td>
<td>Some complex control</td>
</tr>
<tr id="Row3">
<td>Some label</td>
<td>Some complex control</td>
</tr>
</code></pre>
<p>As soon as the page is loaded, I would want to reorder these rows based on the user's previously selected order (stored in a database)</p>
<p>How would I use JQuery/JS to accomplish this?</p>
<p>EDIT:</p>
<p>I have run into a performance issue with the appendTo code. It takes 400ms for a table of 10 rows which is really unacceptable. Can anyone help me tweak it for performance?</p>
<pre><code>function RearrangeTable(csvOrder, tableId)
{
var arrCSVOrder = csvOrder.split(',');
//No need to rearrange if array length is 1
if (arrCSVOrder.length > 1)
{
for (var i = 0; i < arrCSVOrder.length; i++)
{
$('#' + tableId).find('[fieldname = ' + arrCSVOrder[i] + ']').eq(0).parents('tr').eq(0).appendTo('#' + tableId);
}
}
}
</code></pre>
| javascript jquery | [3, 5] |
5,149,123 | 5,149,124 | Jquery plugin for sticking a few table rows at the top of the page when scrolling? | <p>Can anyone recommend a jquery plugin that would allow you to stick a few rows at the top of the page</p>
<p>i.e. page loads, the content is in the right place, then once the content reaches the top of the page it gets fixed in place while the user scrolls...then if they scroll back up the content will go back to it's original place?</p>
<p>The content in question, would be a few TR elements. </p>
<p>I tried a few, but all the ones I tried had major issues, so I'm wondering if you could recommend a few more options for me? thanks</p>
| javascript jquery | [3, 5] |
290,406 | 290,407 | How To Pass PHP Variables On jQuery Load? | <p>I have code like this :</p>
<pre><code><?php
$username = 'johndoe';
?>
<head>
<script>
...
$('a.manage-content-link').click(function (e) {
var self = $(this),
file = self.siblings('input[type="hidden.block-hidden-input"]').val();
self.next(".manage-content-wrap").find(".manage-content").load("file-" + file + ".php");
e.preventDefault();
});
...
</script>
</head>
<body>
...
<li><input type="hidden" value="001" class="block-hidden-input" />
<a href="#" id="manage-1" class="manage-content-link">
<img src="images/web-block/web-block1.jpg"/>
<span class="orange-notice">Click to Edit Content</span>
</a>
</li>
<li><input type="hidden" value="002" class="block-hidden-input" />
<a href="#" id="manage-2" class="manage-content-link">
<img src="images/web-block/web-block2.jpg"/>
<span class="orange-notice">Click to Edit Content</span>
</a>
</li>
...
</body>
</code></pre>
<p>as you can see there, every time user click "manage-content-link" class, either manage-1, manage-2, ... or even manage-X (multiple li tags) jQuery will load "file-XXX.php". which XXX is actually value of hidden input in li tag.</p>
<p>but that "file-XXX.php" requires $username from PHP tags and ID itself, that is "manage-X". how to pass this 2 variables needed by "file-XXX.php", one from PHP and other from ID's?</p>
| php jquery | [2, 5] |
5,540,925 | 5,540,926 | How to declare a global static class in Java? | <p>In C# I am able to create a class like this:</p>
<pre><code>static class clsDBUtils
{
public static SQLiteCommand cmd;
public static SQLiteConnection conn;
public static String databaseFilePath;
public static bool getConnection()
{
}
}
</code></pre>
<p>Then anywhere in my namespace can use without initialization this way:</p>
<pre><code>clsDBUtils.getConnection();
</code></pre>
<p>How can this be rewritten for Java?</p>
<p>I don't want to use:</p>
<pre><code>clsDBUtils sqlutil= new clsDBUtils();
</code></pre>
| c# java | [0, 1] |
4,306,461 | 4,306,462 | Dissect my jQuery - can't use keyup function to insert number of characters into another textarea | <p>I'm trying to figure out why my jQuery isn't working. I've got jQuery linked to, and then after that, I try to bind to the textarea content. I've used name=content and name=#content both.</p>
<pre><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript">
$('input[name=content]').bind('keyup',function(){
$('#desctag').val($(this).length)
});
</script>
</code></pre>
<p>Why isn't it working?</p>
<p>Code is now:</p>
<pre><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('input[name=#content]').bind('keyup',function(){
$('#desctag').val($(this).length)
})})
</script>
</code></pre>
| javascript jquery | [3, 5] |
3,786,863 | 3,786,864 | how make the animation runs in a infinite loop | <p>i have the current code running</p>
<p><a href="http://jsfiddle.net/Qchmqs/SxTgy/" rel="nofollow">MyTry</a></p>
<p>what i want to do is to make the animation go in a infinite loop how to do ??</p>
<p>i want to call the same function again or i don't know what </p>
<p>just that the animation go again and again when finished the last element</p>
<pre><code>(function($) {
$.fn.fade = function() {
return this.each(function(index, item) {
var $this = $(this).siblings();
$(item).hide().stop();
if ($(item).index() == $(this).siblings().length - 1) {
$(item).delay(5000 * index).fadeIn('slow').delay(3500).fadeOut('slow', function() {
/* here is the last element finishing */
});
} else {
$(item).delay(5000 * index).fadeIn('slow').delay(3500).fadeOut('slow');
}
});
};
})(jQuery);
$('.tst').fade();
</code></pre>
<p>EDIT : i left the animation running and came to check for answers
so i saw a strange behavior </p>
<p>how to fix that as well</p>
| javascript jquery | [3, 5] |
4,957,741 | 4,957,742 | c# - Simple User Class Assignment | <p>this is a newbie question, i am trying to build a class in C# that is going to set the user org property for a user (each user can have more than 1)</p>
<p>i have this thus far:</p>
<pre><code>using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;
using System.Data;
/// <summary>
/// Summary description for clsRepUser
/// </summary>
public class clsUser
{
private string userid;
private List<string> userorgs;
public string UserID
{
get
{
return userid;
}
set
{
userid = value;
}
}
public List<string> UserOrgs
{
get
{
return userorgs;
}
set
{
userorgs = value;
}
}
clsConn cCon = new clsConn();
String connStr = "";
public clsUser()
{
}
public DataSet GetUserOrg(string UserID)
{
DataSet ds = new DataSet();
SqlConnection conn = new SqlConnection(cCon.getConn());
SqlCommand cmd = new SqlCommand("sp_getUserOrgs", conn);
// 2. set the command object so it knows
// to execute a stored procedure
cmd.CommandType = CommandType.StoredProcedure;
// 3. add parameter to command, which
// will be passed to the stored procedure
cmd.Parameters.Add(
new SqlParameter("@UserID", UserID));
try {
// Open the connection and execute the Command
conn.Open();
SqlDataAdapter sqlDA = new SqlDataAdapter();
sqlDA.SelectCommand = cmd;
sqlDA.Fill(ds);
}
catch (Exception ex) {
}
finally {
conn.Close();
}
return ds;
}
}
</code></pre>
<p>how do i now populate the userorgs property of that user from the GetUserOrg function? or am i way off on this?</p>
| c# asp.net | [0, 9] |
263,764 | 263,765 | JavaScript/jQuery: Running DOM commands *after* img.onload commands | <p>I need to get the width & height of a CSS background image and inject it into document.ready javascript. Something like:</p>
<pre><code>$(document).ready(function(){
img = new Image();
img.src = "images/tester.jpg";
$('body').css('background', 'url(' + img.src + ')');
$('body').css('background-size', img.width + 'px' + img.height + 'px');
});
</code></pre>
<p>The problem is, the image width and height aren't loaded in at the time of document.ready, so the values are blank. (They're accessible from console, but not before). </p>
<p><code>img.onload = function() { ... }</code> retrieves the width and height, but DOM <code>$(element)</code> calls aren't accessible from within img.onload.</p>
<p>In short, I'm a little rusty on my javascript, and can't figure out how to sync image params into the DOM. Any help appreciated</p>
<p>EDIT: jQuery version is 1.4.4, cannot be updated.</p>
| javascript jquery | [3, 5] |
4,582,966 | 4,582,967 | Toggle effect not working | <p>hello friends i want to use toggle on <code><li></code> when one <code><li></code> is open i want rest <code><li></code> get close i have tried this <a href="http://jsfiddle.net/MbTRD/1/" rel="nofollow">http://jsfiddle.net/MbTRD/1/</a> but its not working as i want</p>
<pre><code> $(function () {
$(".flyout").hide();
$(".flyout").siblings("span").click(function () {
$(this).siblings(".flyout").toggle(500);
});
});
</code></pre>
<p>Please help thanks </p>
| javascript jquery | [3, 5] |
3,758,266 | 3,758,267 | Can someone explain the following javascript code? | <p>In addition to the explanation, what does the $ mean in javascript? Here is the code:</p>
<pre><code>var ZebraTable = {
bgcolor: '',
classname: '',
stripe: function(el) {
if (!$(el)) return;
var rows = $(el).getElementsByTagName('tr');
for (var i=1,len=rows.length;i<len;i++) {
if (i % 2 == 0) rows[i].className = 'alt';
Event.add(rows[i],'mouseover',function() {
ZebraTable.mouseover(this); });
Event.add(rows[i],'mouseout',function() { ZebraTable.mouseout(this); });
}
},
mouseover: function(row) {
this.bgcolor = row.style.backgroundColor;
this.classname = row.className;
addClassName(row,'over');
},
mouseout: function(row) {
removeClassName(row,'over');
addClassName(row,this.classname);
row.style.backgroundColor = this.bgcolor;
}
}
window.onload = function() {
ZebraTable.stripe('mytable');
}
</code></pre>
<p>Here is a link to where I got the code and you can view a demo on the page. It does not appear to be using any framework. I was actually going through a JQuery tutorial that took this code and used JQuery on it to do the table striping. Here is the link:</p>
<p><a href="http://v3.thewatchmakerproject.com/journal/309/stripe-your-tables-the-oo-way" rel="nofollow">http://v3.thewatchmakerproject.com/journal/309/stripe-your-tables-the-oo-way</a></p>
| javascript jquery | [3, 5] |
3,649,948 | 3,649,949 | Camel casing acronyms? | <p>This question may seem pedantic or just silly, but what is your practice for camel casing when it comes to acronyms? Do you insist that everything, even acronyms must be camel cased, or do you make an exception for acronyms. Explanations would be great too. I'm not sure how this practice effects IDE features (autocomplete) or what the industry standard are.</p>
| c# java | [0, 1] |
3,828,944 | 3,828,945 | jQuery conditional logic with multiple classes | <p>I have many articles which have multiple categories. I have a checkbox for every category. When a checkbox is checked the articles with this category should be shown, otherwise should be hidden.</p>
<p>So far so good.</p>
<p>When I check category 1, but not category 2 all posts should be shown which have category 1. If they have category 2 too they should be shown anyway.</p>
<pre><code><input type="checkbox" value="cat1" id="checkbox1" checked />
<input type="checkbox" value="cat2" id="checkbox2" checked />
<input type="checkbox" value="cat3" id="checkbox3" checked />
<input type="checkbox" value="cat4" id="checkbox4" checked />
</code></pre>
<p>I use jQuery to show and hide the posts</p>
<pre><code>if ($('#checkbox1').is(':checked')) {
$("article.category1").show();
} else {
$("article.category1").hide();
}
if ($('#checkbox2').is(':checked')) {
$("article.category2").show();
} else {
$("article.category2").hide();
}
if ($('#checkbox3').is(':checked')) {
$("article.category3").show();
} else {
$("article.category3").hide();
}
if ($('#checkbox4').is(':checked')) {
$("article.category4").show();
} else {
$("article.category4").hide();
}
</code></pre>
<p>I created a js fiddle for this
<a href="http://jsfiddle.net/oliverspies/t8qHT/1/" rel="nofollow">http://jsfiddle.net/oliverspies/t8qHT/1/</a></p>
<p>If you uncheck all, but check the first checkbox, no entries are shown - but all entries with the class cat1 should be shown - even if they have another category which is unchecked.
How can I do this without writing tens of IF statements?</p>
| javascript jquery | [3, 5] |
4,922,622 | 4,922,623 | fire css change before end of code | <p>I'm sure this question has already been asked, but I can't found the good keyword to feed google with. I can't even find a good title for my question.
I want to do this :</p>
<pre><code>$(".selector").click(function() {
$(this).css("background-color", "red");
if (confirm("Do you want to do this ?") {
// do this
} else {
$(this).css("background-color", "transparent");
}
});
</code></pre>
<p>But the css change is fired only after I confirm. How can I fire it before the confirm (or during the confirm) ?</p>
<p>Thanks.</p>
| javascript jquery | [3, 5] |
2,167,582 | 2,167,583 | Call function if two arrays are identical with jQuery | <p>I have a quick question regarding using jQuery to compare 2 arrays. I have two arrays, and I need to call a function only if they are exactly identical (same size, elements, order).</p>
<p>For example, given these two arrays:</p>
<pre><code>a['zero','one','two','three','four','five','six','seven', 'eight','nine'];
b['zero','one','two','three','four','five','six','seven', 'eight','nine'];
</code></pre>
<p>If these two are arrays are identical and in the same order, do:</p>
<pre><code>do function{};
</code></pre>
| javascript jquery | [3, 5] |
1,209,140 | 1,209,141 | What causes a 40 second delay when running an executable using Process.Start()? | <p>I'm running an executable on the local file system using Process.Start() from an ASP.NET web application. This runs correctly and does what I expect it to, the problem is that it takes around 40 seconds before the exe starts after Process.Start() has been called.</p>
<p>When I run the exe from the command line it only takes a few seconds to complete its work.</p>
<p>Does anyone know what is causing this long delay when I use Process.Start()?</p>
<p>Thanks in advance!</p>
<p>Robert</p>
| c# asp.net | [0, 9] |
1,630,996 | 1,630,997 | Text box content rendering in a new window using javascript | <p>I have a asp.net textbox(textarea which is in a repeater have single texarea for each record which are read only) I have button (open in new window) when i click on it the content of the text area needs to be rendered in a new window using javascript .
similar to experts exchange.</p>
| c# asp.net javascript | [0, 9, 3] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.