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
966,628
966,629
How do I add an onclick Handler in asp.net
<p>'m using the <a href="http://coffeescripter.com/code/ad-gallery/#ad-image-0" rel="nofollow">ad-Gallery</a> code in my asp.net application. I've changed it a bit to be generic, because I wanted to download pictures from my database. It means that all the implementation is in the code behind (here's a piece of my C# code):</p> <pre><code>ul.Attributes.Add("class", "ad-thumb-list"); tabs.Controls.Add(ul); int i = 1; foreach (Products item in _PicturesPage) { ul.Controls.Add(li); anchor.Attributes.Add("href", item.ImagePath); image.Attributes.Add("src", "../Images/pictures/thumbs/"+i+".jpg"); image.Attributes.Add("title","A title for 12.jpg"); image.Attributes.Add("alt", "This is a nice, and incredibly descriptive, description of the image"); image.Attributes.Add("class","image3"); li.Controls.Add(anchor); anchor.Controls.Add(image); i++; } </code></pre> <p>I want to know if it's possible to intercept a click in one of the hyperlink ()? Thank you :)</p>
c# javascript asp.net
[0, 3, 9]
4,990,614
4,990,615
Database Transactions in Java on Android
<p>I am trying to translate some of the code of Objective C in Java...</p> <pre><code>[_db beginTransaction]; Date now = [[NSDate alloc] init]; boolean result = [_db executeUpdate:updateQuery, [self stringToDB:account.userId], [self integerToDB:account.accountId], [self integerToDB:account.accountType], [self stringToDB:account.accountName], ]; [_db commit]; return true; </code></pre> <p>Can anyone tell me how can i implement <code>BeginTransaction and Commit</code> in Java?</p>
java android
[1, 4]
5,998,424
5,998,425
Exception during split the string
<p>I'm have the following string <code>str = "one|two|three|four|five"</code><br> I try to split it using <code>str1[]=str.split("\\|");</code>, but it shows exception while debugging.<br> The error is <code>Exception processing async thread queue</code>. What's this and how to do it?</p>
java android
[1, 4]
4,712,583
4,712,584
How do I perform a function on a single jQuery object?
<p>I often make use of the <code>each</code> method in jQuery, such as the following:</p> <pre><code> $('#thing img').each(function(){ //do some stuff }); </code></pre> <p>...where the function is performed on each element in the jQuery object. Is there a method/syntax for performing an action on the only (or first matched) element in the object?</p> <p>I'm imagining something like</p> <pre><code> $('#thing img').do(function(){ //do some stuff }); </code></pre> <p><em>I don't need to use jQuery but can, as the application in question already makes use of it.</em></p>
javascript jquery
[3, 5]
3,724,404
3,724,405
Is it possible to modify Databound content on the fly?
<p>Sorry if the post title wasn't clear, I will try to explain a little better here.</p> <p>I am working with a web control that is databound to a data table. The output of the data is as such:</p> <pre><code>&lt;asp:Repeater ID="RssRepeater" Visible="false" EnableViewState="false" runat="server"&gt; &lt;asp:literal ID="sb_description" Text='&lt;%# DataBinder.Eval (Container.DataItem, "description") %&gt;' EnableViewState="false" runat="server" /&gt; ''// Rest of structure... &lt;/asp:Repeater&gt; </code></pre> <p>I wrote a function that, in theory, should trim a passed string to a specified number of words:</p> <pre><code>protected string CreateTeaser(string Post) { int wordLimit = 50; System.Text.StringBuilder oSB = new System.Text.StringBuilder(); string[] splitBy = new string[] { " " }; string[] splitPost = Post.Split(splitBy, System.StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i &lt;= wordLimit - 1; i++) { oSB.Append(string.Format("{0}{1}", splitPost[i], (i &lt; wordLimit - 1) ? " " : "")); } oSB.Append(" ..."); return oSB.ToString(); } </code></pre> <p>I tried this abomination:</p> <pre><code>&lt;asp:literal ID="sb_description" Text='&lt;%= CreateTeaser(%&gt; &lt;%# DataBinder.Eval (Container.DataItem, "description") %&gt;&lt;%=); %&gt;' EnableViewState="false" runat="server" /&gt; </code></pre> <p>But of course it did not work. So, is it possible to use this function on the <code>Databinder.Eval( ... )</code> while it is inside this literal control? If so, how should I go about doing this? If not, what would be a possible alternative to what I am trying to do?</p> <p>Thanks SO!</p>
c# asp.net
[0, 9]
5,510,392
5,510,393
'Neatest' way of adding javascript to a page footer in asp.net
<p>Whenever i want to add a javascript library programatically, say jquery for example, it generally involves making sure there is a <code>placeholder</code> at the footer of my page, then calling a codebehind method that will take a link to the src as a parameter and return an <code>htmlgeneric</code> control, which is then added to this <code>placeholder</code>.</p> <p>Is this still the neatest way to do it, even with .net 4.0 out?</p>
c# asp.net javascript
[0, 9, 3]
3,537,411
3,537,412
Select asp:Label text on click event
<p>I have a label on my page and want to select the text of this label whenever user click on it so it will be easier for user to Ctrl+C text on this label. I tried using <code>SomeLabel.Attributes["onclick"] = "javascript:this.select();";</code> but it didn't work. Is there any way to do this?</p>
javascript jquery asp.net
[3, 5, 9]
2,258,034
2,258,035
Issue in Export And Import Data To Excel File In ASP.NET
<p>I am import the data from a data table to excel file using following code : </p> <pre><code>public void ExportDataTable(DataTable dt) { string attachment = "attachment; filename=EmployeeList.xls"; HttpContext.Current.Response.Clear(); HttpContext.Current.Response.AddHeader("content-disposition", attachment); HttpContext.Current.Response.ContentType = "application/vnd.ms-excel"; string sTab = ""; foreach (DataColumn dc in dt.Columns) { HttpContext.Current.Response.Write(sTab + dc.ColumnName); sTab = "\t"; } HttpContext.Current.Response.Write("\n"); int i; foreach (DataRow dr in dt.Rows) { sTab = ""; for (i = 0; i &lt; dt.Columns.Count; i++) { HttpContext.Current.Response.Write(sTab + dr[i].ToString()); sTab = "\t"; } HttpContext.Current.Response.Write("\n"); } HttpContext.Current.Response.End(); } </code></pre> <p>It is working fine. </p> <p>Now when i am importing the this excel file to data table then following error accurs:</p> <p>External table is not in the expected format. </p> <p>Here is my code to export the excel file to data table :</p> <pre><code> public static DataTable excelToDataTable(string file) { DataTable dt = new DataTable(); OleDbConnection oledbcn = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source= Server.MapPath("EmployeeList.xls").ToString(); Extended Properties='Excel 8.0;HDR=Yes;IMEX=1'"); string SheetName = "EmployeeList"; oledbcn.Open(); OleDbCommand cmd = new OleDbCommand(@"SELECT * FROM [" + SheetName + "$]", oledbcn); OleDbDataAdapter oledbda = new OleDbDataAdapter(); oledbda.SelectCommand = cmd; oledbda.Fill(dt); oledbcn.Close(); return dt; } </code></pre> <p>Please resolve my issue guys in such way that i can export and import MSOffice 2003 and 2007 excel files.</p> <p>Thanks, Rajbir</p>
c# asp.net
[0, 9]
4,896,845
4,896,846
Call an event on Web Control Load
<p>I am loading my with web controls and loading them based on the URL parameters.</p> <p>I need to load a gridview if the user is in :&amp;cat=8</p> <p>My web control has a method which I need to call. One of its parameters is a session which is created only when the category is 8.</p> <p>Technically I need a way of calling methods within my web control from my page. Placing it on page_load results in an error.</p> <p>Thanks</p>
c# asp.net
[0, 9]
1,153,242
1,153,243
Highlight StartDate to EndDate Calendar
<p>How can i highlight Dates from StartDate to EndDate using asp Calendar C#</p> <p>when i first Click a Date to Calendar it will be the first Date and when i Click another Date i will be the last Date and highlights the Date</p> <p>from StartDate to EndDate</p> <p>I hope someone can answer my question</p>
c# asp.net
[0, 9]
4,717,813
4,717,814
Can you invoke a python routine inside an Android App?
<p>There are some cool python scripts out there and I was wondering what is involved in running one within an Android device? Is this possible? I don't want to call out to a server. Thanks</p>
android python
[4, 7]
1,560,994
1,560,995
jquery "NOW" event?
<p>i've got a jquery image preview plugin that i use. i use it like this:</p> <pre><code>$('a.preview').live('mouseover', function() { $(this).imgPreview({ preloadImages: 'true', }); }); </code></pre> <p>i want the imgPreview function to be executed after an jquery ajaxcall that will insert an image in the DOM. so i wanna execute it to preload the image.</p> <p>any ideas?</p>
javascript jquery
[3, 5]
3,405,462
3,405,463
Adding variable to string in ASP.net
<p>Ok, so it's easy in VB, but I can't figure it out in C#:</p> <pre><code>SqlCommand cmd = new SqlCommand("SELECT COUNT(*) FROM tblUsers WHERE username = '" &amp; username &amp; "'", cn); </code></pre> <p>This throws</p> <pre><code> CS0019: Operator '&amp;' cannot be applied to operands of type 'string' and 'string' </code></pre> <p>Googled it and can't find an answer, help this newbie here please!</p>
c# asp.net
[0, 9]
4,209,943
4,209,944
Browser back button and state retains?
<p>I have an eCommerce system where I have listed the Recently Viewed Count and Items as viewer browse its details page.</p> <p>When the user had viewed any item using any browser and click the Back button of the Browser then, recently viewed items module doesn't get refresh at all. But on reloading the url(Refresh), the module gets refreshed and shows the recently viewed items and Count?</p>
c# javascript jquery
[0, 3, 5]
3,642,171
3,642,172
Can anyone explain this bizarre behavior in jQuery next?
<p>It works:</p> <pre><code>&lt;div class="xpav"&gt; Create &lt;/div&gt; &lt;div class="apr" style="display: none;"&gt; sometext &lt;/div&gt; &lt;script&gt; $('.xpav').click(function() { $(this).next(".apr").slideDown("fast"); }) &lt;/script&gt; </code></pre> <p>It doesn't:</p> <pre><code>&lt;div class="xpav"&gt; Create &lt;/div&gt; &lt;br /&gt; &lt;div class="apr" style="display: none;"&gt; sometext &lt;/div&gt; &lt;script&gt; $('.xpav').click(function() { $(this).next(".apr").slideDown("fast"); }) &lt;/script&gt; </code></pre> <p>Why <br /> breaks it?</p>
javascript jquery
[3, 5]
3,930,826
3,930,827
C#'s opposite to PHP's bin2hex()
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/311165/how-do-you-convert-byte-array-to-hexadecimal-string-and-vice-versa-in-c">How do you convert Byte Array to Hexadecimal String, and vice versa, in C#?</a><br> <a href="http://stackoverflow.com/questions/321370/convert-hex-string-to-byte-array">Convert hex string to byte array</a> </p> </blockquote> <p>I am encrypting a string in PHP and I would like to decrypt this string using C#. The last line of the encryption function will return a hexadecimal representation of the encrypted string. Unfortunately for me, though, I cannot figure out how to reverse this conversion through C#. I will post my source below:</p> <h3> PHP: </h3> <pre><code>echo encrypt('hello'); // Returns '60eb44e27e73ba1d' function encrypt($string) { //Key $key = "12345678"; //Encryption $cipher_alg = MCRYPT_TRIPLEDES; $iv = mcrypt_create_iv(mcrypt_get_iv_size($cipher_alg,MCRYPT_MODE_ECB), MCRYPT_RAND); $encrypted_string = mcrypt_encrypt($cipher_alg, $key, $string, MCRYPT_MODE_ECB, $iv); return bin2hex($encrypted_string); } </code></pre> <p>The only issue I am having is the hex2bin conversion in C# - the rest of the decryption function I have working. Feel free to ask for any further details.</p> <p>Hopefully there is some simple solution out there that I don't know about. I appreciate any responses.</p> <p>Regards,</p> <p>Evan</p>
c# php
[0, 2]
346,347
346,348
jQuery/Javascript Multiple Array Combinations
<p>I have been trying to find a solution to this with no avail. The idea of what i'm trying to achieve is to be able to find all unique combinations of multiple lists. So, let's say I have 3 lists of checkboxes (but this is an unknown number in the real-life application), Colour, Size, Pack Size. The items in the list's will be unqiue.</p> <pre><code>[0] =&gt; ['blue', 'green'] [1] =&gt; ['small', 'medium', 'large'] [2] =&gt; ['Pack Of 6', 'Pack Of 8'] </code></pre> <p>I will want to get "<strong>Blue, Small, Pack Of 6</strong>", "<strong>Blue, Medium, Pack Of 6</strong>", "<strong>Blue, Large, Pack Of 6</strong>", "<strong>Blue, Small, Pack Of 8</strong>", "<strong>Blue, Medium, Pack Of 8</strong>" etc.. The ordering isn't important, but would be nice to have it logically grouped. </p> <p>I already have the lists pulled out into an array using jQuery:</p> <pre><code> options = []; jQuery('.option-types').each(function(){ opts = []; jQuery('input:checked', this).each(function(){ opts.push(jQuery(this).next().text()); }); options.push(opts) }); </code></pre> <p>If there is a recursive functional path to answer this that would be ideal, as like i said the number of lists could be anything, aswell as the contents of the lists.</p> <p>Hope you guys and girls can help, this is doing my head in.</p> <p>Cheers - Dan</p>
javascript jquery
[3, 5]
2,841,868
2,841,869
Running a program on a server
<p>I want to build an Android application that downloads an XML file from a web server and displays its contents in a readable format. My problem is generating that XML file. Basically I want to run a program, say, every 30 minutes that downloads a web page (as that data is not easily accessible), parses it, generates said XML file and puts it somewhere for the Android application to download. Now, I was writing a Java application to do this, but it came to me: where am I going to run this? I thought of having a laptop permanently running at home, but there must be a better alternative. I have online hosting, but it is very simple. It does not even include SSH.</p> <p>Any ideas?</p> <p><strong>Edit:</strong> as per your suggestions, I checked and yes, my cPanel does have a "Cron Jobs" section. I will now investigate it. Thank you so much for your help.</p>
java android
[1, 4]
4,822,525
4,822,526
js number +1 problem
<p>I need click <code>div.toggle1</code>,control slideup, slidedown the <code>div#text1</code>,</p> <p>click <code>div.toggle7</code>,control slideup, slidedown the <code>div#text7</code>.</p> <p>here is my code, also in <a href="http://jsfiddle.net/qHY8K/" rel="nofollow">http://jsfiddle.net/qHY8K/</a> my <code>number +1</code> not work, need a help. thanks.</p> <p>html</p> <pre><code>&lt;div class="toggle1"&gt;click&lt;/div&gt; &lt;div id="text1"&gt;text1&lt;/div&gt; &lt;div class="toggle7"&gt;click&lt;/div&gt; &lt;div id="text7"&gt;text2&lt;/div&gt; </code></pre> <p>js code</p> <pre><code>jQuery(document).ready(function() { counter = 0; for(i=1;i&lt;11;i++){ (function(i){ counter = counter +1; $('.toggle'+counter).toggle(function(){ $('#text'+counter).css('display','none'); }, function() { $('#text'+counter).css('display','block'); }); })(i); }; }); </code></pre>
javascript jquery
[3, 5]
175,960
175,961
Clear Server Cache on Browser Close Using ASP.NET
<p>for a secure web application , How to clear an item in server Cache on Browser close.</p>
c# javascript asp.net
[0, 3, 9]
2,816,606
2,816,607
sleep in JavaScript?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/758688/sleep-in-javascript">Sleep in Javascript</a> </p> </blockquote> <p>I want to make a <strong>sleep</strong> function in JavaScript, I have to stop any code execution before the user performs an action (like the alert() behaviour)</p> <p>What I need is exactly: what should I insert here to make it work?</p> <pre><code>window.alert = function(message){ var dialog = $('&lt;div&gt;'+message+'&lt;/div&gt;').dialog({ title:'Alert', buttons:{ 'Ok': function(){ $(this).dialog('close').data('open', false); $(this).remove(); } } }).data('open', true); //What to insert here? } </code></pre>
javascript jquery
[3, 5]
1,435,554
1,435,555
Compare years and month with jQuery
<pre><code>var onemonth = 3; var oneyear = 2005; var twomonth = 10; var twoyear = 2000; </code></pre> <p>How can i split this and compare? In this example is:</p> <pre><code>var firstdate = onemonth + oneyear; var seconddate = twomonth + twoyear; if(firstdate &lt; seconddate){ alert('error'); } </code></pre> <p>How is the best method for compare two date if i have only month and year?</p> <p>LIVE: <a href="http://jsfiddle.net/26zms/" rel="nofollow">http://jsfiddle.net/26zms/</a></p>
javascript jquery
[3, 5]
1,861,703
1,861,704
Getting Missing ) argument from below script any suggestions why?
<pre><code> &lt;form name="formone" id="optionsform"&gt; &lt;fieldset&gt; &lt;label&gt;&lt;input type="radio" name="group1" id="ac-yes" value="1"&gt;Yes&lt;/label&gt; &lt;label&gt;&lt;input type="radio" name="group1" id="ac-no" value="0"&gt;No&lt;/label&gt; &lt;label&gt;&lt;input type="radio" name="group2" id="bt-yes" value="2"&gt;Yes&lt;/label&gt; &lt;label&gt;&lt;input type="radio" name="group2" id="bt-no" value="0"&gt;No&lt;/label&gt; &lt;a href="varible-address"&gt;CONTINUE&lt;/a&gt; &lt;/fieldset&gt; &lt;/form&gt; &lt;script&gt; $(function(){ var urls = new Array(); urls[0]='http://myurl1/';// no + no urls[1]='http://myurl2/';// yes + no urls[2]='http://myurl3/';// no + yes urls[3]='http://myurl4/';// yes + yes $('input[type=radio]').click(fonction(){ var score = 0; $('input[type=radio]:checked').each(function(){score+=parseInt($(this).val()}); $('a').attr('href',urls[score]); } }); &lt;/script&gt; </code></pre>
javascript jquery
[3, 5]
4,177,296
4,177,297
Run PHP Remotely
<p>I have a PHP script that i want to run on users sites remotely, that ties in with their account on mine. So basically it is software-as-a-service. The user would copy and paste certain code to their site and it would run strictly php. I am unsure how to do this.</p> <p>Are you able to run php remotely and how would you do it if for example my site was:</p> <p>mydomain.com</p> <p>and the users domain would be:</p> <p>customerdomain.com</p>
php javascript
[2, 3]
6,025,668
6,025,669
How do I re-create "this" inside an event handler?
<p>I've got an event handler that was pre-bound to a specific variable (via <code>$.proxy</code>). As a result, when the handler is triggered, <code>this</code> isn't the normal value, it's my pre-bound value.</p> <p>I'd like to recover <code>this</code> using the handler's <code>event</code> argument, but <code>this</code> doesn't seem to map directly to <code>event.currentTarget</code>, <code>event.target</code>, or any other event property.</p> <p>So, I've tried digging through the jQuery source, but the event callback stuff is very convoluted, and I can't figure out exactly what <code>this</code> is getting set to. Does anyone know how simulate a jQuery event handler <code>this</code> using only the event argument?</p> <p><strong>* * Edit * *</strong></p> <p>Just to clarify, here's an example:</p> <pre><code>var boundThis = {foo: 'bar'} var handler = $.proxy(function(event) { // Because of the $.proxy, this === boundThis // (NOT the normal "this" that jQuery would set) // In theory event has everything I need to re-create this, // but I'm having trouble figuring out exactly how // Here's a naive/non-functional example of what I'm trying to do jQueryThis = event.target; // If only this worked ... }, boundThis); $(someElement).click(handler); </code></pre>
javascript jquery
[3, 5]
5,120,079
5,120,080
How to disable browser close button
<p>is there way to disable browsers close button and it will open after voting my polls. like firefox using JavaScript or jquery? i created an auto open browser using C# for every 10am it will open my intranet web page and i want all viewers to vote my polls before leaving my page.. </p>
javascript jquery
[3, 5]
1,251,606
1,251,607
Looping over elements in jQuery
<p>I want to loop over the elements of an HTML form, and store the values of the &lt;input&gt; fields in an object. The following code doesn't work, though:</p> <pre><code>function config() { $("#frmMain").children().map(function() { var child = $("this"); if (child.is(":checkbox")) this[child.attr("name")] = child.attr("checked"); if (child.is(":radio, checked")) this[child.attr("name")] = child.val(); if (child.is(":text")) this[child.attr("name")] = child.val(); return null; }); </code></pre> <p>Neither does the following (inspired by jobscry's answer):</p> <pre><code>function config() { $("#frmMain").children().each(function() { var child = $("this"); alert(child.length); if (child.is(":checkbox")) { this[child.attr("name")] = child.attr("checked"); } if (child.is(":radio, checked")) this[child.attr("name")] = child.val(); if (child.is(":text")) this[child.attr("name")] = child.val(); }); } </code></pre> <p>The alert always shows that <code>child.length == 0</code>. Manually selecting the elements works:</p> <pre> >>> $("#frmMain").children() Object length=42 >>> $("#frmMain").children().filter(":checkbox") Object length=3 </pre> <p>Any hints on how to do the loop correctly?</p>
javascript jquery
[3, 5]
4,049,501
4,049,502
Adding class to show div has no effect on Android when event is jQuery keyup
<p>The following code is supposed to make a div visible as soon as a single character is entered into an input field. As soon as there are no characters entered the input should be hidden again. </p> <p>This works fine for every desktop browser ive tested on and also on iPhone. However on Android nothing happens. </p> <pre><code> $("#filter").keyup(function () { if ( !$('input#filter').val().length == 0 ){ $('#filter-close').removeClass('hidden'); //alert('remove hidden'); } else { $('#filter-close').addClass('hidden'); //alert('add hidden'); } }); </code></pre> <p>Initially I assumed it was an issue with the event not firing. To test this I added alerts (commented out in the code above) and it turns out the event is firing fine. </p> <p>Is there some bug with Android where classes added or removed while an input has focus are not applied, or are applied but the appropriate CSS isn't applied to the elements? Thanks </p>
jquery android
[5, 4]
5,561,758
5,561,759
jQuery is Refreshing the Page
<p>I am having a problem with JQuery: whenever a JQuery function is called, the page refreshes whenever an if block is executed.</p> <pre><code>$(".remove").click(function() { removeOption($(this)); }); function removeOption(obj){ if (obj.parent().siblings().size() &gt; 1){ obj.parent().remove(); } } </code></pre> <p>IF the (obj.parent()...) block is executed, the page refreshes. It's not limited to the function: if I change the if (obj.parent()... ) to if (true), I have the same problem. I also have the problem if I put the removeOption(obj) as an anonymous function inside the first function. Could this be a bug in JQuery, or does anyone have any insight?</p>
javascript jquery
[3, 5]
174,418
174,419
Why my query return null
<p>I want to ask why query return null and not update what i want. Sorry I'm still new with <code>asp.net</code> and <code>c#</code></p> <pre><code>myquery = "UPDATE kenderaan SET buatan = " + "'" + carmake + "'" + "," + "model = " + "'" + carmodel + "'" + "," + "no_enjin = " + "'" + carenjin + "'" + "," + "cc = " + carcc + "," + "seatCapacity = " + carseat + "," + "tahunBuatan = " + caryear + " WHERE no_kenderaan = " + "'" + carid + "'" + "," + "AND ic = " + "'" + cusid + "'"; connection = new DbConnection(); connection.Update(myquery); </code></pre>
c# asp.net
[0, 9]
1,241,453
1,241,454
Disabled radio button losing value after postback
<p>I have two radio buttons that are disabled with javascript when the page loads. <code>RadioButton1</code> is checked by default. When I click the button to do a postback, the <code>RadioButton1</code> is no longer checked.</p> <p>Anyone know why ?</p> <p>Here's my code sample. The code behind is empty. </p> <pre><code>&lt;asp:RadioButton ID="RadioButton1" runat="server" GroupName="group" Checked="true"/&gt; &lt;asp:RadioButton ID="RadioButton2" runat="server" GroupName="group" /&gt; &lt;asp:Button ID="Button1" runat="server" Text="Button"&gt;&lt;/asp:Button&gt; &lt;script type="text/javascript"&gt; window.onload = function () { var RadioButton1 = document.getElementById('&lt;%= RadioButton1.ClientID %&gt;'); var RadioButton2 = document.getElementById('&lt;%= RadioButton2.ClientID %&gt;'); RadioButton1.disabled = true; RadioButton2.disabled = true; }; &lt;/script&gt; </code></pre>
javascript asp.net
[3, 9]
159,300
159,301
How can i make URLEncoding not encode colon?
<p>I have a JSONObject:</p> <pre><code>{user:{"firstname":"testuser","surname":"æøå"}} </code></pre> <p>So i have these special characters in the object</p> <p>I URLEncode the jsonString i have.</p> <pre><code>urlEncodedJsonReq = URLEncoder.encode("{user:{\"firstname\":\"testuser\",\"surname\":\"æøå\"}}","UTF-8"); </code></pre> <p>I get a response from the server: "The URI you submitted has disallowed characters.". This is the encoded url: <code>serverurl/%7Buser%3A%7B%22firstname%22%3A%22testuser%22%2C%22surname%22%3A%22%C3%A6%C3%B8%C3%A5%22%7D%7D</code></p> <p>But what i need it to be:</p> <pre><code>%7Buser:%7B%22firstname%22:%22testuser%22%2C%22surname%22:%22%C3%A6%C3%B8%C3%A5%22%7D%7D </code></pre> <p>Is this possible in any reasonable way?</p> <p>Thanks in advance</p>
java android
[1, 4]
4,794,229
4,794,230
input field, only numbers jquery/js
<p>I have a input field where i only wish users to type numbers </p> <p>html: <code>&lt;input id="num" type="text" name="page" size="4" value="" /&gt;</code> </p> <p>jquery/ js: </p> <pre><code> $("#num").keypress(function (e){ if( e.which!=8 &amp;&amp; e.which!=0 &amp;&amp; (e.which&lt;48 || e.which&gt;57)){ return false; } }); </code></pre> <p>hope someone can help me. </p> <p>btw: I'm not interesting in a larger jquery plugin to make the function work. (I have found some jquery-plugins , but there must be som other ways to fix it, with a smaller code)</p>
javascript jquery
[3, 5]
605,598
605,599
My function returns empty. why?
<p>I know that this is a basic question but I am stuck with it somewhere in my code. I got that code from somewhere but now I am modifying it according to my need.</p> <p>What does jQuery('#selector') do? In my code it always return empty.</p> <p>Here is my code</p> <pre><code>query: function (selector, context) { var ret = {}, that = this, jqEls = "", i = 0; if(context &amp;&amp; context.find) { jqEls = context.find(selector); } else { jqEls = jQuery(selector); } ret = jqEls.get(); ret.length = jqEls.length; ret.query = function (sel) { return that.query(sel, jqEls); } return ret; } </code></pre> <p>when I call this query function then I pass selector as parameter. When I do <code>console.log(selector)</code> it does have all the selectors which I need in this function. But the problem is on this line <code>jqEls = jQuery(selector);</code>. when I do <code>console.log(jqEls)</code> after this it returns empty thus the whole function returns empty.</p> <p>Can I use something different then this to make it work?</p>
javascript jquery
[3, 5]
1,319,891
1,319,892
Costs of Switching to Java
<p>I'm a C# dev and I have plans of starting to develop apps targeting Android, which of course means Java. I have heard good things about Mono for Android and the idea of reusing my skill set is appealing, however the licensing cost (for now) is a bit prohibitive to me. On the other hand, from what I can see, Java is very similar to C#, so I'm predicting that shifting my skills to it will be more or less easy (easier than shifting to Obj-C I guess). </p> <p>Am I wrong in assuming that?</p> <p>Are there any hidden costs I'm blind to?</p>
java c# android
[1, 0, 4]
2,663,434
2,663,435
How to 'bind' Text property of a label in markup
<p>Basically I would like to find a way to ddo something like:</p> <pre><code>&lt;asp:Label ID="lID" runat="server" AssociatedControlID="txtId" Text="&lt;%# MyProperty %&gt;"&gt;&lt;/asp:Label&gt; </code></pre> <p>I know I could set it from code behind (writing lId.Text = MyProperty), but I'd prefer doing it in the markup and I just can't seem to find the solution. (MyProperty is a string property) cheers</p>
c# asp.net
[0, 9]
5,018,423
5,018,424
jQuery exception if element doesn't exist
<p>I working with jQuery and I need to get anytime and anywere exception (with any operation), if I attach some event or try to perform some action with elements (got from selector) that don't exist. Is there some internal "strict" mode in jQuery for this issue?</p>
javascript jquery
[3, 5]
717,599
717,600
Condensing Javascript/jQuery Code
<p>I'd like to start by thanking anyone who can help me condense this piece of Javascript/jQuery code.</p> <pre><code> jQuery(function() { jQuery('#pitem-1').click(function(e) { jQuery("#image-1").lightbox_me({centered: true, onLoad: function() { jQuery("#image-1").find("input:first").focus(); }}); e.preventDefault(); }); jQuery('#pitem-2').click(function(e) { jQuery("#image-2").lightbox_me({centered: true, onLoad: function() { jQuery("#image-2").find("input:first").focus(); }}); e.preventDefault(); }); jQuery('#pitem-3').click(function(e) { jQuery("#image-3").lightbox_me({centered: true, onLoad: function() { jQuery("#image-3").find("input:first").focus(); }}); e.preventDefault(); }); jQuery('table tr:nth-child(even)').addClass('stripe'); }); </code></pre> <p>Basically each #pitem-ID opens the same #image-ID in a popup.</p> <p>Thanks again to anyone who can help.</p> <p>Jack</p>
javascript jquery
[3, 5]
5,465,040
5,465,041
Jquery tablesorter plugin to sort format: 16-Jan-2010
<p>I'm using jQuery Tablesorter and I have a problem sorting tables with date values of format: 16-Jan-2010</p> <p>How do I make them sort properly?</p> <p>Thanks in advance!</p>
javascript jquery
[3, 5]
3,445,896
3,445,897
How to avoid ID-conflicts when on-the-fly generating elements
<p>Say I have this mockup-code:</p> <pre><code> button.click(function(){generateForm();} function generateForm(){ div.append(&lt;input type='text' id='x'&gt;); } </code></pre> <p>I will need the ID in order to access the element individually. </p> <p><strong>What is the best way to avoid having ID-conflicts in a scenario like this ?</strong></p>
javascript jquery
[3, 5]
4,365,435
4,365,436
Find and assign content to a variable
<p>What I need is to find an element which have <em>class="selected"</em> and than assign content of that element to a variable.</p> <pre><code>&lt;a href="#"&gt;This is the content&lt;/a&gt; &lt;a href="#" class="selected"&gt;This is the content&lt;/a&gt; &lt;a href="#"&gt;This is the content&lt;/a&gt; </code></pre> <p>Any help? Thank you</p>
javascript jquery
[3, 5]
5,730,089
5,730,090
How to call a popup window in C#
<p>I have webform1,webform2. I have a submit button in webform1.When the submit is clicked, it has to perform some function then based on the result i have to show different data (let say accept/decline images) in the webform2(POPUP). When this popup is displayed user should not be allowed to make any changes to webform1.</p> <p>Let me know how to achieve this. </p> <p>Thanks in advance</p>
c# javascript asp.net
[0, 3, 9]
46,814
46,815
Android - Listview search inner-text by ignoring Case
<p>I am trying to implement "Listview with search" functionality, in which i am successful to search with the word that we trying to enter in the edittext. But i want to implement to search with inner-text from a string. for that i have tried to implement:</p> <pre><code>string.contains(txtSearch.getText().toString()) </code></pre> <p>I am successful in this as well. But <strong>there is a still problem of "Case sensivity", how do i search for inner-text with ignoring case ?</strong> </p> <p>Can you suggest me what should do i with <strong><code>Contains()</code></strong> to ignore case ?</p>
java android
[1, 4]
1,220,708
1,220,709
Soap service credential available from InputStream
<p>For a project I am doing, I am using a SOAP service to access some data from another system. I added the SOAP service as a web reference to my ASP.NET (C#) project.</p> <p>Now, the service is kinda complicated, because a user has to be authenticated first with a cookie (don't ask). So what we did was:</p> <ul> <li>The user accesses our website.</li> <li>Website redirects the user to a logon page on the server where the service is located.</li> <li>User logs on, and a FormsAuthentication.SetAuthCookie is performed</li> <li>User is redirected back to our site. Which then forwards the user to a page which should contain data from the webservice.</li> </ul> <p>That page instantiates the webservice as an object like this:</p> <pre><code>MyService.MyServiceservice = new MyService.MyService(); </code></pre> <p>Then I put the credentials in (now I do it hardcoded):</p> <pre><code>service.PreAuthenticate = true; service.Credentials = new NetworkCredential("Wim", "mypass"); </code></pre> <p>When I call a method on that service, I want the Global.asax on the server containing the server, to be able to "catch" the username and password from the request. But somehow I cannot fetch it.</p> <p>Don't ask why it has to be done like this, lets call it .. unfortunate :P</p> <p>Does anyone know how to fetch the username and password from that request on the server side, preferable in the Global.asax Application_BeginRequest.</p>
c# asp.net
[0, 9]
3,391,630
3,391,631
need to convert WinForm to WebForm
<p>i have C# Winform program and i need to convert it to Webform.</p> <p>can i get any simple sample for how to show database grid on screen, </p> <p>add new, update and delete ?</p> <p>i try to show table on screen like this:</p> <pre><code>SQL = "SELECT * FROM MEN order by Lname"; dsView = new DataSet(); adp = new SqlDataAdapter(SQL, Conn); adp.Fill(dsView, "MEN"); adp.Dispose(); GridView1.DataSource = dsView.Tables["MEN"].DefaultView; </code></pre> <p>but i dont see nothing</p>
c# asp.net
[0, 9]
540,359
540,360
Find an object and its properties within a larger object with javascript/jquery
<pre><code>family = { 'person1':[{"id":"1111","name":"adam", "sex":"male", "born":"USA"}], 'person2':[{"id":"2222","name":"sarah", "sex":"female", "born":"Canada"}], 'person3':[{"id":"3333","name":"adam", "sex":"male", "born":"USA"}] }; </code></pre> <p>Given the family object above, how do I extract all the properties (id, name, sex, born) of one of the person objects that have a specific id (or name) value? eg id=1111</p> <p>So ideally I can get a new object personInQuestion that I can manipulate, where:</p> <pre><code>personInQuestion = {"id":"1111","name":"adam", "sex":"male", "born":"USA"} </code></pre>
javascript jquery
[3, 5]
4,894,664
4,894,665
How to make more than one div appear using jQuery
<p>I feel I am very close to finishing this. I have a form with an "Add Children" button that when pressed will make a div show. The form has 15 divs hidden (#child1 - #child15). I have it working to show only the first row (#child1).</p> <p>My problem is that when the button is pressed again, the next row (#child2, #child3, etc...) should appear and I am not sure how to get it to show. I tried putting in the counter but I am new to jQuery and any help would be very much appreciated. I don't expect this to be a difficult issue, just one that is eluding my novice ability.</p> <p>Here is the jQuery. If i need to edit or add more code to help the question please let me know. Thanks in advance!</p> <pre><code>&lt;script type="text/javascript"&gt; var counter=0 $(document).ready(function() { $('#addChildren').click(function() { $('#child1').show(function() { counter++ }); }); }); &lt;/script&gt; </code></pre>
javascript jquery
[3, 5]
638,085
638,086
Converting keyboard input numbers into a numeric type
<p>I m a bit stuck here. Though I know how to convert keyboard input character into usable character in C#.</p> <pre><code>char ch = (char)console.read(); </code></pre> <p>I want to read numbers nd make them behave as numbers in my program.</p> <p>If I enter 5 from keyboard I want to store as 5 (mathematical) not character 5.</p>
c# asp.net
[0, 9]
2,892,011
2,892,012
How to disable/hide the close button of firefox browser using asp.net?
<p>I want to disable or hide the close button that we get on the top right side of the firefox browser. Please help me! </p> <p>Thanks</p>
c# asp.net
[0, 9]
3,462,043
3,462,044
Modifying jQuery $.ajax() success method during request
<p>In the web app I am working on there is potential for very long running ajax queries.</p> <p>I'm using jQuery's $.ajax method to do something like:</p> <pre><code>this._xhr = jQuery.ajax({ type: "GET", url: "/path/to/service", data: "name=value", success: function(data, message){ // handle a success }, dataType: "json" }); </code></pre> <p>Is there a way to modify the success callback after this._xhr.readyState = 2 (loaded) and before this._xhr.readyState = 4 (completed)</p> <p>I tried modifying this._xhr.onreadystatechange but found that jQuery does not define onreadystatechange.</p>
javascript jquery
[3, 5]
3,658,679
3,658,680
changing jquery 'this' and 'next', to a specific element
<p>Im working with the following code;</p> <pre><code>&lt;a href=\"#\" onClick=\"if($(this).next('div').css('display') == 'none') { $(this).next('div').show('fast'); } else { $(this).next('div').hide('fast'); } return false;\"&gt;Link&lt;/a&gt; </code></pre> <p>What i need to do, is change the part <code>if($(this).next('div')</code>, to target a specific element ID, not the next one from current location.</p> <p>Any ideas are much appreciated, as well as explinations.</p> <p>Thanks in advance.</p>
javascript jquery
[3, 5]
4,352,458
4,352,459
creating and running a client script from asp.net
<p>I want to create a script like this an run that :(below is attemp)</p> <pre><code>protected void txtPassword_TextChanged(object sender, EventArgs e) { script = "&lt;script type='text/javascript'&gt;"; script += "function showmsg(){"; script += "$('#msg').slideDown('normal');"; script += "$('#msg span').addClass('message');"; script += "setTimeout('showmsg',100);"; script += "}"; script += "&lt;/script&gt;"; ClientScript.RegisterClientScriptBlock(this.GetType(), "ShowMessage",script); } </code></pre> <p>Where is my mistake ? why there is no run ? </p>
c# asp.net
[0, 9]
4,014,642
4,014,643
Reload the same page when click
<p>I want to Reload the same page when I click on reload button.any one give the C# code for achieve this?</p>
c# asp.net
[0, 9]
5,878,783
5,878,784
Error: Authority expected at index 7: http://...!!! Explain please?
<p>I have a url for JSON feeds that i have to fetch from and then parse them to save in my DB. But i am getting the following error in the url when i try to make request to this url using HttpGet method. This Url show the json feeds fine when i open it in browser. For privacy reason i am not posting the original url rather a dummy one.</p> <p>URL is like:</p> <pre><code> http://api.test.com/services/json?method=%22cviews.get%22&amp;view_name=%22section_gallery_slides%22&amp;display_id=%22attachment_1%22&amp;format_output=1&amp;args=[123456]&amp;limit=10 </code></pre> <p>and Error i am getting is:</p> <pre><code>10-18 12:29:10.510: DEBUG/ImageManager(22082): Error: java.io.IOException: Authority expected at index 7: http:// </code></pre> <p>Please tell me what's going wrong and where, any help is appreciated.</p>
java android
[1, 4]
1,962,755
1,962,756
Getting values to the Variable Dynamically
<p>How can I get Form field values dynamically without submitting the page to the variable in the same page ?</p>
javascript jquery
[3, 5]
5,292,634
5,292,635
asp.Net prevent server side link with javascript
<p>I have an ImageButton as follows</p> <pre><code>&lt;asp:ImageButton OnClientClick="javascript:merge();" ID="MenuLinkMerge" Text="Merge" ToolTip="Merge" SkinID="Merge32" runat="server" onclick="MenuLinkMerge_Click" /&gt; </code></pre> <p>merge() will call</p> <pre><code>function merge() { if (IDList.length &gt; 0) { alert("go"); return true; } else { alert("No companies were selected."); return false; } } </code></pre> <p>but whether I return true or false the MenuLinkMerge_Click is always called server side and the page is redirected. I only want the page to change if IDList.length > 0 otherwise display the alert and do nothing.</p> <p>How do I accomplish this?</p>
javascript asp.net
[3, 9]
4,573,338
4,573,339
System.Web.HttpException: This is an invalid script resource request
<p>I get this error when pushing our website to our clients production server however the page works absolutely fine on their dev / test servers. What causes this error (considering I am not using any web resources myself, though I am using the asp.net ajax toolkit).</p>
c# asp.net
[0, 9]
5,193,806
5,193,807
gridview.getElementsByTagName("input") is giving Inputs Zero Why?
<pre><code>&lt;script language="javascript" type="text/javascript"&gt; function ValidateNew() { var gridview = document.getElementById('ctl00_cp_GridViewKRIlib'); if (gridview != null) { var Inputs = gridview.getElementsByTagName("input"); for (i = 0; i &lt; Inputs.length; i++) { if (Inputs[i].type == 'text') { if (Inputs[i].value == "") { alert('Enter the value!'); Inputs[i].focus(); return false; } } } } } </code></pre> <p>i am calling this funtion in </p> <pre><code>&lt;asp:TemplateField HeaderText="Edit"&gt; &lt;ItemTemplate&gt; &lt;asp:LinkButton ID="linkbuttonNew" runat="server" Text="New" CommandName="New" CommandArgument='&lt;%#Container.DataItemIndex%&gt;' OnClientClick="javascript:return ValidateNew();"&gt; &lt;/asp:LinkButton&gt; </code></pre> <p>INPUTS Are Showing zero Why?</p>
asp.net javascript
[9, 3]
132,635
132,636
What's the equivalent of "has_key" in javascript?
<pre><code>if dictionary.has_key('school'): </code></pre> <p>How would you write this in javascript?</p>
javascript python
[3, 7]
690,447
690,448
remove attribute of html tag
<p>Is it possible to remove the attribute of the first html tag? So, this:</p> <pre><code>&lt;div style="display: none; "&gt;aaa&lt;/div&gt; </code></pre> <p>becomes </p> <pre><code>&lt;div&gt;aaa&lt;/div&gt; </code></pre> <p>from the following:</p> <pre><code>&lt;div style="display: none; "&gt;aaa&lt;/div&gt; &lt;a href="#" style="display: none; "&gt;(bbb)&lt;/a&gt; &lt;span style="display: none; "&gt;ccc&lt;/span&gt;​ </code></pre> <p>Many thanks in advance.</p>
javascript jquery
[3, 5]
1,006,899
1,006,900
Beginners question: Variable in Javascript
<p>I'm new to javascript and cant get this little thing to work. (all external scripts a of course loaded)</p> <p>I have this jQuery script:</p> <pre><code>$('a.Link').click(function(){ autoComp('City'); }); function autoComp(strFormName) { var Company = 'Adobe Apple Microsoft'.split(" "); var City = 'London Paris Berlin'.split(" "); $('#'+strFormName).autocomplete(strFormName) } </code></pre> <p>I cant get it to work. I've discovered that the problem is the last "strFormName" after .autocomplete</p> <p>Appreciate all the help I can get.</p>
javascript jquery
[3, 5]
2,357,235
2,357,236
How to close the box if click anywhere?
<p>I have an code that the function is autosuggestion. This code works good. And I just want to ask You about how to close the box after I input text in the textbox. In my code when I try to click anywhere, it didn't close the box. So what I want to do is when I click anywhere so the box must be close.</p> <p>Here is my jQuery:</p> <pre><code>$(document).ready(function() { $(".text_search").keyup(function() { var searchbox = $(this).val(); var dataString = 'searchword=' + searchbox; if (searchbox == '') {} else { $.ajax({ type: "POST", url: "search1.php", data: dataString, cache: false, success: function(html) { $("#display").html(html).show(); } }); } return false; }); });​ </code></pre> <p>HTML:</p> <pre><code>&lt;div class="search"&gt; &lt;form method="get" action="search.php" autocomplete="off"&gt; &lt;input class="text_search" type="text" name="q" id="q" value="Search people" onfocus="if (this.value == 'Search people') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Search people';}"&gt; &lt;/form&gt; &lt;/div&gt; &lt;div id="display"&gt; &lt;/div&gt; </code></pre>
javascript jquery
[3, 5]
5,866,732
5,866,733
How to replace numbers with #
<p>Hi i have an Account number which is 8 digits long. How can i loop through it and replace the numbers with # and only display the last digit?</p>
c# asp.net
[0, 9]
242,364
242,365
activity_main error
<p><code>Activity_main.xml</code> is present but still its giving a error in <code>MainActivity.java</code> Can anyone tell me what is the error here?</p> <pre><code>package com.example.hellotabwidget; import android.R; import android.app.Activity; import android.os.Bundle; import android.view.Menu; public class MainActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.activity_main, menu); return true; } } </code></pre> <blockquote> <p>activity_main cannot be resolved or is not a field</p> </blockquote>
java android
[1, 4]
918,391
918,392
Table of content like JavaScript-Garden
<p>I want to create a table of content similar to <a href="http://bonsaiden.github.com/JavaScript-Garden/" rel="nofollow">JavaScript Gardens</a>. How do they determine which section is currently active and do you have any recommended JavaScript libraries that imlpement this behavior?</p> <p>Edit: So the thing I am asking for is how to know which section currently is active on the screen while the user is scrolling so that I can highlight that section in the table of content.</p>
javascript jquery
[3, 5]
3,954,886
3,954,887
Jquery "Delay is Not A Function" with Jquery 1.6.4
<p>I looked at some of the other questions on here pertaining to this problem but they were all using an older version of Jquery. I am having a problem with the latest version of jquery which I am grabbing from the goolge link:</p> <p><a href="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js" rel="nofollow">http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js</a></p> <p>When I execute this code it is giving the error "delay is not a function". It didn't use to do this and I can't figure out why it might be doing it now. </p> <pre><code>$('.news_title_main').children('ul').delay(1500).slideUp(1000).queue(function(next) { removeLast(); }); </code></pre>
javascript jquery
[3, 5]
247,219
247,220
How to choose each element from an array in their respective order? (jquery, JS)
<p>My code:</p> <p>I understand that my for loop assigns all array elements to the variable pickSound and that is why I am left with it only playing the last element. So how can I get it to play each element in order and start over once done. </p> <pre><code> function show() { var sounds = new Array( "audio/basement.mp3", "audio/roll.mp3", "audio/gatorade.mp3", "audio/half.mp3", "audio/hotdogs.mp3", "audio/keys.mp3", "audio/heil.mp3", "audio/money.mp3", "audio/ours.mp3", "audio/pass.mp3" ); for (var i = 0; i &lt; sounds.length; i++){ var pickSound = sounds[i]; } $('#divOne').html("&lt;embed src=\""+ pickSound +"\" hidden=\"true\" autostart=\"true\" /&gt;"); return false; }; </code></pre>
javascript jquery
[3, 5]
4,043,108
4,043,109
Does Validator.SetFocusOnError work without a postback?
<p>I have an ASP.net page with a RegexValidator. The RegexValidator successfully displays my validation error text when a user types a value out of range and navigates (tabs) off of the control. At that point, it doesn't set the focus to that control, even though I have SetFocusOnError="true".</p> <p>The focus does appear to be set when I click a button on that page. </p> <p>Is focus supposed to be set as soon as the javascript detects on issue?</p>
asp.net javascript
[9, 3]
4,633,756
4,633,757
How to Iterate through TreeView
<p>I have TreeView Web Control like</p> <pre><code>1 1.1 2 2.1 2.1.1 2.1.1.1 2.1.1.2 3 3.1 3.1.1 </code></pre> <p>If i have checked [CheckBox] 2.1.1.2 node , how can i get the result like 2,2.1,2.1.1 and 2.1.1.2 <br/> I have tried to use this <a href="http://msdn.microsoft.com/en-us/library/wwc698z7.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/wwc698z7.aspx</a> example but it doesnt give me required out put. Any Help or instructions how to achieve the required out put will be much appreciated.</p> <pre><code>private void PrintRecursive(TreeNode treeNode) { // Print the node. System.Diagnostics.Debug.WriteLine(treeNode.Text); MessageBox.Show(treeNode.Text); // Print each node recursively. foreach (TreeNode tn in treeNode.ChildNodes) { PrintRecursive(tn); } } // Call the procedure using the TreeView. private void CallRecursive(TreeView treeView) { // Print each node recursively. TreeNodeCollection nodes = treeView.CheckedNodes; // Modified to get the Checked Nodes foreach (TreeNode n in nodes) { PrintRecursive(n); } } </code></pre>
c# asp.net
[0, 9]
4,113,744
4,113,745
Detect if capslock is down
<p>What I need is to detect, whether the caps lock key at the very moment is down. So I don't need the state (on/off), I want to check if the user keeps the caps lock pressed down. Is it possible with javascript? I want to create something like an Enso Launcher inside the browser.</p>
javascript jquery
[3, 5]
4,407,577
4,407,578
jquery attached event with class execute more than once
<p>I have some div`s with same class say:</p> <pre><code>&lt;div id="1" class="same"&gt;..&lt;/div&gt; &lt;div id="2" class="same"&gt;..&lt;/div&gt; &lt;div id="3" class="same"&gt;..&lt;/div&gt; </code></pre> <p>I attach eventhandler all div :</p> <pre><code>$(".same").live({mouseenter : function{ /*code*/ },mouseout: function{ /*code*/ }}) </code></pre> <p>Now my problem is when mouseenters to div <code>(id="1")</code> , the code for mouseenter function will executes 3 time may be because there are 3 divs with <code>class="same"</code> but i want it to execute only one time and without attaching the events with ids. Is this possible?</p>
javascript jquery
[3, 5]
2,533,295
2,533,296
Conversion from jQuery into JavaScript
<p>I've a script:</p> <pre><code>&lt;form id="myform"&gt; &lt;input type="text" value="" id="input1"&gt; &lt;input type="text" value="" id="input2"&gt; &lt;input type="submit" value="submit"&gt; &lt;/form&gt; &lt;img id="image" src="http://mydomain.com/empty.gif" /&gt; &lt;script&gt; $(document).ready(function () { $("#myform").submit(function (ev) { ev.preventDefault(); var val1 = $("#input1").val(); var val1 = $("#input2").val(); $("#image").attr("src", "http://mydomain.com/image?val1="+val1+"&amp;val2="+val2); }); }); &lt;/script&gt; </code></pre> <p>How would it look like if written in JavaScript?</p>
javascript jquery
[3, 5]
1,323,205
1,323,206
Alternative to Update Panel using Javascript or JQuery
<p>Is there any alternative for <code>asp:UpdatePanel</code> usnig Javascript or JQuery</p>
c# javascript jquery asp.net
[0, 3, 5, 9]
5,080,360
5,080,361
.click function not working
<p>I have JavaScript for a commenting system, however when I click on the submit button with the class name "com_submit" nothing happens except the page reloads. Even if I leave the form empty and submit the alert should pop up but it isn't. What am I doing wrong?</p> <p>Here is my code: </p> <pre><code>$(function() { $('.com_submit').live("click", function() { var comment = $("#comment").val(); var user_id = $("#user_id").val(); var perma_id = $("#perma_id").val(); var dataString = 'comment='+ comment + '&amp;user_id='+ user_id + '&amp;perma_id=' + $perma_id; if(comment=='') { alert('Please Give Valid Details'); } else { $("#flash").show(); $("#flash").fadeIn(400).html('&lt;img src="ajax-loader.gif" /&gt;Loading Comment...'); $.ajax({ type: "POST", url: "commentajax.php", data: dataString, cache: false, success: function(html){ $("ol#update").append(html); $("ol#update li:first").fadeIn("slow"); $("#flash").hide(); } }); } return false; }); }); </code></pre> <p>I have tried using .click, .live and .bind none of these work</p>
javascript jquery
[3, 5]
677,912
677,913
JQuery - append rather than replace content using .innerHTML?
<p>Below is a function that retrieves a users older wallposts, 16 at a time, and appends each chunk of 16 to the end of the current list in the div called "sw1".</p> <p>It works fine, except in the case where there is currently a wallpost that contains a video/embedded object that is currently in the process of playing. When we click on the button that calls the function below during the playback of an object in sw1, the below function seems to cause the entire content of sw1 to be removed, and then re-dumped.</p> <p>Is it possible to modify the function below so that it merely appends new data to the end of sw1, rather than replacing the entire contents, killing any objects that are currently playing??</p> <pre><code>function fetch_older_wallposts(u,lim){ var xhr = getXMLHttpRequest(); xhr.onreadystatechange = function() { if (xhr.readyState == 4 &amp;&amp; (xhr.status == 200 || xhr.status == 0)) { //document.getElementById( 'sw1' ).innerHTML.append( xhr.responseText ); document.getElementById( 'sw1' ).innerHTML += xhr.responseText; }else{ document.getElementById( 'oaps_loading' ).innerHTML = 'loading'; } }; xhr.open("POST", "script.php?u="+u+"&amp;lim="+lim, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.send(null); } </code></pre> <p>Any sort of assistance or guidance appreciated guys....</p> <p>Thanks for all the usefull comments guys!</p>
javascript jquery
[3, 5]
5,692,496
5,692,497
count the textbox values using javascript
<p>I have dynamically added rows using javascript.now I have to sum the values in the text boxes.if i click add button the same row will be added.now i have one fixed textbox.if i enter the values in the textbox it should add and get displayed in the fixed textbox on keypress.how can i do this with javascript or jquery</p> <p>here is my html and jquery scripts to addd the row</p> <p>input id="name" type="text" input id="add" type="button" value="+" input id="Button1" type="button" onclick="removeRowFromTable();" value="x" </p> <p>I have used jquery to add the rows dynamically and javascript to delete the rows</p> <pre><code>$(document).ready(function() { $("#add").click(function() { $('#mytable tbody&gt;tr:last').clone(true).insertAfter('#mytable tbody&gt;tr:last'); $('#mytable tbody&gt;tr:last #name').val(''); $("#mytable tbody&gt;tr:last").each(function() {this.reset();}); return false; return false; }); }); </code></pre> <p>function removeRowFromTable() { var tbl = document.getElementById('mytable'); var lastRow = tbl.rows.length; if (lastRow > 2) tbl.deleteRow(lastRow - 1); }</p>
javascript jquery
[3, 5]
2,203,383
2,203,384
How to pass variable from PHP to JS, perform math on the variable then output to an on page element
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/7705921/how-to-access-php-variables-from-within-javascript">how to access PHP variables from within JavaScript?</a> </p> </blockquote> <p>I am trying to pass a variable from mySQL to PHP then to JavaScript to perform some math on it then have the result displayed on page in a specific area (in a <code>&lt;p&gt;</code> element with a specific ID assigned to it). Is this possible or is there an easier solution?</p> <p>Thanks!</p> <p>I already know how to get the variable from MySQL to PHP just having trouble on what to do after that.</p> <p>Here is my updated code after reading responses. Still not working but I am sure I'm doing something wrong!</p> <pre><code>&lt;p id="p_id"&gt;&lt;?php echo $price; ?&gt;&lt;/p&gt; &lt;input type="radio" group="radio_group" value="Reduce 10%" onclick="radio_click();" /&gt; &lt;script type="text/javascript"&gt; var price = &lt;?php echo $price; ?&gt;; function radio_click() { var target = document.GetElementById('p_id'); var final_number; // this will be variable your store the final number in final_number = price * .9; target.innerHTML = final_number; } &lt;/script&gt; </code></pre>
php javascript
[2, 3]
5,977,121
5,977,122
password input masking with delay, android style in javascript/jquery
<p>Let me start by saying that my task is complete. But I'm trying to get an understanding of how it's working, and one thing is confusing to me. In other words, I stumbled on the answer by accident.</p> <p>My task was simple: in an input box, mask the input as the user types, by changing each character to * after a delay. This is how android phones handle masked input, slightly different than iPhone.</p> <p>I used a combination of jQuery/javascript and regex. My working code:</p> <pre><code>$('.room_input').focus(function () { currentFocus = $(this); }); $('.key').click(function () { setTimeout(function () { currentFocus.val(currentFocus.val().replace(/[^\*]/, '*')); }, 2000); }); </code></pre> <p>It's pretty simple, and it works great. When each key is pressed, it changes to * after 2 seconds. <em>Each key is on its own timer</em>. But there is one major thing I don't understand. When the callback from setTimeout triggers, the code above seems like it would set the <em>entire</em> contents of the textbox to *'s. Because the "replace" above replaces the entire content of the value with any characters not *.</p> <p>But it doesn't. Each key changes after 2 seconds from when it was clicked (as it should). Why is that? I'm thinking it might be the regex - does it only change the first match it finds? Did I just answer my own question?</p> <p>UPDATE: I did. It's the regex. It only replaces the <em>first</em> matched character in the string. I was thinking it maybe had something to do with single-threading issues... as usual, I'm making a problem much more difficult than it is. :)</p>
javascript jquery
[3, 5]
3,985,944
3,985,945
Return JQuery specific click in a container
<p>I was wondering how you can return the value of which specific child has been clicked within an index.</p> <p>Normally the default behavior would be to use</p> <pre><code>var selected = $(this).index(); </code></pre> <p>Although this works as it should , it doesn't return the index from INSIDE a function such as the following.</p> <pre><code>var selected; $(container.children()).on('click', function() { selected = $(this).index(); selected.siblings().fadeOut(); selected.animate({ width: 920, height: 440 }); selected.fadeOut(); }); //console.log(selected) = 'undefined'! </code></pre> <p>Why is this and what is the appropriate solution?!</p> <p>EDIT:</p> <p>Please note, I have edited this to make the question less specific and localized, in order for it to gain a better vote.</p> <p>Rick</p>
javascript jquery
[3, 5]
4,596,425
4,596,426
UserControl pass Value to MasterPage Content
<p>I am coding in a userControl, </p> <p>how can I pass text to a control I placed in one of the contents?</p> <p>It's a literal by the way</p> <p>Thank you</p>
c# asp.net
[0, 9]
2,920,243
2,920,244
How to connect to wi-fi network programatically?
<p>I am making Android application, and I need to know how I can connect to a wi-fi network programatically. Please give me an example or some other guidance. Thank you. </p>
java android
[1, 4]
5,969,421
5,969,422
Android random generate chars
<p>How to generate random chars ? </p> <p>Random numbers like this: :</p> <pre><code>public static int random() { Random generator = new Random(); int x = generator.nextInt(10000); return x; } </code></pre> <p>I need to draw something like: zCs3v3b1b6 just random chars</p>
java android
[1, 4]
1,458,168
1,458,169
asp.net nested repeaters and rendering issue
<p>I am rendering 1000+ records on a web page using nested repeaters. The problem i am facing is that it takes too much time to render the data on page. </p> <p>Here is the concept layout of repeaters.</p> <blockquote> <p>-Main</p> <pre><code>-Level 1 -Level 2 -Level 3 -Level 3 -Level 2 -Level 1 </code></pre> <p>-Main</p> </blockquote> <p>When page loads Main and level 1 rows are showing. when user click on level 1 row, level 2 row appears and by clicking on level 2, level 3 row shows up.</p> <p>I am loading data to all the repeaters at once and hiding/showing the level 2 and level3 rows using jQuery.</p> <p>The problem is that i get data within a second from database but it takes too long to render. </p> <p>One solution is that i load Main and Level 1 row at the page load and show level 2 and 3 rows based on user click.</p> <p>Is there any other way to improve the performance?</p> <p>Thanks in advance</p> <p>I am loading the data onto page at once and then hiding Level 2 and Level 3.</p>
jquery asp.net
[5, 9]
5,456,762
5,456,763
howto get $('input[name=...]').val() from $('form')[...];
<p>This my html code</p> <pre><code>&lt;div id="list_refer_1"&gt; &lt;form id="refer_1_0"&gt; &lt;input type="hidden" name="channel" value="1"&gt; &lt;input type="hidden" name="url" id="input_1_0" value="http://localhost:8000/"&gt; &lt;input type="button" onclick="pullrefer(1, 0);" value=" - "&gt; http://localhost:8000/ &lt;/form&gt; &lt;form id="refer_1_xxxxx"&gt; ///xxxxx is timestamp &lt;input type="hidden" name="channel" value="1"&gt; &lt;input type="hidden" name="url" id="input_1_1" value="http://127.0.0.1:8000/"&gt; &lt;input type="button" onclick="pullrefer(1, 1);" value=" - "&gt; http://127.0.0.1:8000/ &lt;/form&gt; &lt;form id="refer_1_2"&gt; &lt;input type="hidden" name="channel" value="1"&gt; &lt;input type="hidden" name="url" id="input_1_2" value="http://localhost*"&gt; &lt;input type="button" onclick="pullrefer(1, 2);" value=" - "&gt; http://localhost* &lt;/form&gt; ... </code></pre> <p>i can get value by </p> <pre><code>$('#list_refer_1 #refer_1_0 input[name=url]').val(); </code></pre> <p>but i want get</p> <pre><code>$('input[name=url]').val() from $('#list_refer_1 **form**')**[1]**; </code></pre> <p>howto get it? Thank you.</p>
javascript jquery
[3, 5]
5,125,133
5,125,134
multiple custom EditText
<p>I have a layout with 10 small EditText', each taking one digit. These fields need a custom focushandler, but how do I apply it to them all without writing the same class more than once?</p> <p>Is there something like css select by class? Or some other way to do it?</p> <p>If it matters, this is the focushandler I want to try: <a href="http://stackoverflow.com/questions/8630819/moving-focus-from-one-edittext-to-another">Moving focus from one EditText to another</a></p> <p>As you can see, this uses findById, which I assume cannot do what I want.</p>
java android
[1, 4]
4,131,855
4,131,856
path to Assets to string?
<p>For example, this would be the path to a file on the external memory...</p> <pre><code>String path = Environment.getExternalStorageDirectory().toString()+"/myApp/face.jpg"; </code></pre> <p>But is there also such a path to the Asset folder?</p> <p>Cheers!</p> <p>P.S.</p> <pre><code>"file:///android_asset/1.png" </code></pre> <p>Gives a file not found.</p>
java android
[1, 4]
3,458,778
3,458,779
Any other alternative to capturing text on Ctrl+V
<p>I am trying to capture the text on Ctrl+V event as below.. </p> <ol> <li><p>Creating a textarea in the page and setting height 0px and width 0px. like below</p> <pre><code> &lt;textarea id="a" style="height:0px;width:0px"&gt;&lt;/textarea&gt; </code></pre></li> <li><p>On pressing V key i am setting the focus to that textarea and then using Ctrl+V button. Like below.. </p> <pre><code> shortcut.add("X",function() { $('#a').focus(); }); // In between user have to press Ctrl+V to paste the content shortcut.add("V",function() { alert($('#a').val()); }); </code></pre></li> </ol> <p>I think this as a most inefficient approach and waiting for valuable suggestions to improve this.. </p>
javascript jquery
[3, 5]
2,183,180
2,183,181
how to return true or false when I click on confirm dialog button?
<p>I have a jquery</p> <pre><code>$(function () { $('.checked').click(function (e) { e.preventDefault(); var dirtyvalue = "Test1"; var textvalue= "Test"; if (dirtyvalue.toLowerCase() != textvalue.toLowerCase()) { { var dialog = $('&lt;p&gt;Do you want to save your changes?&lt;/p&gt;').dialog({ buttons: { "Yes": function () { dialog.dialog('close'); alert('yes btn called'); }, "No": function () { dialog.dialog('close'); alert('No btn called'); }, "Cancel": function () { dialog.dialog('close'); } } }); } return false; } return true; }); }); </code></pre> <p>I want to to return true or false on button click, yes will return true, No will return true and Cancel will return false. </p> <p>I already check this <a href="http://stackoverflow.com/questions/6049687/jquery-ui-dialog-box-need-to-return-value-when-user-presses-button-but-not-wor">link</a> but this is not solving my problem. my previous <a href="http://stackoverflow.com/questions/9091001/how-to-show-confirmation-alert-with-three-buttons-yes-no-and-cancel-as-it/9091077#comment11456137_9091077">qus.</a></p> <p>My problem is I have many ActionLink and TreeView links, on which I am calling there respective page, Suppose I am on page1 where I have all these js, and on that page1 and have many action link and clicking on page2, at that time my confirm will open and when i'll click on button No it will redirect to page2.</p> <p>please someone help me...</p>
javascript jquery asp.net
[3, 5, 9]
690,658
690,659
Use a javascript function in php
<p>I have a nav bar on my site that has dynamic links. When the user is logged out, I want these links to say "Register | Log in" and when they are signed in, I want those same links to change to "$userName | Account". I have a script to handle this, but there is one problem. </p> <p>When the user is signed out, I want the "Register" link to open a popup div with the registration page on it, instead of forwarding them to a different page. The only problem is, the way I am handling this is in a link like </p> <pre><code>&lt;a href="#" onClick="popup('popUpDiv')"&gt;Register&lt;/a&gt; </code></pre> <p>But I need to call this in a php script. </p> <p>Any Help is appreciated. </p> <p>This is from the php script. </p> <pre><code> if (!isset($_COOKIE['idCookie'])) { $logOptions = ' &lt;a href="http://' . $dyn_www . '/register.php"&gt;Register&lt;/a&gt; &amp;nbsp;&amp;nbsp; | &amp;nbsp;&amp;nbsp; &lt;a href="http://' . $dyn_www . '/login.php"&gt;Log In&lt;/a&gt;'; </code></pre> <p>}</p> <p>But instead of having the whole register.php, i just want it to go to</p> <pre><code>&lt;a href="#" onClick="popup('popUpDiv')"&gt;Register&lt;/a&gt; </code></pre>
php javascript
[2, 3]
5,392,864
5,392,865
How to Separate a List into Two Lists
<p>In my form, I have multiple fields (hidden text boxes) which has the same name (eform_id). (For example i have 7 hidden textboxes which contains values like this 1234,-1235,1236,1237,-1238,-1239,1240...</p> <p>I am getting those values to my js file like this.</p> <pre><code>var eformDetailIds=$("[name=eform_id]").map(function(){ return $(this).val() }).get(); </code></pre> <p>Now my requirement is I have to separate this eformDetailIds into two lists..(or a string of comma separated values) so that first list contains all positive values and second list contains all negative values..</p> <p>This is a very urgent requirement and I am seeking your help in this. Please help me with suitable code which resolves my problem.</p> <p>Thans in advance -sathya</p>
javascript jquery
[3, 5]
5,937,373
5,937,374
jQuery Deconstruction | JQuery object in ES 5 terms?
<p>This returns a jQuery object. what is a jQuery object. Is it an object, an array, or some combination of both? </p> <pre><code>$("#id") </code></pre> <p>I'm looking in the <a href="http://code.jquery.com/jquery-latest.js" rel="nofollow">source here</a>, but can not find it.</p>
javascript jquery
[3, 5]
1,304,994
1,304,995
Finding Changed Form Element With jQuery
<p>i have a form(id="search_options") and i tracking changes in form by:</p> <pre><code> $("#search_options").change(function() { // Bla Bla Bla }); </code></pre> <p>In this form i have many inputs and one of is select(id="project_category") and i want to catch if user changed project_category select or another input. How can i done this ? Thanks</p>
javascript jquery
[3, 5]
2,579,629
2,579,630
jQuery, where to load functions best practice
<p>I am using jQuery and I am loading dynamic HTML via PHP. My question is, what is the best practice concerning elements/attributes that may or may not exist on any given page? Should I have one .js file containing all the possibilities (I would think this is inefficient) or should I use a bunch of script tags (that seems also inefficient)? Is there a "lazy" initialization way to do this?</p> <p>For instance, say I have the following:</p> <pre><code>&lt;div id="list"&gt; &lt;ul&gt; &lt;li&gt;some&lt;/li&gt; &lt;li&gt;stuff&lt;/li&gt; &lt;li&gt;here&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; </code></pre> <p>But this list is generated only if necessary, not on all pages. Should my global js file have the following:</p> <pre><code>$("#list").click( function(){ $(this).removeClass('collapse').addClass('expand'); }); </code></pre> <p>Or should I add it in a script tag <del>just above the div that is being generated</del> at the bottom of the page after creating the div is output via PHP?</p> <p>Thanks SO, you guys are awesome. Can't wait until I know enough to start answering some questions!</p> <p>Edit, just thought of a quick way to ask. Which is better, jQuery running with a bunch of selectors that don't match or passing javascript in script tags via PHP?</p>
javascript jquery
[3, 5]
5,395,088
5,395,089
What is a good way of achieving this filtering?
<p>I have data like the following:</p> <pre><code>var data = [{ id: 1, date: new Date("2010-01-01"), value: 10 }, { id: 2, date: new Date("2010-01-01"), value: 11 }, { id: 3, date: new Date("2010-01-01"), value: 12 }, { id: 4, date: new Date("2010-01-02"), value: 10 }, { id: 5, date: new Date("2010-01-03"), value: 10 }, { id: 6, date: new Date("2010-01-03"), value: 21 }, { id: 7, date: new Date("2010-01-03"), value: 22 }, { id: 8, date: new Date("2010-01-03"), value: 23 }]; </code></pre> <p>I am trying to apply two kinds of filters: </p> <ul> <li><code>Filter1</code> should give me only those points that differ by 1 in their <code>value</code> field but having the same <code>date</code> field. Therefore, this should return a new dataset containing data records with ids 1,2,3, 6,7,8 (the first three because values are 10,11,12 and last three because values are 21,22,23)</li> <li><code>Filter2</code> should give me only those points that differ by 1 day in their <code>date</code> field but having the same <code>value</code> field. Therefore, this should return a new dataset containing data records with ids 1,4,5</li> </ul> <p>I am currently doing this in C# on the server-side but am looking to see if there is an efficient way to do this in Javascript. Any suggestions?</p>
javascript jquery
[3, 5]
4,765,984
4,765,985
Is there TAB control and how to open page2 from button click?
<p>Is there TAB control and how to open page2 from button click ?</p> <p>On asp.net ?</p> <p>I work with C# and Visual Studio 2008 and ASP.NET</p> <p>Thanks in advance</p>
c# asp.net
[0, 9]
4,241,597
4,241,598
jquery each function not working on client click asp.net
<pre><code>function AddressVal5() { $('.ma-addressEdit .address:visible input:text.number').each(function () { var maxLength = $(this).attr('maxLength'); var thisLength = $(this).val().length; // alert(maxLength + ' ' + thisLength) //$(this).next('.error').hide(); if ($(this).val() == '' || thisLength &lt; maxLength) { alert("sa"); $(this).next('.error').show(); return false; } }); $('.ma-addressEdit .address:visible input:text, .ma-addressEdit .address:visible textarea').each(function () { var maxLength = $(this).attr('maxLength'); var thisLength = $(this).val().length; $(this).next('.error').hide(); if ($(this).val() == '' || thisLength &lt; maxLength) { $(this).next('.error').show(); } }); } </code></pre> <p>I am working on jquery validations its work properly with</p> <pre><code>&lt;a href="javascript:void(0);" class="clear" id="addressUpdateBtn"&gt;&lt;img src="images/update.png" width="83" height="31" alt="Upate" onclick="AddressVal5()" /&gt;&lt;/a&gt; </code></pre> <p>but not work with</p> <pre><code>&lt;asp:ImageButton ID="imgbtnNewADD" runat="server" ImageUrl="~/_layouts/images/Experia/update.png" CssClass="Nbutton" OnClientClick="return AddressVal5();" ToolTip="Add" OnClick="imgbtnNewADD_Click" /&gt; </code></pre> <p>error messages are come but refresh on click please help..</p>
jquery asp.net
[5, 9]
4,890,108
4,890,109
Multiple jquery command won't work
<p>Only the first command using id "exp_month" works, the other 2 don't work. The id's are set currently in the html.</p> <pre><code> if (month!="") $('select#exp_month&gt;option:eq('+month+')').attr('selected', true); if (year!="") $('select#exp_year&gt;option:eq('+year+')').attr('selected', true); if (state!="") { $('select#x_state&gt;option:eq("'+state+'")').attr('selected', true); } </code></pre>
javascript jquery
[3, 5]
3,585,614
3,585,615
how to access the user control controls in aspx code behind
<p>I created a user control with tab container in my project. I want to access the tab container from aspx page for the reason of disable the some tabs. For example i need to hide the first tab and third tab dynamically from aspx page. Because i am using the same user control for different page. Please help me to fix this issue.</p> <pre><code>&lt;%@ Register TagPrefix="cust" TagName="Creation" Src="~/Cust_Creation.ascx" %&gt; &lt;div&gt; &lt;cust:Creation ID="uc_more_pack" runat="server" /&gt; &lt;/div&gt; </code></pre> <p>I </p>
c# asp.net
[0, 9]
2,663,460
2,663,461
Javascript - Count characters of an anchor tag
<p>Basically I want to create a function that will search a string for an anchor tag, when it finds one, count the characters between and return that number. I am doing this for an editor that is counting the number of characters in a textarea because the textarea has a limit the user can enter and I don't want the characters in a link to count against that total.</p> <p>If I have this in the textarea:</p> <pre><code>This is what it looks like here &lt;a href="http://www.bmhl.com"&gt;Placeholder&lt;/a&gt;. Please click the link to go to the page. </code></pre> <p>There are 32 characters prior to the anchor, 11 in between and 42 after for a total of 85. In the anchor tag there are 34 characters that I don't want to go towards the count.</p> <p>Hope that makes sense.</p>
javascript jquery
[3, 5]
909,945
909,946
this.href vs $(this).attr('href')
<p>After reading this article <a href="http://net.tutsplus.com/tutorials/javascript-ajax/14-helpful-jquery-tricks-notes-and-best-practices/" rel="nofollow">net.tutsplus.com/tutorials/javascript-ajax/14-helpful-jquery-tricks-notes-and-best-practices/</a> I came to conclusion that using <strong>this.href</strong> is more efficient. </p> <p>However, when I tried to use it on one of my projects, I saw that <strong>this.href</strong> returns not only href but also appends a url of a website. For example <code>&lt;a href="tab-04"&gt;&lt;/a&gt;</code><strong>this.href</strong> will return <a href="http://example.com/abc/tab-04" rel="nofollow">http://example.com/abc/tab-04</a> and <strong>$(this).attr('href')</strong> will return only tab-04. </p> <p>You can see an example here <a href="http://jsfiddle.net/UC2xA/1/" rel="nofollow">http://jsfiddle.net/UC2xA/1/</a>. </p> <p><strong>$(this).attr('href')</strong> however returns exactly what I need and nothing more. </p> <p>My question is this, how can I rewrite (or do what is necessary) <strong>this.href</strong> so that it would only return <strong>tab-04</strong>?</p> <p><strong>EDIT</strong></p> <p>Doug you are right on the money with <pre>this.getAttribute('href')</pre></p>
javascript jquery
[3, 5]