Unnamed: 0
int64
302
6.03M
Id
int64
303
6.03M
Title
stringlengths
12
149
input
stringlengths
25
3.08k
output
stringclasses
181 values
Tag_Number
stringclasses
181 values
5,419,500
5,419,501
Intent.getIntExtra() behaviour changes on a virtual device and on a real device
<p>I have the below code and on my computer via Eclipse virtual device it works fine. But when installed on a real life phone it always reverts to the else statement. This activity does not always get passed a value and if it is not I want a random record to appear. Thank you for any help or advice and time taken to read.</p> <pre><code> searchId = getIntent().getIntExtra("EMPLOYEE_ID", 0); if(searchId &gt; 0){ Query="SELECT * FROM " + DB_TABLE +" ORDER BY RANDOM() LIMIT 1"; Log.v("STANDARD RANDOM", "Was run"); } else{ Query ="SELECT * FROM " + DB_TABLE +" WHERE _id=" + searchId + ""; Log.v("FROM SEARCH PAGE", "Was run"); } </code></pre>
java android
[1, 4]
1,045,262
1,045,263
jquery, how to use trigger?
<p>i have this situation:</p> <pre><code>if(isset($_POST["sm"]){ print "&lt;br&gt;&lt;div id=\"redirect\"&gt;success&lt;/div&gt;"; } </code></pre> <p>in javascript i have:</p> <pre><code>$('#redirect').delay(2000).fadeOut('slow'); </code></pre> <p>what happens is that if the form is submitted that div shows up for two seconds then faced out, but i also want to trigger a click by using: <code>$('#test').trigger('click');</code></p> <p>how can i connect them together so that when the div shows i also trigger the click.</p> <p>also i cant use javascript inside the php if statement</p> <p>any ideas?</p> <p>thanks</p>
php jquery
[2, 5]
4,928,363
4,928,364
"document.formName" is undefined?
<p>I've got an ASP.NET site running locally on my XP system using IIS Express. There is a live version of the site running on a Windows server. </p> <p>In the web pages, often the Javascript will reference a form on the page using the style <code>document.formName</code>, where <code>formName</code> is the name of the form. As far as I know, this is a cross-browser method, along with <code>document.forms.formName</code> and <code>document.forms[0]</code> and so forth.</p> <p>On my local development site, the reference <code>document.frm1</code> (I know, bad naming practice) errors out; it is undefined. On the other hand, <code>document.forms.frm1</code> works fine. Strangely, this doesn't occur on the server, although both pages are identical as far as the code goes. I've double checked with Firebug, and in both IE8 and Firefox 6.</p> <p>Another weird part: checking with Firebug, <code>document.frm1</code> is undefined, but <code>document.frmClose</code> (another form) exists! Huh?!</p> <p>Anyone experienced this before?</p>
javascript asp.net
[3, 9]
3,764,658
3,764,659
How to use the client side(JS) variable in c#?
<p>I have the following JS code.</p> <pre><code>var thisItem = document.thisItem; var e-mail = thisItem.getProperty("email");// which gets the e-mail of the User </code></pre> <p>And I have the following C# code.</p> <pre><code>public static void Main() { string username = "username"; string email = ""; //code to send a mail to the user } </code></pre> <p>In JS code I' m using applyMethod("CSProgramName"); to run the C# from client side. Here I want to use the Javascript 'e-mail' variable in C# code. How Can I do this? </p>
c# javascript
[0, 3]
171,771
171,772
Open clicked thumbnail in a new tab
<p>I have the below code on one page:</p> <pre><code>&lt;div id="prodoneid" class="prodcls"&gt; &lt;a href="javascript:void(changeIt('big.png', 'pagewrapid')());"&gt; &lt;img src="images/zara/thumbnails/1.png" alt="ZARA"/&gt; &lt;/a&gt; &lt;/div&gt; </code></pre> <p>By the below code I am opening the image in a new window. The new page is opening but is not showing the image in the div.</p> <pre><code>var changeIt, img; changeIt = function(imageName, objName) { img = '&lt;img src="images/zara/' + imageName + '"&gt;'; newwindow = window.open( 'fprod.html', target="_blank" ); document.getElementById(objName).innerHTML = img; setTimeout('newwindow.document.getElementById("pagewrapid").innerHTML=img',0) }; </code></pre>
javascript jquery
[3, 5]
2,924,835
2,924,836
Background Process without UI - android
<p>I have an application Android and I need update the data without UI (Background Process) I haven't idea about it</p> <p>Help me</p>
java android
[1, 4]
821,990
821,991
How do i get middle tab selected on click on a linkbutton in asp.net
<p>I am working in an application in which there is a linkbutton inbox, when user clicks on it "default.aspx" page opens with 1st tab selected but i required that in case of inbox clicked middle tab must be selected and shows opened.when user not clicks on inbox "default.aspx" 's page 1st tab must be selected.Click event code is</p> <pre><code>protected void btnInbox_Click(object sender, EventArgs e) { Response.Redirect("default.aspx"); } </code></pre>
c# asp.net
[0, 9]
2,671,181
2,671,182
ASP.NET Multiple Field Validation
<p>In ASP.NET 2, I've used Field Validators, and RequiredField validators, but I'm unsure of how to handle a case like this. <br> I have two check boxes on a page, and I need to be sure that at least one of them is set. So, if you look at in binary, it can be 01, 10 or 11, but it can not be 00. My question is, what the best way to do this with checkboxes?</p> <p><p> Can the normal ASP Validators handle this, or would I need to create an integer value like mentioned above, hidden somewhere and use a RangeValidator do a test to make sure THAT value is never zero?</p>
c# asp.net
[0, 9]
5,454,237
5,454,238
Put GridView in Edit Mode Programmatically with ASP MERMERSHIP
<p>I need Put GridView in Edit Mode Programmatically when editing ROLES in ASP MERMERSHIP. Could you provide me some examples? I am not able to write the appropriate EVENTS to display the right EDIT TEMPLATE.</p> <p>Thanks</p>
c# asp.net
[0, 9]
4,786,857
4,786,858
jQuery to prepend URL in img src attribute
<p>I just need a jQuery snippet to do the prepend in img src , i.e</p> <pre><code>&lt;img src='/img/picture1.jpg' /&gt; </code></pre> <p>The code snippet jQuery is to prepend this url</p> <pre><code>http://cdn.something.com/ </code></pre> <p>so after the snippet jQuery, it becomes like </p> <pre><code>&lt;img src='http://cdn.something.com/img/picture1.jpg' /&gt; </code></pre> <p>Any help is greatly appreciated.</p> <p>so far I wrote something like</p> <pre><code>$().ready(function(){ var cdn ='http://cdn.something.com'; $('img').attrib('src', cdn); </code></pre> <p>});</p> <p>However it is replaced the src rather than pre</p>
javascript jquery
[3, 5]
2,007,806
2,007,807
How to get innerhtml value in mozilla
<p>I have below html code </p> <pre><code>&lt;div id="divTest"&gt; Hello &lt;input type="text" id="txtID" value="" /&gt; &lt;input type="button" onclick="getForm();" value="Click" /&gt; &lt;/div&gt; </code></pre> <p>And I have below javascript function to get innerHtml value</p> <pre><code> &lt;script language="javascript" type="text/javascript"&gt; function getForm() { var obj = document.getElementById('divTest'); alert(obj.innerHTML); } &lt;/script&gt; </code></pre> <p>I am trying to get the complete innerHtml value. When user put some value in <strong>"txtId"</strong> and when he clicks on button it should show all the innerHtml with <strong>txtId</strong> value in it. It is working fine in Internet Explorer but failing in Mozilla.</p> <p>Please suggest what type of changes I need to do in javascript function or I need some Jquery for this.</p> <p>Thanks.</p> <p>Best Regards,</p>
javascript jquery
[3, 5]
2,908,996
2,908,997
How to translate java "?" operator in C#?
<p>I would like to know the translation of this java code in C#</p> <pre><code>n = (length &gt; 0) ? Math.min(length, buffer.length) : buffer.length;//Java code </code></pre> <p>Can it be equivalent to this in C# ?</p> <pre><code>if(length &gt;0) { n = Math.min(length, buffer.length); } else { n = buffer.length; } </code></pre>
c# java
[0, 1]
381,760
381,761
problem with jquery move image
<p>how can get x,y when mousedown in image and then mouse move in the image and then mouseup get x,y</p> <p>(2 x,y 1-x,y when mouse down 2-x,y when mouse up) all the event in the one image. and language jquery</p> <p>this my code by this not working(image stick to mouse and only mouse_d called)</p> <p>var mx1; var my1;</p> <p>$("document").ready(function () { $("img#ground").bind("mousedown",mouse_d); $("img#ground").bind("mouseup",mouse_u); $("img#ground").bind("dragstart",mouse_d); });</p> <pre><code> function mouse_d(event) { mx1=event.pageX; my1=event.pageY; } function mouse_u(e) { mx2=e.pageX; my2=e.pageY; mx2=mx1-mx2; my2=my1-my2; } </code></pre>
javascript jquery
[3, 5]
4,448,426
4,448,427
Correct Namespace For GetHtmlPage
<p>Can anyone tell me the namespace for GetHtmlPage? I have:</p> <pre><code>using System.Net; using System.IO; </code></pre> <p>as per the instructions found here: <a href="http://www.mikesdotnetting.com/Article/49/How-to-read-a-remote-web-page-with-ASP.NET-2.0" rel="nofollow">http://www.mikesdotnetting.com/Article/49/How-to-read-a-remote-web-page-with-ASP.NET-2.0</a></p> <p>But this line of code:</p> <pre><code>string locatorReport = GetHtmlPage(URL); </code></pre> <p>throws an error message:</p> <pre><code>The name 'GetHtmlPage' does not exist in the current context </code></pre> <p>Any advice is appreciated.</p> <p>Regards.</p>
c# asp.net
[0, 9]
2,720,362
2,720,363
FIPS compliant algortihm to store passwords in a database?
<p>I am looking for a FIPS -compliant hashalgortihm to store passwords in the database. I did use the following code but still i get the error "This implementation is not part of the Windows Platform FIPS validated cryptographic algorithms."</p> <pre><code> SHA1CryptoServiceProvider Testsha1 = new SHA1CryptoServiceProvider(); byte[] hashedBytes; UTF8Encoding encoder = new UTF8Encoding(); hashed = Testsha1.ComputeHash(encoder.GetBytes(strPassword)); StringBuilder sb = new StringBuilder(); for (int i = 0; i &lt; hashed.Length; i++) { sbuilder.Append(hashed[i].ToString("x2")); } string Password = sb.ToString(); </code></pre>
c# asp.net
[0, 9]
2,411,818
2,411,819
variable name is not replaced with value inside head tag
<p>My asp.net site has a navigation that uses an .active css tag to change the color of the navigation color on active pages. </p> <p>This is in my site.master header </p> <pre><code>.active { background-color: #c62020; border-right: 1px solid; margin-left: -1px; } &lt;/style&gt; </code></pre> <p>This works great as is. But now I want it to change the background color depending on a variable, I have the code to do it in the Site.Master.cs.</p> <p>I understand that I cant use &lt;%= %> inside the header. Whats the best way to get this to work?</p> <p>Thanks</p>
c# asp.net
[0, 9]
5,891,214
5,891,215
IE blocks pdf file save popup
<p>I have created savepdf.aspx which writes pdf file contents to response as attchment by following code</p> <pre><code> Response.Clear(); Response.AppendHeader("Content-Disposition", "attachment; filename=Sample.pdf"); Response.ContentType = "application/pdf"; Response.BinaryWrite(transcriptFileBytes); Response.End(); </code></pre> <p>When click on button of parent page savepdf.aspx opens as popup, which writes pdf file contens.</p> <p>Now problem is popup just gets open and close immediatly without prompting for file save diaolog box.</p> <p>But, when I hold Ctrl key while clicking on parent button, popup does appears and ask for file open save dialog box. This time works fine.</p> <p>How to fix this behaviour through code?</p>
c# asp.net
[0, 9]
2,141,970
2,141,971
jQuery .keyup() triggering infinitely
<p>I'm trying to get immediate feedback from an input box as to the letter that has been typed into it. The input has a maxlength of 1 character and I want jQuery to be alerted to this value the moment the user lifts their key having entered their character.</p> <p>The following detects the value immediately but then keeps looping forever. This isn't strictly a problem but it seems like an undue strain.</p> <pre><code>$("#captcha").keyup(function(e) { ( $(this).val() == 'w' ) ? $(this).css("border-bottom","2px dotted #27bbb1") : $(this).css("border-bottom","2px dotted #ED0664") ; //e.preventDefault(); }); </code></pre> <p><code>change()</code> won't work as an event as this is only triggered when the user changes focus, I need this immediately after keypress.</p> <p>Thanks</p>
javascript jquery
[3, 5]
4,582,258
4,582,259
how can i get one value to another on user click?
<p>i have two text box when i press a button text of textbox one can automatically display on textbox2. i used V S 2010 I need this code in c#</p>
c# asp.net
[0, 9]
1,525,193
1,525,194
What is significance of javascript _property
<p>I look into the jQuery source v.1.8.1 and search the jQuery.fx.speeds and its value is </p> <pre><code>jQuery.fx.speeds = { slow: 600, fast: 200, // Default speed _default: 400 }; </code></pre> <p>Why did the jQuery developers use "_defaults" instead of "defaults"??</p> <pre><code>jQuery.fx.speeds = { slow: 600, fast: 200, // Default speed // Default without underscore prefix in it default: 400 }; </code></pre> <p>What is the benefits having a property with a prefixed underscore?? What the heck does the underscore stands for??</p> <p>Example ..</p> <pre><code> var obj = {}; obj.property = "property value"; obj._property = "property value with _"; alert( obj._property ); alert( obj.property ); </code></pre> <p>When does the obj._property is more appropriate use than obj.property??</p> <p>Thanks...</p>
javascript jquery
[3, 5]
2,791,044
2,791,045
what is a good idea for manage and check pages permission?
<p>i have built a crm with asp.net.I want to set and check </p> <ul> <li>some permission for some pages,</li> <li>some user controls,</li> <li>some panel ,</li> <li>some records in database .</li> </ul> <p>please get me a good idea for manage and check this permission easily.</p>
c# asp.net
[0, 9]
2,266,732
2,266,733
Parsing an XML getting through HttpPOST in android
<p>During the execution of a httpPOST i store the response as a String and the response i am getting is like this:</p> <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;string xmlns="http://localhost:4471/"&gt;101~Success&lt;/string&gt; </code></pre> <p>i just want to get 101~Success after parsing so that i can get 101 by using split function but am not able to get this element in android.I was getting this in J2ME as:</p> <pre><code> InputStream in = new ByteArrayInputStream(strResponse.getBytes("UTF-8")); InputStreamReader is = new InputStreamReader(in); parser = new XmlParser(is); doc.parse( parser ); Element root = doc.getRootElement(); Element item = doc.getElement(2); String parsedResponse = item.getText(0); </code></pre> <p>How can i do it in android?</p>
java android
[1, 4]
2,649,855
2,649,856
jQuery - Calendar plugin, pre selected dates on multiple select
<p>Im using a calendar plugin for jQuery, im using the 'selecting multiple dates' demo which is here <a href="http://www.kelvinluck.com/assets/jquery/datePicker/v2/demo/datePickerMultiple.html" rel="nofollow">http://www.kelvinluck.com/assets/jquery/datePicker/v2/demo/datePickerMultiple.html</a> </p> <p>Im using the demo code for starters which is as follows:</p> <pre><code>&lt;script type="text/javascript" charset="utf-8"&gt; $(function() { $('.date-pick') .datePicker( { createButton:false, displayClose:true, closeOnSelect:false, selectMultiple:true } ) .bind( 'click', function() { $(this).dpDisplay(); this.blur(); return false; } ) .bind( 'dateSelected', function(e, selectedDate, $td, state) { console.log('You ' + (state ? '' : 'un') // wrap + 'selected ' + selectedDate); } ) .bind( 'dpClosed', function(e, selectedDates) { console.log('You closed the date picker and the ' // wrap + 'currently selected dates are:'); console.log(selectedDates); } ); }); &lt;/script&gt; </code></pre> <p>This works great, i want to be able to pre select dates somehow, im getting dates from the database, and i want to be able to show them as checked when i click the link to open the calendar.</p> <p>If anyone has any experience with this, i would love some help ... im not a jQuery nut at all, so its hard to figure this out.</p> <p>Cheers,</p>
javascript jquery
[3, 5]
4,526,448
4,526,449
Disable browser buttons and url address bar in all major browsers?
<p>I don't know if this is possible but is it possible to disable a url address bar in the browser when a user is on a certain page? Also is the user able to disable browser buttons if a user is on a certain page?</p> <p>But the twist is that it needs to work on all browsers, Chrome, Safari, IE, Opera and Firefox. It has to work on all of these browsers. Can't fail in one of these browsers which I know makes this difficult.</p>
php javascript
[2, 3]
5,474,775
5,474,776
PHP And JS Code Not Executed
<p>i Have This PHP and JS Code on my web page.</p> <pre><code>&lt;?php include 'connect1.php'; $query = "SELECT URL FROM remontee_nlf ORDER BY URL ASC"; $result = mysql_query($query) or die (mysql_error());; $counter = 0; // write the values from the database into the javascript array echo "&lt;script type='text/javascript'&gt;"; echo "this.styleListArray = new Array();"; if ($result) { while($row = mysql_fetch_array($result)) { echo("this.nameArray[" . $counter . "] = '" . $row['URL'] . ", " . $row['user_fname'] . "';"); // displays 'lname, fname' $counter += 1; } } echo("&lt;/script&gt;"); ?&gt; </code></pre> <p>The Problem is that when i execute the page containing the code, a part of this code doesn't get executed and it just shows on the page as a simple text : </p> <pre><code>"); echo "this.styleListArray = new Array();"; if ($result) { while($row = mysql_fetch_array($result)) { echo("this.nameArray[" . $counter . "] = '" . $row['URL'] . ", " . $row['user_fname'] . "';"); // displays 'lname, fname' $counter += 1; } } echo(""); ?&gt; </code></pre> <p>I tried to figure it out, but i couldn't get it, if you can help brothers, that would be wonderful.</p>
php javascript
[2, 3]
4,033,049
4,033,050
Reason behind deprecating the Thread's stop(), destroy(), resume() methods
<p>I read that the Thread class stop(),destroy(),resume() methods been depricated. As a reason it says:</p> <p>"Because stopping a thread in this manner is unsafe and can leave your application and the VM in an unpredictable state"</p> <p>Honestly I didn't understand the reason perfectly from the text. Can someone explain it more clearly please (Perticularly that "VM unpredictable" and "unsafe" words )</p> <p>Thanks</p>
java android
[1, 4]
4,774,263
4,774,264
javascript attributes store this
<p>Is something like the following possible?</p> <pre><code>var obj = { data:'some data', init:function(){ console.log(this.data); console.log(obj.data); } } obj.init(); </code></pre> <p>Here, <code>console.log(this.data)</code> and <code>console.log(obj.data)</code> both return the same value.</p> <p>Is it possible to store <code>this</code> in some variable like I stored <code>'some data'</code> in <code>data</code>?</p> <p>Let's say somehow we store <code>this</code> in <code>$this</code>. Then, <code>console.log($this.data)</code> should work like <code>console.log(this.data)</code>.</p>
javascript jquery
[3, 5]
4,493,557
4,493,558
Preloading web assets: load less then the full size of the file
<p>You (me, we, everyone etc) no doubt aware of methods to load and preload assets on a site. But I was wondering if it's at all possible, either server or client side, to partially load an assets.</p> <p>Let's say I have 10 images on my site, all 500kb.</p> <p>But these images are not immediately viewable until a user triggered event.</p> <p>Is it at all possible, to load say, 200kb of each image on load, and then load the remaining 300kb when needed?</p> <p>I don't need info on preloading, as it been well documented in many places, just if partial loadin of assets is something anyone has tried and achieved</p> <p>Thank for any ideas</p> <p>Andrew</p>
php javascript asp.net
[2, 3, 9]
2,203,563
2,203,564
Is there a good Python library that can parse C++?
<p>Google didn't turn up anything that seemed relevant.</p> <p>I have a bunch of existing, working C++ code, and I'd like to use python to crawl through it and figure out relationships between classes, etc.</p> <p>EDIT: Just wanted to point out: I don't think I need or want to parse every bit of C++; I just need something smart enough to pick up on class, function and member variable declarations, and to skip over function definitions. </p>
c++ python
[6, 7]
3,256,423
3,256,424
How to differentiate between click and drag/drop event?
<p>I have a problem with element which is both draggable and also has a click event.</p> <pre><code>$('.drag').mousedown(function() { //... }); $('.class').click(function() { //... )}; &lt;div class="drag class"&gt;&lt;/div&gt; </code></pre> <p>When I drag and drop the element, the click event gets fired, too. How to prevent that?</p>
javascript jquery
[3, 5]
4,213,597
4,213,598
Jquery/JS scoping
<p>This may be pretty simple but it's stumping me. I'm trying to return a variable in javascript to another variable outside of the function's scope. For some reason, the assignment isn't occurring. Here's my code:</p> <pre><code>var time = Math.round(((new Date()).getTime())/1000); // first call to get data var power_now = get_data(&lt;%= @user.id %&gt;, time); function get_data(user_id, timestamp){ var targetURL = "get/user_data?time_now="+timestamp+"&amp;user_id="+user_id; var power = 0; $.get(targetURL, function(data){ power = data[0]['power']; alert(power); }) return power; } $('body').html('&lt;h1&gt;'+power_now+','+power_then+'&lt;/h1&gt;') </code></pre> <p>If I place alert(power) within the .get function, the value is correct; however if I place it outside of the .get function, the value is 0.</p> <p>Maybe I'm missing something about scoping in javascript?</p> <p>Thanks!</p>
javascript jquery
[3, 5]
1,514,104
1,514,105
Select element(s) without specific element
<p>Hi this is my problem:</p> <pre><code>&lt;ul&gt; &lt;li&gt;&lt;span class="show"&gt;*&lt;/span&gt;Show&lt;/li&gt; &lt;li&gt;&lt;span class="show"&gt;*&lt;/span&gt;Show&lt;/li&gt; &lt;li&gt;&lt;span class="show"&gt;*&lt;/span&gt;Show&lt;/li&gt; &lt;li&gt;&lt;span class="show"&gt;*&lt;/span&gt;Show&lt;/li&gt; &lt;li&gt;Hide&lt;/li&gt; &lt;li&gt;Hide&lt;/li&gt; &lt;/ul&gt; </code></pre> <p>So oposite of this <a href="http://jsfiddle.net/ajitam/GqCpW/" rel="nofollow">http://jsfiddle.net/ajitam/GqCpW/</a></p> <p>How can I select (with jQuery) 'li's without span.show inside.</p> <p>thank you</p>
javascript jquery
[3, 5]
4,556,174
4,556,175
How to check/uncheck checkboxes by clicking a hyperlink?
<p>I have 11 checkboxes with individual ids inside a modal popup.I want to have a hyperlink called SelectAll,by clicking on which every checkbox got checked.I want this to be done by javascript/jquery.</p> <p>Please show me how to call the function</p>
javascript jquery
[3, 5]
4,693,956
4,693,957
Jquery get text value of option on change
<p>I have code like this:</p> <pre><code>&lt;select name="caffe" id="caffe"&gt; &lt;option value="5"&gt;Red&lt;/option&gt; &lt;option value="6"&gt;nmfxnsdnx&lt;/option&gt; &lt;/select&gt; &lt;div id="gll_select"&gt; &lt;script&gt; var caffe = $("#caffe").val(); var cff_name = $("#caffe option:first").text(); $("#gll_select").load("http://localhost/010/form/galleries", {id : caffe}, function(){ $("#gll").on('change', function(){ var cff_name = $("#caffe").text(); get_gallery(cff_name); console.log(cff_name); }); }); &lt;/script&gt; &lt;/div&gt; </code></pre> <p>How can I get text value of the option that has been selected? </p>
javascript jquery
[3, 5]
4,152,799
4,152,800
ASP.NET - Internal messaging system
<p>I want to implement a messaging system in my Web application similar to the one Chase and Facebook have on their websites. Should I develop this on my own, or should I find a 3rd party control or other solution? Would google provide some sort of API to make this easy? I'm leaning towards developing this on my own because it probably won't involve too much but wanted to know my options. </p> <p>All suggestions/comments are appreciated! </p>
c# asp.net
[0, 9]
193,327
193,328
Falling through a switch case?
<p>I was in the process of writing a switch case when I read on the PHP site: </p> <p><code>Thus, it is important not to forget break statements (even though you may want to avoid supplying them on purpose under certain circumstances).</code></p> <p>A switch case without break statements was perfect for what I wanted to do. I want all the cases below the matched one to execute. Why is this wrong, and what is the best way to do it differently?</p> <p>Is it bad for all languages, or just PHP? Why?</p> <p>edit: Whether it is or isn't a problem, is there a way to do the same thing without a switch case?</p>
php javascript
[2, 3]
669,102
669,103
how to call javascript/jQuery when javascript is disabled in mozilla/ie?
<p>how to call javascript/jQuery when javascript is disabled in mozilla/ie ?</p>
javascript jquery
[3, 5]
1,819,407
1,819,408
How to prevent jQuery functions from not running if a preceding function fails?
<p>I'm having an issue with jQuery functions not running if a preceding function failed for example:</p> <pre><code>jQuery(function($) { // this function failed to run because the dependency file wasn't loaded }); jQuery(function($) { // fails to run unless all preceding function succeed }); jQuery(function($) { // fails to run unless all preceding function succeed }); </code></pre> <p>I'm doing this because they're all small chunks of code, each one for a jquery plugin used on my site so one for a slider another one for a drop down menu ..., for example if a page without a slider I'm not loading the slider plugin so all everything after the slider function fails to run.</p> <p>so what should I do so jquery ignores failing function ?</p> <p>and thanks in advance. </p>
javascript jquery
[3, 5]
6,005,080
6,005,081
Communicate from one page to another? JavaScript, PHP?
<p>I'm building a prototype where on one page A I have a controller. Imagine a TV remote. On another page B, independent of form A -- it can be a different screen/computer -- with some elements X, Y, and Z that are going to be animated by the remote on page A.</p> <p>My first idea would be:</p> <ul> <li>Remote on page A saves an action wanted and sends JSON.</li> <li>I create a listener on page B that reads the JSON to listen to what action to trigger.</li> </ul> <p>I wonder if this the right direction.</p> <p>It is just for a prototype so it doesn't have to be a production-perfect idea.</p>
php javascript
[2, 3]
5,781,269
5,781,270
jQuery iframe upload. Handle network errors
<p>This code works, except now I need to handle network errors.</p> <p>For example if the network is turned off while a file is uploading. I need to handle errors like these.</p> <p>How can I proceed?</p> <pre><code>var name = 'iframeUpload'; var cur = $(this); var iframe = $('&lt;iframe name="' + name + '" id="' + name + '" style="display: none" /&gt;'); $("body").append(iframe); cur.attr("action", "upload/test"); cur.attr("method", "post"); cur.attr("enctype", "multipart/form-data"); cur.attr("encoding", "multipart/form-data"); cur.attr("target", name); cur.attr("file", $(this).val()); cur.submit(); $('#' + name).load(function () { }); </code></pre>
javascript jquery
[3, 5]
2,466,492
2,466,493
Changing div class within set
<p>I have the following html and I want to change the divs around onclick. For example: </p> <p>Initial</p> <pre><code>&lt;div class="box1"&gt;Story 1&lt;/div&gt; &lt;div class="box2"&gt;Story 2&lt;/div&gt; &lt;div class="box2"&gt;Story 3&lt;/div&gt; &lt;div class="box2"&gt;Story 4&lt;/div&gt; </code></pre> <p>When I click on Story 2, it becomes</p> <pre><code>&lt;div class="box2"&gt;Story 1&lt;/div&gt; &lt;div class="box1"&gt;Story 2&lt;/div&gt; &lt;div class="box2"&gt;Story 3&lt;/div&gt; &lt;div class="box2"&gt;Story 4&lt;/div&gt; </code></pre> <p>So .. whichever div is clicked will take the property of box1 and the others will become box2. Is it possible?</p>
javascript jquery
[3, 5]
4,765,288
4,765,289
jQuery: write variable between 2 quotation mark
<p>I want to create a loop for input so that the variable img get number 1 to 5 like this: </p> <pre><code>img1, img2 ... img5. </code></pre> <p>How to write <code>$i</code> after img?</p> <pre><code>for ($i=1;$i&lt;=5;$i++) { function(data) { $('input[name="img1"]').val(data) }); } </code></pre> <p><strong>Note:</strong> img is between <strong>two</strong> quotation mark.</p> <p>it's edite:</p> <pre><code>user = $('input[name="name"]').val(); for (var i = 1; i &lt;= 5; i++) { $.post("test.php", { name: user, num: i }, function(data) { $('input[name="img'+i+'"]').val(data) }); } </code></pre>
javascript jquery
[3, 5]
2,314,957
2,314,958
How do I run a function only when a div gets loaded?
<p>I want to run a function only when a div gets loaded.</p> <p>When I load the page, a number of files are loaded. At the end of the list, PHP echoes a div. When this one is displayed, jQuery should run a function.</p> <p>I can do this with a click-event, but I want it to work automatically, without pushing a button.</p> <p>This is how it works with a click:</p> <pre><code>$("#PP_end_show").live("click",function(){ $("#PP_head_bar").slideToggle("slow"); $("#PP_info_file_wrap").slideUp("slow"); }); </code></pre> <p>This is the <code>div</code> echoed by PHP:</p> <pre><code> &lt;?php echo "&lt;div id=\"PP_end_show\"&gt;&lt;/div&gt;"; ?&gt; </code></pre> <p>The output is generated after an AJAX call:</p> <pre><code>&lt;form id="PP_search_input" method="post" name="search_ID" ONSubmit="xmlhttpPost('PP_search_stream_client.php', 'PP_search_input', 'PP_thumb_output', '&lt;img src=\'images/wait.gif\'&gt;');return false; "&gt; &lt;input name="search_string" type="text" class="PP_input" id="search_string" value="&lt;?php echo $_POST['search_string']; ?&gt;"/&gt; &lt;button type="submit" class="PP_submit" id="search_submit"&gt; search &lt;/button&gt; </code></pre> <p>at the end of the generated output the specific div will be printed and should trigger the new jQuery function.</p>
php javascript jquery
[2, 3, 5]
3,495,920
3,495,921
Call C#.net method in Javascript
<p>I Have Method in Code behind(C#) and Want to call this method inside the javascript.</p> <p>My Code in C#</p> <pre><code> private void StatusSet() { List&lt;StatusHandler&gt; iListStatus = new List&lt;StatusHandler&gt;(); iListStatus.Add(new StatusHandler('A', "Active")); iListStatus.Add(new StatusHandler('I', "InActive")); iListStatus.Add(new StatusHandler('L', "All")); if (hdnMode.Value == "i") { ddlStatus.DataSource = iListStatus.Take(2); } else { ddlStatus.DataSource = iListStatus.Take(3); if (lnkBtnUpdate1.Visible == true) { ddlStatus.DataSource = iListStatus.Take(2); } } } </code></pre> <p>Javascript :</p> <pre><code>function GetMode(modeIndex) { if (modeIndex == 'i') { StatusSet(); //How to Call in Javascript } } </code></pre>
javascript asp.net
[3, 9]
5,700,951
5,700,952
Is there any benefit to defining a utility function directly on the jQuery object?
<p>Are there any specific benefits derived from defining a utility function directly on the jQuery object:</p> <p>For instance, given the following two constructs:</p> <pre><code>$.someUtility = function(){ //do some something with jQuery } var someUtility = function(){ //do some something with jQuery } </code></pre> <p>Is there any specific reason I would want to use the first example over the second?</p> <p><strong>Quick Update:</strong> I don't need to do any chaining, and my utility is not a plugin in the traditional sense; It will not perform any operations on a jQuery selector.</p>
javascript jquery
[3, 5]
107,571
107,572
Onblur, what is the next control which will gain focus?
<p>I am firing some code onblur() of a textbox. But I want to do something different if the user clicked on the cancel button to cause that onblur(). Is there a way within the onblur() event handler function to know what the control is that is about to receive focus and react acordingly?</p> <p>-Joseph</p>
javascript jquery
[3, 5]
4,141,126
4,141,127
grid view control in asp.net
<p>I have one grid view control in my asp.net web application. For example i have data grid as 10 rows and 8 columns in fixed size. I want When the data comes to grid view more than 10 rows means the scroll bar will appear to display and not the size of the data grid exceed. How can I do . I use the following source </p> <pre><code> &lt;FooterStyle BackColor="#507CD1" ForeColor="White" Font-Bold="True" /&gt; &lt;PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" /&gt; &lt;SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" HorizontalAlign="Center" VerticalAlign="Middle" /&gt; &lt;HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" /&gt; &lt;EditRowStyle BackColor="#2461BF" /&gt; &lt;AlternatingRowStyle BackColor="White" /&gt; &lt;/asp:GridView&gt; </code></pre> <p>If anyone can help to me its really appreciated. Thank you</p>
c# asp.net
[0, 9]
5,337,883
5,337,884
How to disable a row in gridview?
<p>In have to disable a row in which chechbox is checked.I have tried it in RowDataBound event by using following code but it shows error <code>Object reference not set to an instance of an object</code>.</p> <pre><code> CheckBox cbAttachClrReq = (CheckBox)gvEntity.FindControl("chkAdd"); if (cbAttachClrReq.Checked) { this.gvEntity.Rows[e.Row.RowIndex].Enabled = false; } </code></pre>
c# asp.net
[0, 9]
1,486,615
1,486,616
Need To Blink Text in GridView using Jquery
<p>I need to blink some text in GridView Using Jquery its working outside GridView but i implemented the same inside the GridView its not working can any 1 please point me to my issue here is the link of my sample application if any 1 want to see the source code : <a href="http://www.mediafire.com/file/oxk90bjsmfqa03f/Grid.rar" rel="nofollow">Link to my Sample Application</a></p> <p>Here is some part of my code </p> <p><em><strong>Javascript Function</em></strong></p> <p><img src="http://i.stack.imgur.com/St7Jd.png" alt="enter image description here"></p> <p><em><strong>ASPX Code</em></strong></p> <p><img src="http://i.stack.imgur.com/OFgqj.png" alt="enter image description here"></p> <p><em><strong>CodeBehind Code</em></strong></p> <p><img src="http://i.stack.imgur.com/t7aAJ.png" alt="enter image description here"></p> <p>the Above code is working for the div which is outside the GridView but not working for the div which is inside the GridView... Please point me where i am going wrong...</p> <p>Thanks</p>
jquery asp.net
[5, 9]
212,212
212,213
selectall() property in C# for textbox control
<p>I know, there is a property for textbox control in windows form, called selectall().</p> <p>I am trying to achieve the same in my web app, for a textbox, once it recieves the focus(), i am trying to select all the text in the textbox.</p> <p>I know, i can write some jquery for this, but, is there any other easier way to achieve this?</p> <p>Regards, Ron.</p>
c# asp.net
[0, 9]
4,328,611
4,328,612
How to disable scrolling for ListView on Android?
<p>I have the following question: I have a difficult layout that contain ListView. I need disable scrolling ability for ListView, because it's container (root Layout) have had ScrollView already, and I don't need a scrolls for ListView. I disable scrolls by android:scrollbars="none", but abilitity for scrolling would stay. I need that if ListView has 10 items that all items will be shown. How can I do it? </p>
java android
[1, 4]
1,473,270
1,473,271
Using jQuery how to select the first next element(s) that matches a certain selector?
<p>How to select a node after <code>$(this)</code> that matches a certain selector?</p> <p>eg:</p> <pre><code>&lt;textarea id="foo"&gt;&lt;/textarea&gt; &lt;a href="#"&gt;someLink&lt;/a&gt; &lt;a href="#"&gt;someOtherLink&lt;/a&gt; &lt;textarea id="bar"&gt;&lt;/textarea&gt; </code></pre> <p>With out directly selecting #bar via $("#bar"), how can i select it from within #foo?</p>
javascript jquery
[3, 5]
1,560,309
1,560,310
how to refresh my record count from database - asp.net?
<p>i have in my asp.net web-page <code>label</code> that contain result of count record query.</p> <p>i need to see refresh this query and see the correct record count.</p> <p>how to see it ? i need any timer ? how to do it without Flickers ?</p> <p>can i get any sample C# asp.net code ?</p> <p>thanks in advance</p>
c# asp.net
[0, 9]
4,936,572
4,936,573
How to set buttons with dynamic ID's clickable jquery
<p>I have form that goes like this:</p> <pre><code>&lt;?php foreach($userID as id):?&gt; &lt;input type="button" id="ok_&lt;?php echo id?&gt;" value="ok" /&gt; &lt;input type="button" id="cancel_&lt;?php echo id?&gt;" value="cancel" /&gt; &lt;?php endforeach;?&gt; &lt;script&gt; $(document).ready(function(){ //how do i set the click events of these buttons, assuming i have 3 sets of the of the ok and cancel buttons. }); &lt;/script&gt; </code></pre>
php javascript jquery
[2, 3, 5]
985,023
985,024
inject UTC time into the page
<p>I'm using several literals to inject the user's time onto the the page. The values in the HTML are the UTC times.</p> <pre><code>var TheDay = parseInt($('#UserDayToday').html(), 10); var TheMonth = parseInt($('#UserMonthToday').html(), 10); var TheYear = parseInt($('#UserYearToday').html(), 10); var TheHours = parseInt($('#UserTimeStampHours').html(), 10); var TheMinutes = parseInt($('#UserTimeStampMinutes').html(), 10); </code></pre> <p>Now I want to build a time stamp with that time so I tried this:</p> <pre><code>var TheDateToday = new Date(); TheDateToday.setUTCFullYear(TheYear, TheMonth, TheDay); TheDateToday.setUTCHours(TheHours, TheMinutes, 0, 0); alert(TheDateToday); </code></pre> <p>When the alert comes on, it gives me the time with his timezone shift added. How can I just have the the UTC time. I know I can get it from the browser but I want to get the UTC time built from the data sent from the server, not retrieved from the user's machine by the browser.</p> <p>Thanks</p>
c# javascript asp.net
[0, 3, 9]
4,997,062
4,997,063
Render dropdown selected value in gridview
<pre><code>&lt;asp:TemplateField HeaderText="Division"&gt; &lt;ItemTemplate&gt; &lt;asp:DropDownList ID="Division" runat="server"&gt; &lt;asp:ListItem Text="Select" Value="Select"&gt;&lt;/asp:ListItem&gt; &lt;asp:ListItem Text="Computer" Value="Computer"&gt;&lt;/asp:ListItem&gt; &lt;asp:ListItem Text="Electronics" Value="Electronics"&gt;&lt;/asp:ListItem&gt; &lt;/asp:DropDownList&gt; &lt;/ItemTemplate&gt; &lt;/asp:TemplateField&gt; </code></pre> <p>In i am not able to diplay the selected values in the dropdown which is already in the database. </p>
c# asp.net
[0, 9]
2,120,085
2,120,086
Combining document.load + blur
<p>I have the following javascript to determine whether a copyright is properly formatted:</p> <pre><code> var copyright = $('#copyright') var copyright_text = copyright[0].value if (copyright_text.length &gt; 0) { var containsYear = /\d{4}/.test(copyright_text); if (containsYear == false) { copyright.css({ 'background-color': 'rgba(230, 89, 78, 0.07)', }); copyright.parent().append( '&lt;div class="explanatory caution"&gt;CAUTION: Make sure this copyright contains a year.&lt;/div&gt;' ); }; }; </code></pre> <p>How would I apply this same logic to <code>.blur()</code> as well as the normal page load above without copy and pasting all the code from above?</p>
javascript jquery
[3, 5]
998,734
998,735
Jquery dynamic dropdown event not firing
<p>Hi i am trying to create dropdownlists dynamically and populating the contents via an ajax call, this sort of works in the sense that the drop down is created and populated as required but its 'change' event does not fire. I am posting the code below, if anyone can spot something obvious, can you please let me know regards</p> <pre><code>$(document).ready(function () { $("#positions select").change(function (e) { alert("in"); var id = $("#category_id").val(); $.getJSON("/Category/GetSubCategories/" + id, function (data) { if (data.length &gt; 0) { alert(data.length); var position = document.getElementById('positions'); var tr = position.insertRow(7); var td1 = tr.insertCell(-1); var td = tr.insertCell(-1); var sel = document.createElement("select"); sel.name = 'sel'; sel.id = 'sel'; sel.setAttribute('class', 'category'); td.appendChild(sel); $.each(data, function (GetSubCatergories, category) { $('#sel').append($("&lt;option&gt;&lt;/option&gt;"). attr("value", category.category_id). text(category.name)); }); } }); }); }); </code></pre>
javascript jquery
[3, 5]
383,996
383,997
Using jQuery with ASP.NET to Submit a Form
<p>I've used jQuery dozens of times with PHP with great success. I'm working on an ASP.NET application and would like to use jQuery in the same manner. </p> <p>Basically, I've got a masterpage that has the form and a webform that has all the form fields and data. A user can submit the form multiple ways - selection of a drop-down, button, etc. I want to catch all submits and use jQuery to submit the form. While the form is being processed, I want to display a new DIV with some text in it. Finally, I want to replace that div with the new form.</p> <p>How can I accomplish this with the way that ASP.NET works?</p>
c# jquery asp.net
[0, 5, 9]
3,306,765
3,306,766
Loading youtube videos by its URL with the help of a JS/Jquery function
<p>I am trying to load youtube videos using JS function. The intention is to have the user simply copy and paste the youtube video URL into an input field and then have my JS code takes care of the loading part. Unfortunately I am not sure why js code is not loading anyvideo? <a href="http://jsfiddle.net/bullseye2346/fZsrs/" rel="nofollow">JS FIDDLE</a></p> <p>JS:</p> <pre><code>&lt;script&gt; $(document).ready(function(){ var last_cnad_text_1 = ''; var options_cnad_text_1 = { embedMethod:'fill', maxWidth:320, maxHeight: 320 }; function loadVideo() { val = $('#cnad_text_1').val(); if ( val != '' &amp;&amp; val != last_cnad_text_1 ) { last_cnad_text_1 = val; $("#embed_cnad_text_1").oembed(val,options_cnad_text_1); } } $(function(){ $('#cnad_text_1').keydown(loadVideo()); $('#cnad_text_1').click(loadVideo()); $('#cnad_text_1').change(loadVideo()); }); }); ​&lt;/script&gt; </code></pre> <p>html:</p> <pre><code>&lt;html&gt; &lt;div class="col1"&gt;Insert a youtube video Link&lt;/div&gt; &lt;div class="col2"&gt; &lt;input id="cnad_text_1" type="text" name="cnad[text_1]"&gt; &lt;div id="embed_cnad_text_1"&gt; &lt;iframe&gt;&lt;/iframe&gt; &lt;/div&gt; &lt;/div&gt;​ &lt;/html&gt; </code></pre>
javascript jquery
[3, 5]
5,905,825
5,905,826
modular use of a page on multiple domains
<p>I am looking for the best way to do this.. basically i have multiple domains hosted on the same server. Each domain will have a page that is the same across them all. I want it to be modular in the sense that if i change it in one place it will be changed on all of them. What is the best way to do this? My site is built using PHP and Javascript, by the way.</p> <p>Thanks</p> <p>(my thought would be having the page listed on one main site and then have all others 'include' it? )</p> <p>Thanks</p>
php javascript
[2, 3]
4,541,591
4,541,592
setting the height of the parent according to the highest child element, jquery
<p>I have a layout, which basically contains a</p> <pre><code>&lt;div class="line" id="#"&gt; &lt;div class="summary"&gt; Some Text &lt;/div&gt; &lt;div class="summary"&gt; Some &lt;/div&gt; &lt;div class="summary"&gt; Some long text &lt;/div&gt; &lt;/div&gt; </code></pre> <p>I want, using jQuery, to expand the height of the <code>&lt;div class="line"&gt;</code> according to the highest child element, I tried fiddling with:</p> <pre><code>$(".line").attr("id", function() while ($(this).next().length &gt; 0) { ac = $(this).children(".summary").outerHeight(); a = $(this).children(".summary").next().outerHeight(); if (a &gt; ac) { a = ac; } } $(this).css("height", a + "px"); }); </code></pre> <p>and no success, what selectors I need to use, and how would I go about achieving this?</p>
javascript jquery
[3, 5]
5,020,110
5,020,111
How to apply static class in php
<p>I am java and php programmer. In java i can use static class/method so that anyone can use the same one time created class during run-time.</p> <p>But for php how to do it since it is script based and only run while we refreshing the page?</p> <p>My main objective is, I want to use syncronized class/method so that it wont clash while executing the PHP...</p> <p>Need your help to give input. Thanks</p> <p><strong>Update:</strong></p> <ol> <li>I am doing portal like multi level marketing(mlm) </li> <li>Once register a member, we should pay bonus to the uplines </li> <li>I don't want immidiately calculate the bonus because it is risky and could take some time to finish, so is is better just to register the member and show successfull. </li> <li>My idea is, after registration, just invoke another class to run bonus with syncronized method so that the bonus calculation will not disturb by another registration.</li> </ol>
java php
[1, 2]
3,314,003
3,314,004
UpdatePanel initial call
<p>I am using an UpdatePaenl in an asp.net page. It has a button to trigger it. I'm able to show "Loading" when the button is pressed. Here's my issue: I need it to show "Loading" when the page is first called, not just when a button is pressed.</p> <p>I would imagine that JavaScript would be used to trigger the UpdatePanel when the page is first loaded.</p> <p>Any ideas are greatly appreciated. Thanks</p>
asp.net javascript
[9, 3]
3,130,572
3,130,573
javascript comparing strings (for date purposes)
<p>Ive only ever done absolute comparisons before, so Im a bit stuck as to how to deal with this...</p> <p>I have two strings returned from PHP (format is DATE_ATOM i.e 2012-01-20)</p> <p>What I need to do is compare one string (date) against another - however, I need to return true on the following three conditions</p> <ul> <li>The first date matches the second date (== got this one...)</li> <li>The first date matches the second date +1 day </li> <li>The first date matches the second date +2 days</li> </ul> <p>Anything over that will return false.</p> <p>How can I do this in as 'clean' a way as possible..</p> <p>P.S This can be done in either PHP or Javascript - just the cleanest way possible would be prefered!!!</p> <p>Many thanks in advance!</p>
php javascript
[2, 3]
1,517,228
1,517,229
Looping a json encode filtered by type
<p>I create a json encode in PHP like this:</p> <pre><code>$get = mysql_query("SELECT * FROM $table") or die(mysql_error()); $data = array(); while($row = mysql_fetch_assoc($get)){ $data[$row['id']][0] = $row['g']; $data[$row['id']][1] = $row['w']; $data[$row['id']][2] = $row['s']; $data[$row['id']][3] = $row['name']; $data[$row['id']][4] = $row['type']; } $data4 = json_encode($data); </code></pre> <p>I assign it to a js variable: var bdata;</p> <p>So what im trying to do is now loop the content filtered by [4] = type.</p> <p>This is my loop:</p> <pre><code> for(var key in bdata){ //stuff here } </code></pre> <p>But this will loop all of them... but I want to loop only ones that have a [4] (type) of a certain value lets say the value was "2".</p> <p>Is there a way to do that?</p>
php javascript
[2, 3]
2,059,099
2,059,100
Jquery post multiple vars to php
<p>I want to post multiple vars from jquery to php</p> <pre><code>&lt;script&gt; //vote script function vote(type){ $.post('vote.php', '{user_id: &lt;?php echo $fb_userid;?&gt;, page_name: &lt;?php echo $get_image;?&gt;, type: type}', function(data){ $('#voteNumber').html(data); }); }//end function &lt;/script&gt; </code></pre> <p>The above code is not working what is my problem ?</p> <p>here is my php</p> <pre><code>if(isset($_POST['user_id']) &amp;&amp; isset($_POST['page_name']) &amp;&amp; isset($_POST['type'])){ echo "done"; } </code></pre>
php javascript jquery
[2, 3, 5]
2,527,177
2,527,178
When and how can I use a JQuery function ? - easy one
<p>I want to know that when we have a function with parameters that </p> <p>works like a VB procedures</p> <p>When and how can I use this function ?</p> <p>How can we call this ?</p> <pre><code>&lt;script type="text/javascript"&gt; function place(div, image_x, image_y ) { $("#"+div).css("position", "absolute") ; $("#"+div).css("left",image_x+"px"); $("#"+div).css("top",image_y+"px"); } </code></pre> <p></p> <p><strong>When and how can I use this function ?</strong></p> <p>I tried to use this in several ways , but It seems that JQuery didn't activate .</p> <p>some of my efforts to call this : <em>(maybe funny)</em></p> <pre><code>(function($) { // $(document).ready( function(){ $.fn.Place = function place(div, image_x, image_y) { }) (jQuery) jQuery(function($) { place("pnlLinx", 700 , 500 ) ; }); </code></pre> <p>or simply :</p> <pre><code>place("pnlLinx", 700 , 85 ) ; </code></pre> <p>with no effect</p> <p>thanks in advance</p> <p><em>This should be a simple question for people knew the structure of JQuery I'm not totally familiar with the structure of JQuery but I used it different ways in my codes .</em></p> <p><em>this example is just for learning one part of this structure , that I had problem .</em></p>
javascript jquery
[3, 5]
2,793,683
2,793,684
how would i upgrade this code to work with jquery 1.6.2
<p>how would i upgrade this code to work with jquery 1.6.2 as it only seems to work if i use Version 1.2.6.</p> <pre><code>&lt;script type="text/javascript" charset="utf-8"&gt; window.onload = function () { var container = $('div.sliderGallery'); var ul = $('ul', container); var itemsWidth = ul.innerWidth() - container.outerWidth(); $('.slider', container).slider({ min: 0, max: itemsWidth, handle: '.handle', stop: function (event, ui) { console.log(ui.value); ul.animate({'left' : ui.value * -1}, 500); }, slide: function (event, ui) { ul.css('left', ui.value * -1); console.log(ui.value); } }); }; &lt;/script&gt; </code></pre> <p>link to my issue: <a href="http://www.floodgateone.com/catering/index1.html" rel="nofollow">http://www.floodgateone.com/catering/index1.html</a></p> <p>thanks for any help</p>
javascript jquery
[3, 5]
2,936,376
2,936,377
If span exists add class to link
<p>I have a list of links that I retrieve by AJAX. I parse the links and append them to a div. However sometimes there is a 'span' just after the 'a' that I need to take into consideration.</p> <p>The code looks like this:</p> <pre><code>&lt;ul&gt; &lt;li&gt;&lt;a href="/link1" class="list-link"&gt;Link1 &lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="/link1" class="list-link"&gt;Link1 &lt;/a&gt;&lt;span class="sometimes-here"&gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="/link1" class="list-link"&gt;Link1 &lt;/a&gt;&lt;/li&gt; ... &lt;/ul&gt; </code></pre> <p>So what I want to do is to locate when a 'li' consist of a span and then apply that class ('sometimes-here') as an additional class to the 'a'.</p> <p>I should elaborate what I need a bit as you only answered how to filter out all the 'li' that doesn't consist of the span. I want the end result to look like this.</p> <pre><code>&lt;a href="/link1" class="list-link"&gt;Link1 &lt;/a&gt; &lt;a href="/link1" class="list-link sometimes-here"&gt;Link1 &lt;/a&gt; &lt;a href="/link1" class="list-link"&gt;Link1 &lt;/a&gt; </code></pre>
javascript jquery
[3, 5]
2,834,336
2,834,337
Difference between contentResolver and ContentObserver
<p>I am developing an Android application that receives MMS and I read a lot of code. And there is contentResolver and ContentObserver, but I do not get what is the difference between them</p> <p>Like this statement:</p> <p><code>contentResolver.registerContentObserver(Uri.parse("content://mms-sms"), true, mmsObserver);</code></p> <p><code>contentResolver.unregisterContentObserver(mmsObserver);</code></p> <p>What is the difference between contentResolver and ContentObserver and what do they have to do with receiving MMS?</p>
java android
[1, 4]
5,653,746
5,653,747
How can I replace a class with another using jQuery?
<p>What jquery can I use to change the class that's used in the following from indent_1 to indent_2 or indent_4 to indent_2? I know about remove class but how can I do that when the classes are names that vary?</p> <pre><code>&lt;div class="rep_td0 indent_1" id="title_1"&gt;Menu two&lt;/div&gt; or &lt;div class="rep_td0 indent_4" id="title_1"&gt;Menu two&lt;/div&gt; </code></pre>
javascript jquery
[3, 5]
3,025,141
3,025,142
How can alter text in a loop in a DIV
<p>I have text inside a DIV tag. Is it possible to change the text content with five different text contents in cycle that never ends? Sounds simple, but I'm trying to find the easiest approach with jquery or related.</p> <p>Many thanks, Erik</p>
javascript jquery
[3, 5]
4,666,673
4,666,674
How to use activity to request data from service?
<p>Now, my program have an activity and a service. The service runs in the background and sometimes vibrates to ask users give some selection. I meet a problem here. I know broadcast could pass data from service to activity. But if the activity is not working, then it cannot receive the broadcast information, so if user feels vibration but after a period of time start the activity then the activity will miss the broadcast information and cannot ask user to choose a selection. So does anybody know how to actively request the data from the service by activity? I just want when I onCreate() or onResume() the activity, my app could update UI in time?</p> <p>Thanks</p>
java android
[1, 4]
1,424,444
1,424,445
JQuery apply bind to all children
<p>I have:</p> <pre><code>$(document).ready(function(){ $("#eventsContent").children().each(function(){ $(this).bind("mouseenter", function(){ $(this).css("background","#F5F5F5"); }); }); }); </code></pre> <p>I have tried this a couple different ways, but this is the jist of what i've done. </p> <p>I have a container div with numerous divs within it. I want to bind a MouseEnter event to each inner div respectively (and eventually a mouseout, once i see what's done it will be easy to expand upon).</p> <p>Thanks for you help in advance.</p>
javascript jquery
[3, 5]
1,287,389
1,287,390
JQuery Check if input is empty and show status of it
<p>I have an input which I need to check whether it is empty or not:</p> <pre><code>&lt;input id="myinput" name="myinput" type="text" value="hello" /&gt; </code></pre> <p>The input above could change any time, so I need to check it on <code>onchange</code>?</p> <p>If my input is not empty then I need to add the class <code>ok</code> or else add class <code>noTxt</code>.</p> <p>The class could be added to the element below.</p> <pre><code>&lt;div id="status" style="display:none;"&gt;&amp;nbsp;&lt;/div&gt; </code></pre>
javascript jquery
[3, 5]
5,010,626
5,010,627
jquery.extend(true, [], obj) not creating a deep copy
<p><a href="http://jsfiddle.net/s2bLv/7/" rel="nofollow">jsFiddle here</a>.</p> <p>If deep copying worked, the output would be "Curious George" and not "Ender's Game". How can I make a deep copy? An answer to <a href="http://stackoverflow.com/questions/122102/most-efficient-way-to-clone-an-object">this question</a> indicates that <code>$.extend(true, [], obj)</code> creates a deep copy. Yet my example shows that it doesn't.</p> <pre><code>function Person(){} Person.prototype.favorite_books = []; var george = new Person(); george.favorite_books = ["Curious George"]; var kate = new Person(); kate.favorite_books = ["The Da Vinci Code", "Harry Potter"]; var people = [kate, george]; var people_copy = $.extend(true, [], people); people_copy[0].favorite_books[0] = "Ender's Game"; $('#text').text(people[0].favorite_books[0]); </code></pre> <p><strong>SOLUTION</strong></p> <p>I updated the jsFiddle. It turns out I need to deep copy each object in the array individually <strong>if the object is a custom object</strong> (that is, <code>$.isPlainObject</code> returns false).</p>
javascript jquery
[3, 5]
3,543,417
3,543,418
How to compare two values without if else statement
<p>How can I compare two values <strong>without if/else statement</strong>?</p> <p>e.g</p> <p><code>var One = $('#one').height();</code><br /> <code>var Two = $('#two').height();</code></p> <p>How to check which value is higher <strong>without if/else statement</strong>?</p> <p>There is no must to avoid <code>if/else</code> statament - <strong>exercises only.</strong></p>
javascript jquery
[3, 5]
1,657,007
1,657,008
Wrap all non-child HTML into a DOM-element
<p>I am working on a little hyphenation engine for a website, and I got to get my head around this. I am matching all <code>p.hyphenatable</code> and send the content to a PHP-script to have it hyphenated like this:</p> <pre><code>jQuery(".hyphenatable").each(function() { var hyphenatableObject = jQuery(this); if (hyphenatableObject.children().size() == 0){ // Hyphenate only if there is no child elements to prevent HTML from being omitted jQuery.ajax({ type: "POST", url: phpHyphenatorUrl, data : { language:hyphenationLang, text: hyphenatableObject.text() }, dataType: "html", success: function(data) { hyphenatableObject.html(data); } }); } }); </code></pre> <p>To be able to have this script work on elements with children as well, I would like to wrap the non-encapsulated parts of the matched selectore into new elements, and send those to the web service. For example:</p> <pre><code>&lt;p&gt;My text &lt;img src="img.jpg" /&gt; with image&lt;/p&gt; </code></pre> <p>becomes</p> <pre><code>&lt;p&gt;&lt;span class="whatever"&gt;My text&lt;/span&gt; &lt;img src="img.jpg" /&gt; &lt;span class="whatever"&gt;with image&lt;/span&gt;&lt;/p&gt; </code></pre> <p>Any ideas on that?</p>
javascript jquery
[3, 5]
498,796
498,797
Converting string array to Name/Value object in javascript
<p>I currently am dealing with a Web Service that is returning an array of strings to the client. From here I would like to take this array of strings and convert it into an object that gives each string a name so to reference it later.</p> <p>So start with this:</p> <pre><code>var result = ["test", "hello", "goodbye"]; </code></pre> <p>And I would like to end up with this:</p> <pre><code>var final = [{'value': "test"}, {'value': "hello"}, {'value': "goodbye"}]; </code></pre> <p>I use jquery. Is there a easy to accomplish this?</p>
javascript jquery
[3, 5]
4,476,242
4,476,243
how to insert rows into gridview
<p>Sir, I want to have an insert link functionality to insert rows into gridview As we have auto generate edit and delete in gridview in asp.net,. how to do it?can u also provide me the links.</p>
c# asp.net
[0, 9]
672,563
672,564
Displaying a list of images based on a folder
<p>I am so rusty and looking for assistance. I have loaded a few image files into a folder on my web server (So, uploaded them). I now want to simply display them, one underneath each other on as aspx page. So, I want to iterate through all image files in a folder, and display them on a page.</p> <p>The easiest way would be a table, and then add a tr/td for each file.</p> <p>Can someone advise? Would this be best? An event in my cs file that reads the folder, created as and populate it?</p> <p>This is purely for a test page, and not for production.</p>
c# asp.net
[0, 9]
1,829,498
1,829,499
get text, and split it after a given string
<p>is there any javascript method to get text, and split it after a certain value? </p> <p>Like for instance, having: </p> <pre><code>&lt;p&gt;here is some text &lt;!-- read more --&gt; and here is some more&lt;/p&gt; </code></pre> <p>get this:</p> <pre><code>&lt;p&gt;here is some text&lt;/p&gt; &lt;p&gt;and here is some more&lt;/p&gt; </code></pre> <p>I suppose jQuery don't have the tools to achieve this.</p>
javascript jquery
[3, 5]
3,431,159
3,431,160
attaching a Client control ID and value to the Request object...possible?
<p>I have a Grid view in which the columns are Databound Item templates. I need to attach the client Id of a control(Hyperlink) and its value to the request object while posting it back to the server(since Viewstate is turned off). Using the Client Id, I can write code to retrieve the value of the hyperlink 'text' field.</p> <p>Is this possible in any way? Or, can you guys suggest me an alternative approach to doing this??</p>
c# javascript asp.net
[0, 3, 9]
5,880,274
5,880,275
JQuery with SMARTY php
<p>This might seem a very noob question but I haven't found the answer yet. I have a header.tpl file which contains xhtml code. I want to and some java script to it using jquery. But my problem is that it simple doesn't happen what I tell it to do. Because the page hoster comiples php with SMARTY I had to make a small change to the block script, which was had the {literal} {/literal}. But the rest seems ok. Btw the jquery.js is on the same folder as the header.tpl.</p> <p>File header.tpl <a href="http://feupload.fe.up.pt/get/SQWJvybQkDCmjEG" rel="nofollow">http://feupload.fe.up.pt/get/SQWJvybQkDCmjEG</a></p> <p>PS: I event replaced all the code by the getstarted tutorial on the jquery homepage and added the {literlar} {/literal} (otherwise it would give an error) and it steel didn't work</p>
php jquery
[2, 5]
2,568,403
2,568,404
select box option value not getting perfect while generating selectbox dynamically by using jquery
<pre><code>&lt;?php $res = mysql_query($qry) or die(mysql_error()); while($data = mysql_fetch_row($res)) { echo "&lt;option value=".$data[0]."&gt;" .$data[0]. "&lt;/option&gt;";&lt;br&gt; } ?&gt; </code></pre> <p>In this case, supposing <code>data[0]</code> has sample data value then inside value only sample is storing. How to get whole value?</p> <p>I'm calling this file by <code>$.ajax</code> method.</p>
php jquery
[2, 5]
1,327,951
1,327,952
How to make a sliding thingamajig between photos?
<p>See the effect in the photos in the article here:</p> <p><a href="http://www.popsci.com/science/article/2012-11/and-after-images-show-hurricane-sandys-devastation" rel="nofollow">http://www.popsci.com/science/article/2012-11/and-after-images-show-hurricane-sandys-devastation</a></p> <p>Does anyone have any idea how that's done? I suppose I could make two frames with adjustable width within a fixed frame, but what about the handle? And the way the frame line and handle brighten and enlarge when you mouse over? Hover event, to be sure, but what kind of hover event?</p>
javascript jquery
[3, 5]
5,112,648
5,112,649
if users press the browser's back button to reach the prior page..then page should display a message like "web page expired" in asp.net
<p>if users press the browser's back button to reach the prior page..then page should display a message like "web page expired" in asp.net</p> <p>can i use javascript for this???</p> <p>for example..</p> <p>there are 4 pages in web sites. 1,2 and 3 can be back. but when the 4th page run then 4th page can not be back... when the user press browser's back button , diaplay ma message "weg page expired".</p>
javascript asp.net
[3, 9]
4,873,312
4,873,313
Javascript .toFixed() more precise rounding alternative?
<p>For rounding decimals (prices), I've been using .toFixed(2) for quite some time now. But I just recently discovered that Javascript can't "precisely" round decimals. I was a bit shocked that even 10.005 couldn't be rounded correctly to 10.01. It just got rounded down to 10.00. And other times it did round correctly. I like to have control over my code, so this is a big no-no for me.</p> <p>And since I'm calculating prices, I think I need something more (100%) accurate for rounding only 2- or 3-decimal numbers, maybe a 4-decimal one.</p> <p>Is there no straightforward way of doing basic rounding in javascript, the correct way?</p> <p>UPDATE: As Felix Kling has suggested, the method of processing my prices as integers of cents, there are also drawbacks to this (besides more code)?</p>
javascript jquery
[3, 5]
4,393,265
4,393,266
Problem in displaying all images inside the folder using javascript
<p><strong>Hi,</strong></p> <p>For my project I m using jquery bulit in photo slide show,jquery code is taking images from array and displaying the images..The problem is I have a lot of images which I don't want to put it in Array(because it need manual effort) instead of that I want to read each image from the folder and display the images. the advantage of doing so is whenever you want to add more images you need to drop it in folder since you are reading images from folder so need not to do any thing in code level.so it makes your work easier and simpler.. so is there any way to achieve the same using javascript?.</p> <p>Thanks in Adavance.</p>
javascript jquery
[3, 5]
300,513
300,514
Reverse jquery resize shift functionality
<p>When you resize a div using jquery resize plugin, if you hold the shift key the aspect ratio is kept.</p> <p>Well it is possible to {aspectRatio: true} to option list and if i hold the shift key to disable the aspect ratio ?</p> <p>Thanks.</p>
javascript jquery
[3, 5]
452,594
452,595
How to load jQuery if it's not already loaded?
<p>I'm working on a weather widget, so in order to optimize it i want to check if jQuery has been loaded in the page, if Not, the widget will load it from my website. Because not all the websites use jQuery. how to do that?</p> <p>Example of how to put my widget:</p> <pre><code>&lt;html&gt; blah blah blah ................. &lt;script src="http://www.xxx.com/weather.js"&gt;&lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Thank you</p>
javascript jquery
[3, 5]
4,674,525
4,674,526
Sending data to web through command-line with javascript built-in
<p>Webkit and Selenium use a browser interface to interact with javascript elements and send data. Is there a way where I can fill in a ajax form and send data straight from a command-line ? If not, why is it not possible ? If so, how ? Thanks</p>
c# java javascript c++
[0, 1, 3, 6]
4,528,060
4,528,061
jquery - scope of function passed to $().grep
<p>It seems that "myFunction" in the following example loses its scope. </p> <pre><code>$().grep(myArray, myFunction) </code></pre> <p>By this, I mean that it no longer has access to the "this" of the scope it was defined in, and "this" becomes the window object. Can anyone explain why this is and if there's a handy way to preserve myFunction's scope? This javascript closure stuff halfway does my head in, but I'm trying to get facile with it.</p>
javascript jquery
[3, 5]
268,440
268,441
why BroadcastReceiver don't catch the Action?
<p>Hi I am working on BroadCastReciver. There are two way to define BroadCastReciver.First one is using Java code and Second one is define in AndroidManifest.xml using . In my code second one is don't work properly.please tell where am i goes wrong.</p> <pre><code>public class HotelReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { // TODO Auto-generated method stub String dActionName = intent.getAction(); Log.i("My Rceiver ", intent.getAction()); if (dActionName.equals(Intent.ACTION_SCREEN_ON)) { Toast.makeText(context, "SCREEN ON", Toast.LENGTH_SHORT).show(); } else if (dActionName.equals(Intent.ACTION_SCREEN_OFF)) { } } } </code></pre> <p>AndroidManifest.xml</p> <pre><code>&lt;manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.hotelsecurity" android:versionCode="1" android:versionName="1.0" &gt; &lt;uses-sdk android:minSdkVersion="10" android:targetSdkVersion="10" android:maxSdkVersion="15" /&gt; &lt;uses-permission android:name="android.permission.PREVENT_POWER_KEY" /&gt; &lt;application android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" &gt; &lt;activity android:name=".MainActivity" android:label="@string/title_activity_main" &gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.MAIN" /&gt; &lt;category android:name="android.intent.category.LAUNCHER" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; &lt;receiver android:name=".HotelReceiver"&gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.SCREEN_ON"/&gt; &lt;/intent-filter&gt; &lt;/receiver&gt; &lt;/application&gt; &lt;/manifest&gt; </code></pre>
java android
[1, 4]
4,498,866
4,498,867
Is it possible to create a jQuery function that plays around with the name of the selector?
<p>I am trying to make a counter for "Number of characters left" in a form:</p> <pre><code>&lt;input type="text" id='username_input'&gt; &lt;input type="text" id='password_input'&gt; </code></pre> <p>Is it possible to make a function whose parameter will be part of the selector? So you can understand my question better, I'll show you an example that I did, and that doesn't work.</p> <p>What I'm trying to do will seem obvious. This implies I have to standardize all id's. I'm aware I could make a maxChar parameter in the function, but I left my mistake <code>field+'_maxChar'</code> so that you can tell me why it's not possible.</p> <p>THanks a lot in advance</p> <pre><code>var username_maxChar=20,password_maxChar=30; function countLeft(field,minCharacters){ $('#'+field+'_input').keyup(function(){ var input_length = $('#'+field+'_input').val().length; var input_count = field+'_maxChar' - input_length; $('#'+field+'_counter').text(input_count); }); } countLeft(username,6); </code></pre>
javascript jquery
[3, 5]
2,305,835
2,305,836
How to make sure at least one check box is selected
<p>I'm trying to make sure at-least one check-box is selected using custom validator and javascript but but it does not show the error message at all. It blocks the code to go forward but fails to show the error message. If I select one checkbox then the code move on to the next level. What am missing here? thanks.</p> <pre><code> &lt;script type="text/javascript"&gt; function ValidateModuleList(source, args) { var chkListModules = document.getElementById('&lt;%= cblCustomerList.ClientID %&gt;'); var chkListinputs = chkListModules.getElementsByTagName("input"); for (var i = 0; i &lt; chkListinputs.length; i++) { if (chkListinputs[i].checked) { args.IsValid = true; return; } } args.IsValid = false; } &lt;/script&gt; </code></pre> <p>and here is my custom validator and the control</p> <pre><code> &lt;asp:CheckBoxList ID="cblCustomerList" runat="server" DataSourceID="SqlDataSource1" DataTextField="GroupName" DataValueField="GroupName" onclick="readCheckBoxList()"&gt; &lt;/asp:CheckBoxList&gt; &lt;asp:CustomValidator runat="server" ID="cvmodulelist" ValidateModuleList" ErrorMessage="Please Select Atleast one Application" &gt;&lt;/asp:CustomValidator&gt; </code></pre>
c# javascript asp.net
[0, 3, 9]
2,588,843
2,588,844
How can we simulate calls and SMS in Android?
<p>Can we simulate calls and SMS in android programmtically? Like in Windows mobile we can simulate calls and SMS.</p>
java android
[1, 4]
4,243,445
4,243,446
Populate .data() with $.getJSON()
<p>I am trying to populate <code>$('div').data()</code> through JSON. It works fine with <code>JQuery.parseJSON</code> but not with <code>$.getJSON</code>.</p> <pre><code>// works as expected $('div').data('dat', { xmin: '-10', xmax: 40 }); $('div').data('dat', jQuery.parseJSON('{"bbx" : {"xmin" : "-10", "xmax" : "40"}}')); // doesnt work $('div').data('dat', $.getJSON("init.php", function(json) {return(json);})); </code></pre>
javascript jquery
[3, 5]
5,526,998
5,526,999
HOw can i do that partial match in jquery
<p>I am trying this</p> <pre><code> $("ul.nav-tabs a:contains('profile')").parent().addClass("active") </code></pre> <p>It don't work if i have <code>Profile</code> in there.</p> <p>Is there any way to make that <code>case insensitive</code></p>
javascript jquery
[3, 5]