Unnamed: 0
int64
302
6.03M
Id
int64
303
6.03M
Title
stringlengths
12
149
input
stringlengths
25
3.08k
output
stringclasses
181 values
Tag_Number
stringclasses
181 values
3,313,629
3,313,630
doesn't toggle the feedback div
<pre><code>&lt;script type="text/javascript"&gt; $(document).ready(function(){ $('#feedback').hide(''); $('a#1').click(function(){ $('#feedback').toggle(''); }); }); &lt;/script&gt; </code></pre> <p>It doesn't toggle the feedback div, but if you use show instead of toggle the script works.</p>
php javascript jquery
[2, 3, 5]
2,098,658
2,098,659
setText(String) is not available for the TextView
<p>I'm trying to simplify my code, but for some reasons the "setText" method is not available.</p> <p>Here is the code which is currently working for me:</p> <pre><code>TextView textView = (TextView)view.findViewById(R.id.testId); textView.setText("Test"); </code></pre> <p>I'm trying to simply it to this code:</p> <pre><code>(TextView)view.findViewById(R.id.testId).setText("Test"); </code></pre> <p>But I'm getting the error message: "Cannot find symbol". Even IDE does not give me this option:</p> <p><img src="http://i.stack.imgur.com/GJP0p.png" alt="enter image description here"></p> <p>However, this code is working fine for some other things, like this:</p> <pre><code>view.findViewById(R.id.another_testID).setOnClickListener(test_listener); </code></pre> <p>Any ideas?</p>
java android
[1, 4]
4,842,549
4,842,550
Event managment: Replace click event
<p>I have a button with a click event (from a 3. party library) which submits a form. I like to remove the click event, add my own function and call the original event after a validation.</p> <p>I thought i just add an <code>event.stopImmediatePropagation();</code> but that did not work. Maybe because of the order the events where added(?).</p> <p>Is the another way to manage the event execution?</p> <p>Or how can I get the old event to do something like this:</p> <pre><code>originalClickEvent = $('#button').doSomeMagicAndGetTheEvent('click'); $('#button').unbind(); $('#button').bind('click', function (event) { if (valid()) originalClickEvent(); }); </code></pre>
javascript jquery
[3, 5]
5,252,179
5,252,180
how to add cancel button inside spinner
<p>I want to add cancel button inside of spinner how to add cancel button in spinner without </p> <p>using alert dialog please give me an example..</p> <p>spinner = (Spinner) findViewById(R.id.spinner);</p> <pre><code> ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;(getApplicationContext(),R.layout.test_list_item,stringArray); adapter.setDropDownViewResource(R.layout.simple_spinner_dropdown_item); spinner.setAdapter((adapter)); </code></pre>
java android
[1, 4]
635,139
635,140
Calculate some data and draw corresponding image in ASP.NET
<p>I got a question with my ASP.NET page. On the page I have a form with some textboxes and a submit button. How can I do the following:</p> <ol> <li>Get data from the textboxes</li> <li>Calculate some values</li> <li>Draw and place an image after the form using these values.</li> </ol> <p>Third step - is the problem for me.</p> <p>Thanks in advance.</p> <p>P.S. I use C# as code behind language.</p>
c# asp.net
[0, 9]
3,911,837
3,911,838
variable scope in jquery
<p>I'm trying to access the value of a variable that is set inside a <code>.click</code> function outside of the function but I'll get the error, can anyone please tell me what I'm doing wrong?</p> <pre><code>var id; var currentPosition; var slideWidth = 368; var slides; var numberOfSlides; $('#accordion_catering h3').click(function() { id = $(this).attr('id'); $('#' +id+'_gallery').show(); //alert(id);//works }); alert(id); // is undefined // Because id is undefined these don't work . slides = $('.' + id + '_slide'); numberOfSlides = slides.length; </code></pre>
javascript jquery
[3, 5]
684,654
684,655
How to get the class names using jquery?
<p>Hey, I'm wondering how I can get the class names dynamically using jquery for the script below.</p> <p>The HTML output looks like this:</p> <pre><code>&lt;div id="main-info-1" class="maini"&gt; &lt;p&gt;this is a paragraph.&lt;/p&gt; &lt;/div&gt; </code></pre> <p>So, I'm trying to get the class name dynamically instead of hard coded like it is above.</p> <p>There are two parts where I need to get the class names in the jquery script:</p> <pre><code>1.) pc.children('div.maini').remove(); 2.) maini_s = $('div.maini').remove(); </code></pre> <p>As you can see the class 'maini' is hard coded and im unsure how to get the class name dynamically and put it properly in the script.</p> <p>The jQuery file:</p> <pre><code>&lt;script type="text/javascript"&gt; // make them global to access them from the console and use them // in handlePaginationClick var maini_s; var num_of_arts; var ipp; function handlePaginationClick(new_page_index, pagination_container) { var pc = $(pagination_container); pc.children('div.maini').remove(); for(var i=new_page_index*ipp; i &lt; (new_page_index+1)*ipp ;i++) { if (i &lt; num_of_arts) { pc.append(maini_s[i]); } } return false; } $(document).ready(function() { maini_s = $('div.maini').remove(); num_of_arts = maini_s.length; ipp = 3; // First Parameter: number of items // Second Parameter: options object $("#News-Pagination").pagination(6, { items_per_page:ipp, callback:handlePaginationClick }); }); &lt;/script&gt; </code></pre> <p>Any help on this would be awesome, thank you.</p>
javascript jquery
[3, 5]
3,417,486
3,417,487
Catch exception
<p>folks! I got Activity, in onCreate() i try to fetch data:</p> <pre><code>protected void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); ............... fillUI(); } public void getDetailedItem(){ FeedParser parser=new FeedParser(); try{ mItem=parser.parseDetailed(); }catch(Exception e){ closeAndShowError(); } } public void fillUI(){ getDetailedItem(); if(mItem!=null){ ............... }else{ closeAndShowError(); } } private void closeAndShowError(){ Context context = getApplicationContext(); CharSequence text = getResources().getString(R.string.toast_error); int duration = Toast.LENGTH_SHORT; Toast toast = Toast.makeText(context, text, duration); toast.show(); finish(); } </code></pre> <p>Them problem is, when Exception occures, it is caught, and I expect my activity to finish itself, but I still get code inside fillUI() executed, so I had to put if statement after getDetailedItem(); How do I solve it?</p>
java android
[1, 4]
5,199,647
5,199,648
Remove item after max reached w/jQuery
<p>OK, I am trying to clone table with 3 elements in it. After I make 3 clones I need to continue cloning but remove item <strong>.val3</strong>.</p> <pre><code>$('a').click(function(e) { var $table = $(this).prev(); $table.after($table.clone()); e.preventDefault(); var n = $(".val3").length; if (n &gt; 3) { if (!$(".val3").hasClass("max3")) { $(".val3").remove(); } } else { $(".val3").addClass("max3"); } }); &lt;table border="1"&gt; &lt;tr&gt; &lt;td&gt; &lt;div class="val1"&gt;val 1&lt;/div&gt; &lt;div class="val2"&gt;val 2&lt;/div&gt; &lt;div class="val3"&gt;val 3&lt;/div&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;a href="#"&gt;copy&lt;/a&gt; </code></pre> <p>I decided that I'll add a class to the first 3 and then check if the class does not exist, remove the div. I think i got lost in my own logic... </p> <p>Here's <a href="http://jsfiddle.net/uR7Aw/" rel="nofollow">jfiddle I put as a demo</a>.</p>
javascript jquery
[3, 5]
4,165,420
4,165,421
change event for combobox not getting fired in jquery
<p>i am working in php. I have written code for displaying combo box like this :</p> <pre><code>&lt;select name="country" id="idCountry" class="clsCountry" &gt; &lt;?php foreach($objCountries as $objCountry):?&gt; &lt;option value="&lt;?php echo $objCountry-&gt;getId()?&gt;" &gt;&lt;?php echo $objCountry-&gt;getName()?&gt; &lt;/option&gt; &lt;?php endforeach;?&gt; &lt;/select&gt;&lt;/td&gt; </code></pre> <p>For change event:</p> <pre><code>$("#idCountry").change(function(){ .... }); </code></pre> <p>but change event is not getting fired. Anybody have any idea about it? Thanks in advance.</p>
php jquery
[2, 5]
2,143,140
2,143,141
How to upload image file that converted thumbnails with javascript & PHP?
<p>I have some code in which, before uploading the original images, it creates thumbnail images. What I want to do is, instead of uploading the client's original images, I'd like to upload the thumbnail images. The reason is that the originals image files are usually too big, and my system's OK with very small images such as thumbnails. How can I achieve my goal?</p> <p>Here is my code so far:</p> <h3>PHP code:</h3> <pre><code>if (isset($HTTP_POST_VARS['action'])) { $SafeFile = $_FILES['client_image']['name']; } </code></pre> <h3>HTML code:</h3> <pre><code>&lt; input type="file" valign=middle name="client_image" id="client_image" &gt; &lt; output id="list" &gt; &lt; /output&gt; </code></pre> <h3>JavaScript code:</h3> <pre><code>document.getElementById('client_image').addEventListener('change', handleFileSelect, false); function handleFileSelect(evt) { var files = evt.target.files; for (var i = 0, f; f = files[i]; i++) { // Only process image files. if (!f.type.match('image.*')) { continue; } reader.onload = (function(theFile) { return function(e) { // Render thumbnail. var span = document.createElement('span'); span.innerHTML = ['&lt;img class="thumb" id="thumb_image" src="', e.target.result, '" title="', escape(theFile.name), '"/&gt;'].join(''); document.getElementById('list').insertBefore(span, null); }; })(f); } } </code></pre>
php javascript
[2, 3]
1,754,745
1,754,746
jquery : How to unbind dynamically created elements?
<p>I have buttons created dynamically. I know that bind/unbind is only applicable for elements not created dynamically. To add functionality I use <code>.live()</code> which works perfectly. My problem is Idk how to remove the functionality. Please help.</p>
javascript jquery
[3, 5]
5,900,124
5,900,125
store value of input type="hidden" into a php variable without javascript
<p>store value of input type="hidden" into a php variable.</p> <p>The value is set by javascript into a hidden variable[input].</p> <p>Now i need to save its value into a $myphpvariable.</p> <p>I cant set the value into session with javascript and cookies is not an option.</p>
php javascript
[2, 3]
5,842,163
5,842,164
what javascript object am I looking for? click a button-it stays bold till the next one is clicked?
<p>A very basic thing, I know. I have a collapsing div help box thing that is triggered when clicking links. Click the link, the help topic opens in the div.</p> <p>I want the text in the link to stay bold until I click another link. What function am i looking for? I'm using jquery. Thanks!</p>
javascript jquery
[3, 5]
4,535,387
4,535,388
jquery - button in ajax respone - no response to click
<p>jquery;</p> <p>Situation - just upgrading from pure javascript to jquery - prompted by browser inconsistencies.</p> <p>On load, a page displays, in a div, the result of an ajax request, which includes an OK button, <code>&lt;input name="srd_button_ok" type="button" value="OK"&gt;</code> at the bottom.</p> <p>Clicking OK button IS NOT detected by:</p> <pre><code>$('[name*="srd_button_ok"]').click (function(){ alert("srd_button_ok clicked");}); </code></pre> <p>However, another 'test button' placed in a separate div on same page, permanently displayed <code>&lt;input name="test_div" type="button" value="Test Div"&gt;</code> IS detected by:</p> <pre><code>$('[name*="test_div"]').click (function(){ alert("test_dv clicked");}); </code></pre> <p>Both of the above within</p> <pre><code>jQuery(document).ready(function(){ ....}); </code></pre> <p>What am I missing or doing incorrectly?</p> <p>Your advice will be appreciated.</p> <p>Many thanks,</p> <p>Ivan Rutter</p>
javascript jquery
[3, 5]
3,847,380
3,847,381
Clean php output into javascript
<p>Due to the nature of my project. I am pulling data from my db and outputting to javascript. Things were working just fine till I got to the main content. It has strings like (;, :, - ''). How do I ensure that these are displayed without crushing my script coz as for now nothing seems to work.</p>
php javascript
[2, 3]
3,416,614
3,416,615
Pass the anchor text of a Jquery generated link from another server into a Jquery var
<p>Not sure this is possible but maybe you can help.</p> <p>I have a list, where the content of the <code>&lt;li&gt;</code>'s is generated by Javascript, through a function called <code>showLink();</code> this <strong><em>function is on another server and it's not controlled by me</em></strong>.</p> <p>The <code>showLink();</code> function generates a <strong>html link</strong>. I am interested in the generated anchor text.</p> <p><strong>QUESTION: Is there a way I can use Jquery to get the anchor text of that link into a Jquery variable?</strong></p> <p>Here is the code:</p> <pre><code>&lt;ul class="my_list"&gt; &lt;? $zero = '0'; for($rn = 1; $rn &lt;= $traffic_rows_nr; $rn++){ ?&gt; &lt;li&gt;&lt;script language="JavaScript"&gt;showLink(&lt;? echo $rn; ?&gt;)&lt;/script&gt;&lt;/li&gt; &lt;? } ?&gt; &lt;/ul&gt; </code></pre> <p>Thank you!</p>
javascript jquery
[3, 5]
1,685,933
1,685,934
Finding the textNode which the cursor is currently over
<p>Let's say I have the following...</p> <p><code>&lt;div id="text"&gt;Some text&lt;/div&gt;</code></p> <p>When my mouse goes over <code>Some</code>, <code>Some</code> will be returned and the same with <code>text</code>.</p> <p>Is this possible without putting each node into it's own element?</p>
javascript jquery
[3, 5]
3,056,574
3,056,575
jQuery calculation gives NaN
<p>Im trying to do a calculation, but i constantly get the error NaN; Could you help me out how to do the math for var testBottom?</p> <pre><code>jQuery(document).ready(function(){ var test = jQuery("#test"); var testTopOffset = test.offset(); var testTop = testTopOffset; var testHeight = test.height(); var testBottom = parseInt(testTop + testHeight); alert(testHeight); alert(testBottom); }); </code></pre>
javascript jquery
[3, 5]
3,087,199
3,087,200
can this code be re-written to use jquery chaining for setTimeout()
<p>Is it possible to use chaining when using setTimeout(). This example gives a div a red background, then I use setTimeout() to wait a second and make the background back to normal. can it be re-written or improved in any way</p> <pre><code>$(target).css('background', 'red'); setTimeout(function(){ $(target).css('background', ''); }, 1000 ); </code></pre>
javascript jquery
[3, 5]
2,288,327
2,288,328
Adding a jQuery Click handler
<p>I have following div in a page (I can not modify). </p> <pre><code> &lt;div id=":0.control"&gt;Click me&lt;/div&gt; </code></pre> <p>Now I want to add a jQuery Click handler </p> <pre><code>$("#:0.control").click(function () { alert('Clicked'); } ); </code></pre> <p>Above gives error. Any solution??</p>
javascript jquery
[3, 5]
2,040,119
2,040,120
How do I port php's openssl_sign to C#?
<p>I need to translate the following code to C# from php. What libraries / namespaces do I need to use?</p> <pre><code>function sign($method, $uuid, $data) { $merchant_private_key = openssl_get_privatekey(file_get_contents('merchant_private_key.pem')); $plaintext = $method . $uuid . serialize_data($data); **openssl_sign($plaintext, $signature, $merchant_private_key);** return base64_encode($signature); } </code></pre> <p>The api can be found over at <a href="http://php.net/manual/en/function.openssl-sign.php" rel="nofollow">http://php.net/manual/en/function.openssl-sign.php</a>. Where do I start? I have no idea what the open_ssl sign in php does behind the covers.</p> <p>Anyone able to help out that knows both php and C# or could someone at least explain what openssl_sign does in the background so that I can port it.</p> <p><strong>EDIT: 2010-08-18</strong> I can't find a way to use openssl, it keeps saying it can't load managedopenssl.dll. Think it is because of my machine being x64. </p>
c# php
[0, 2]
5,739,982
5,739,983
Issue with Javascript (call asynchronously)
<p>I'm trying change text before I get feeds.<br> But the text changes after I got the feeds.<br> The question/answer it's only for Google Chrome (because it's an extension)<br> Sorry for my poor english ;-)</p> <pre> $("h1").click(function(){ $(this).text("Loading..."); // this happen after fids(); fids(); // function to get feeds }); </pre>
javascript jquery
[3, 5]
1,195,608
1,195,609
Attempted GCF app for Android
<p>I am new to Android and am trying to create a very basic app that calculates and displays the GCF of two numbers entered by the user. Here is a copy of my GCF.java:</p> <pre><code>package com.example.GCF; import java.util.Arrays; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.EditText; import android.widget.TextView; public class GCF extends Activity { private TextView mAnswer; private EditText mA, mB; private Button ok; private String A, B; private int iA, iB; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mA = (EditText) findViewById(R.id.entry); mB = (EditText) findViewById(R.id.entry1); ok = (Button) findViewById(R.id.ok); mAnswer = (TextView) findViewById(R.id.answer1); ok.setOnClickListener(new OnClickListener() { public void onClick(View v) { A = mA.getText().toString(); B = mB.getText().toString(); } }); // the String to int conversion happens here iA = Integer.parseInt(A.trim()); iB = Integer.parseInt(B.trim()); while (iA != iB) { int[] nums={ iA, iB, Math.abs(iA-iB) }; Arrays.sort(nums); iA=nums[0]; iB=nums[1]; } updateDisplay(); } private void updateDisplay() { mAnswer.setText( new StringBuilder().append(iA)); } } </code></pre> <p>Any Suggestions? Thank you!</p>
java android
[1, 4]
3,673,646
3,673,647
Color not changing using Jquery
<p>I want the default "CSS class"to be black, and when using this select function for "selected" to have white text. I don't know where I'm going wrong</p> <pre><code>$(function() { $('a.link').click(function() { $('a.link').removeClass('selected'); $(this).addClass('selected'); $(this).css('color', 'white'); $(this).addClass('result-holder'); $(this).css('color', 'black'); }); }); </code></pre> <p>Image demonstrating the problem:</p> <p><img src="http://i.stack.imgur.com/ZOPXb.png" alt="enter image description here"></p> <p><a href="http://imgur.com/AquDa" rel="nofollow">http://imgur.com/AquDa</a></p>
javascript jquery
[3, 5]
5,682,091
5,682,092
Formating a date in the text of a label inside a form view
<p>I want to know if there's a easier way to format a label that is inside a form view, the code I use is this one, it's inside the event form view databound:</p> <pre><code>protected void FormView2_DataBound(object sender, EventArgs e) { if (FormView2.CurrentMode == FormViewMode.Edit) { Label DAT_Label1 = (Label)FormView2.FindControl("DAT_Label1"); if (DAT_Label1 != null) { DateTime date = Convert.ToDateTime(DAT_Label1.Text); DAT_Label1.Text = string.Format("{0:dd/MM/yyyy}", date); } } } </code></pre> <p>Is there no attribute in the label control that can help making this formating?</p>
c# asp.net
[0, 9]
5,818,567
5,818,568
Android java how to set authtoken to accounts?
<p>How to set authtoken to accounts for block access the 3rd party applications?</p>
java android
[1, 4]
798,778
798,779
multiple jquery galleries
<p>I'm trying to separate two jQuery galleries, so they don't interlink on my html page:</p> <p><a href="http://mashanova.com/myFAQ/faqGallery.html#" rel="nofollow">http://mashanova.com/myFAQ/faqGallery.html#</a></p> <p>here is the html:</p> <p>here is javascript:</p> <pre><code>$(document).ready(function(){ $('.gallery_thumbnails a').click(function(e){ e.preventDefault(); $('.gallery_thumbnails a').removeClass('selected'); $('.gallery_thumbnails a').children().css('opacity','1'); $(this).addClass('selected'); $(this).children().css('opacity','.4'); var photo_fullsize = $(this).attr('href'); var photo_preveiw = photo_fullsize.replace('fullsize','preview'); $('.gallery_preview').html('&lt;a href="'+photo_fullsize+'" style="background-image:url('+photo_preveiw+');"&gt;&lt;/a&gt;'); }); }); </code></pre>
javascript jquery
[3, 5]
5,725,613
5,725,614
jQuery ajax post strange behaviour
<p>I have an ajax function to calculate and perform a certain validation.</p> <p>Code is shown below:</p> <pre><code>function collectFormData(fields) { var data = {}; for (var i = 0; i &lt; fields.length; i++) { var $item = $(fields[i]); data[$item.attr('name')] = $item.val(); } return data; } function calculate(){ var $form = $('#purchase-form'); var $inputs = $form.find('[name]'); var data = collectFormData($inputs); $.ajax({ url: '${validateUrl}', type: 'POST', data: data, contentType: 'application/json; charset=utf-8', success: function (response) { alert(response.status); }, error: function () { alert("error"); } }); } </code></pre> <p>HTML:</p> <pre><code>&lt;button id="calculateBtn" class="btn btn-primary" onclick="calculate();"&gt; &lt;spring:message code="button.calculate" /&gt; &lt;/button&gt; </code></pre> <p>However, as soon as the above function called my form is being submitted. What might cause this ?</p>
javascript jquery
[3, 5]
4,385,540
4,385,541
Jquery datepicker write in other textbox
<p>I.ve a problem with jquery datepicker. Here is tehe code</p> <pre><code>&lt;asp:GridView ID="CompIncGridView1" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="D_id" ClientIDMode="Static" &gt; &lt;Columns&gt; &lt;asp:TemplateField HeaderText="Data idoneità"&gt; &lt;EditItemTemplate&gt; &lt;/EditItemTemplate&gt; &lt;ItemTemplate&gt; &lt;asp:TextBox CssClass="DatePick" ID="ComplyDateTB1" runat="server" Text='&lt;%# Bind("ComplyDate", "{0:d}") %&gt;'&gt;&lt;/asp:TextBox&gt; &lt;/ItemTemplate&gt; &lt;/asp:TemplateField&gt; &lt;/Columns&gt; &lt;/asp:GridView&gt; </code></pre> <p>and this is the jquery code</p> <pre><code>$(document).ready(function () { $(".DatePick").datepicker($.datepicker.regional['it']); }); </code></pre> <p>The problem is that when I click on any textbox, the calendar appears but when I choose the day, the date is written only on the first textbox of the table.</p> <p>thanks</p>
jquery asp.net
[5, 9]
713,333
713,334
Combobox for dot net 2.0 web forms using c#
<p>Could you please help me in finding an answer on whether combobox is available in dot net 2.0.</p> <p>i have installed ajax toolkit for dot net 2.0 however combobox is not available in it moreover combobox which we need should have autocomplete feature where if user types something then combobox should display only items related to text entered.</p> <p>I have seen combobox in dot net, when we type something in them they highlight items which matches entered text however it has all other items also.</p> <p>for example if 'A' is pressed first item that starts with 'A' gets highlighted however combobox have items with starts with other characters as well like B, C etc, i need combobox where if A is typed combobox should populate items related to A only.</p> <p>Is it possible in dot net 2.0.</p> <p>Thanks for all help.</p>
c# asp.net
[0, 9]
1,451,532
1,451,533
If Page is typeof custom class
<p>I'm trying to work out whether my webforms <code>Page</code> is a certain type.</p> <p>I've got a number of base classes that inherit one another:</p> <pre><code>BasePage -&gt; System.Web.UI.Page CMSPage -&gt; BasePage Page -&gt; CMSPage </code></pre> <p>In a custom <code>UserControl</code>, I need to get the the page, but only if it's derived from <code>CMSPage</code>.</p> <p>I've tried:</p> <pre><code>if(Page.GetType() == typeof(CMSPage)) </code></pre> <p>But the value of GetType() just returns the class name of the page. It looks like I need to do:</p> <pre><code>if(Page.GetType().BaseType.BaseType == typeof(CMSPage)) </code></pre> <p>To get the match working. However, some pages are at different <code>BaseType</code> levels before it reaches the type of <code>CMSPage</code>.</p> <p>I could create a function like this to loop through each <code>BaseType</code> until it found the right one:</p> <pre><code>public static bool IsPageTypeOf(this System.Web.UI.Page page, Type targetType) { var pageType = page.GetType(); if (pageType == targetType) return true; while (pageType.BaseType != null) { if (pageType.BaseType == targetType) return true; pageType = pageType.BaseType; } return false; } </code></pre> <p>But it feels messy. Is there a better way to do this?</p>
c# asp.net
[0, 9]
4,706,080
4,706,081
Send email to user for password reset
<p>The flow is:</p> <ol> <li>user enters email address</li> <li>after submit, an email is sent to the user </li> <li>The email will include a link that will take the user to a reset password page.</li> </ol> <p>Now, how do I fetch user's ID based on the email address and encrypt it? Then what should link be? Like, what I want is fetch the User ID then encrypt it somehow so that the link doesn't contain the actual ID and that link will take the user to a page that will have textboxes to reset the password. I am just confused how to go about it.</p> <p>Also is this the secure way? To reset a password like this?</p>
c# asp.net
[0, 9]
1,954,242
1,954,243
Parse data using JSOUP for android app
<p>I'm having issues parsing tags using JSOUP for android. I keep trying to go down further in the document the app doesn't work. Please help. I got "TR" to work which will parse all data within a TR, but I want to grab a single element and parse to the toast box.</p> <p>Thank you</p> <pre><code>import java.io.IOException; import org.jsoup.Jsoup; import org.jsoup.nodes.Document; import org.jsoup.nodes.Element; import org.jsoup.select.Elements; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.Toast; public class JsoupTestActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Button myButton; myButton = (Button)findViewById(R.id.button1); myButton.setOnClickListener(new View.OnClickListener(){ @Override public void onClick(View v) { try { Document doc = Jsoup.connect("http://money.cnn.com/data/bonds/").get(); Elements divs = doc.select("td.login.div.status"); for (Element div : divs) { Toast toast = Toast.makeText(getApplicationContext(), div.text(), Toast.LENGTH_LONG); toast.show(); } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }); } </code></pre> <p>}</p>
java android
[1, 4]
5,123,767
5,123,768
Logic of adding double values
<p>I was given the following question in an interview...</p> <pre><code>Compute the following sum: 1/2 + 1/4 + 1/8 + ... + 1/1048576 </code></pre> <p>I was told that this was a logic question and they weren't looking for the source code, however my answer was the following...</p> <pre><code> private static double computeSum(){ double x = 0.0; for(double i=2; i&lt;=1048576; i*=2){ x += (1 / i); } return x; } </code></pre> <p>What is the correct <em>logical</em> answer to this question?</p>
c# java
[0, 1]
5,246,880
5,246,881
Disable click if class ="X", jQuery
<p>Im trying to build a tabbed content box, and im wondering if its possible that i can disable 1 link with a specific class, such as 'disabled' </p> <p>I read somewhere about a function called preventDefault, would this work?</p> <p><a href="http://jsfiddle.net/Ssr5W/" rel="nofollow">http://jsfiddle.net/Ssr5W/</a></p>
javascript jquery
[3, 5]
2,018,645
2,018,646
Delay href click, but not with SetTimeout
<p>I am trying to track the outbound links via google analytics, and <a href="http://support.google.com/googleanalytics/bin/answer.py?hl=en&amp;answer=55527" rel="nofollow">Google suggests using this</a>: </p> <pre><code>&lt;script type="text/javascript"&gt; function recordOutboundLink(link, category, action) { _gat._getTrackerByName()._trackEvent(category, action); setTimeout('document.location = "' + link.href + '"', 100); } &lt;/script&gt; </code></pre> <p>Which is fine, except, my outbound links are to be opened in a new tab, and I am (naturally) using a <code>target="_blank"</code> for that.. </p> <p>but, the <code>setTimeout</code> method takes that away, and opens the link in the same page.. </p> <p>I've tried using <code>window.open()</code> but I am worried that it will be blocked by browsers..</p> <p>So, is there anyway that I can execute this js function, and delay the click for just a little while? (100ms as google suggests)?</p> <p>Thanks.</p> <p><hr> I've looked at <a href="http://stackoverflow.com/questions/3032182">other</a> <a href="http://stackoverflow.com/questions/351268">questions</a> like this on SO, but they don't deal with opening in new tab/window.</p>
javascript jquery
[3, 5]
1,469,191
1,469,192
How do you hide/show forms in Android?
<p>I come from Windows .Net forms development.</p> <p>This is a pretty basic/fundamental question.</p> <p>I'm attempting to build an Android app that will have multiple screens/forms (like most do)</p> <p>My question is how do you achieve this in Android?</p> <p>For example, a listview loads with menu items. When the user clicks a menu item, how is the new layout/form loaded?</p> <p>Do you simply set visibility of your UI controls based on user actions? Or is there a built in mechanism to control the loading of "forms"?</p> <p>I hope this makes sense. I have some java background and have actually done a small amount of Android development. (But have yet to do an UI type things)</p> <p>Edit: A better way to phrase this might be: What is the Android equivalent of forms?</p> <p>Thanks Kevin</p>
java android
[1, 4]
2,562,752
2,562,753
JQuery Pop up message
<p>I am trying to make a custom pop up message, that appears, displays to the user for 5 seconds and then fades out. This works fine BUT if the use triggers the event multiple times and the time out is already running the message quickly disappears. </p> <p>My function so far...</p> <pre><code>function showMessage(message) { $(".messageText").text(message); $(".message").fadeIn("slow"); closeBox = function(){ $(".message").fadeOut("slow"); } clearInterval(closeBox); setInterval(closeBox, 5000); } </code></pre> <p>Many thanks</p>
javascript jquery
[3, 5]
1,735,953
1,735,954
how to view Listview edit template for user in ASP.NET
<p>I want the user to be able to switch between list view templates, according to button click event</p>
c# asp.net
[0, 9]
5,910,881
5,910,882
how to create universal UI design?
<p>I would like to learn from experienced developers Android, as you develop a UI for different screens? For example, now I have this problem:</p> <p>I have an element <code>(TextView)</code>, which should be placed as nearly aligned to the left, but not back to back, but with a slight indentation. Accordingly, the bigger the screen, so this should become more padding. If it is set fixed <code>(px / dp)</code>, as <code>layout_marginLeft</code>, it will remain so for all screens.</p> <p>Or, like I have a button, which should take approximately the width of the percent of 60, while the remaining 40 percent are left blank. How can this be done without specifying a fixed size?</p> <p>Is it possible to design a universal screen, which will stretch to compress the distance between the elements (as in my case), and do other similar things? Or is it necessary for each screen to create a resource directory and a separate design for each screen? How do you usually do that? </p> <p>Thank you in advance for your reply, it is very important to me.</p>
java android
[1, 4]
3,982,699
3,982,700
Applying drawable to an ImageView from another Activity Layout
<p>Using <a href="https://github.com/jasonpolites/gesture-imageview" rel="nofollow">this</a> library, I'm trying to retrieve the edited image and place it on another activity's ImageView...</p> <p><strong>Calling the function to set the edited drawable to the other ImageView:</strong></p> <pre><code>Log.d("eiDR",gImageView.getDrawable().toString()); PreviewPostal pp = new PreviewPostal(); pp.setImage(gImageView.getDrawable()); </code></pre> <p><strong>Setting the edited drawable to the other ImageView (in PreviewPostal Activity):</strong></p> <pre><code>public void setImage(Drawable dr){ Log.d("ppDR",dr.toString()); //ImageView iv = (ImageView)this.findViewById(R.id.imageForTest); //iv.setImageDrawable(dr); } </code></pre> <p>This logs the same drawable, but if I uncomment those two lines, it gives me a NPE.</p> <p>Note: The activities are wrapped in a TabHost (each activity are a tab with their own layouts).</p> <p>Thanks in advance!</p> <p><strong>Edit: How I add the activities (tabs):</strong></p> <pre><code>mTabHost = getTabHost(); // Tab Editar Imagem TabSpec editImageSpec = mTabHost.newTabSpec("Imagem"); editImageSpec.setIndicator(setTabIndicator(getResources().getDrawable(R.drawable.tab_editimage_icon))); Intent editImageIntent = new Intent(this, EditImage.class); editImageIntent.putExtra("imagem", getIntent().getStringExtra("imagem")); editImageSpec.setContent(editImageIntent); </code></pre>
java android
[1, 4]
5,965,528
5,965,529
Make long log data diplayed with PHP easy to read
<p>I have a long log file I am displaying with PHP. Its getting too long for me and I have to use CTRL+F to look at this thing in any way. What is a good way to display this data in a way easy to read? Best way would be using jquery. </p>
php javascript jquery
[2, 3, 5]
2,614,441
2,614,442
Convert C# row to PHP
<p>I want to convert a C# row to PHP, but it doesn't work (the result isn't the same):</p> <p>C#:</p> <p>PHP:</p> <p>Someone know how to do this?</p> <p>Thanks</p>
c# php
[0, 2]
1,851,287
1,851,288
jQuery hide and show label on user interaction
<p>I have the following jQuery code that hides and shows a label when user interacts with text box. Some scenarios:</p> <p>1.) User focus, label should be at 50% opacity<br> 2.) User types, label should be at 0% opacity<br> 3.) User removes all content but remains focused, label should be at 50% opacity<br> 4.) User removes all content and focus, label should be at 0% opacity<br> 5.) User types content and focus, label should be at 0% opacity </p> <p>So in a nutshell if input has value then no label, if focused it's at 50% and if no value then at 100% opacity.</p> <p>The code is as follows:</p> <pre><code> $('label.placeholder').each(function() { var label = $(this); var input = label.next('input'); label.click(function() { input.focus(); }); input.bind('keyup keydown focus click check change paste copy', function() { if (input.val().length &gt; 0) { label.animate({ opacity: 0 }, 200); } else { label.animate({ opacity: .6 }, 200); } }).bind('blur', function() { label.animate({ opacity: 1 }, 200); }); </code></pre> <p>The problem though is that if a user types in fast or does multiple actions then it can cause the fade back in or out to take a while as it has to go through all the checks for each scenario for each interaction callback. A good example is to type in a load of text and then delete it all again and you will see it take a while to reshow the label.</p> <p>Any ideas on how to prevent this? <a href="http://jsfiddle.net/fFGM7/" rel="nofollow">http://jsfiddle.net/fFGM7/</a></p>
javascript jquery
[3, 5]
4,472,623
4,472,624
How much leeway do I have to leave myself to learn a new language?
<p>I'm a relatively new hire, and I'm starting on a small, fairly simple project. The language that this project will be implemented in is still to be determined. The question basically boils down to - Java or Python? </p> <p>Here's the dilemma: My manager would prefer it to be done in Python. I don't object to that, but I have no experience in Python. I'd really love to learn Python and think I could manage it fairly quickly (especially as it's a small project). BUT the project is due at the end of March and must be ready by then. So they'd rather have it in Java and on time than in Python and late, and they don't want to pressure me to do it in Python if I think I can't make it on time.</p> <p>Sorry about the background - but my question basically is, how long does it take, on average, to adapt to a new language? I know this is subjective and personalized, and depends on how fast the particular programmer is... but talking about an average programmer, or even a somewhat fast one that picks up things quickly, what percentage of an increase does programming in a non-native language (but with similar concepts) cause? As in, if this project would take me about 2 weeks in Java or a .NET language, how much longer can it take me in Python? Can I assume that having double the amount of time (i.e. a new, unfamiliar language causes a 50% increase in programming time) is adequate?</p> <p>And included in this question - from what I've heard, it seems to be pretty easy/intuitive to switch over from Java to Python. Is this true...?</p> <p><strong>Thanks</strong> everyone for all the answers! I didn't realize there are so many sides to this question... I will try to choose an answer soon - each response made me look at it a different way and it's hard to choose one answer.</p>
java python
[1, 7]
414,697
414,698
jQuery - Fade in objects selected by class
<p>I'm trying to select several elements at once and fade them in on window load. The obvious </p> <pre><code>$('.home').delay(200).fadeIn(400); </code></pre> <p>didn't work, and neither did</p> <pre><code>$('.home').each(function(){ $(this).delay(200).fadeIn(400); });​ </code></pre> <p>What's the best way to do this?</p> <p><a href="http://jsfiddle.net/FaqBX/4/" rel="nofollow">http://jsfiddle.net/FaqBX/4/</a></p>
javascript jquery
[3, 5]
1,064,165
1,064,166
why in firefox it is ok, but in ie8 it print 'undefined undefined'?
<pre><code>&lt;div&gt; &lt;span onmouseover="tip(event,this);"&gt;程序错误&lt;div class="content"&gt;good&lt;/div&gt;&lt;/span&gt;&lt;br&gt; &lt;span onmouseover="tip(event,this);"&gt;程序错误&lt;div class="content"&gt;good&lt;/div&gt;&lt;/span&gt;&lt;br&gt; &lt;span onmouseover="tip(event,this);"&gt;程序错误&lt;div class="content"&gt;good&lt;/div&gt;&lt;/span&gt;&lt;br&gt; &lt;span onmouseover="tip(event,this);"&gt;程序错误&lt;div class="content"&gt;good&lt;/div&gt;&lt;/span&gt;&lt;br&gt; &lt;span onmouseover="tip(event,this);"&gt;程序错误&lt;div class="content"&gt;good&lt;/div&gt;&lt;/span&gt;&lt;br&gt; &lt;span onmouseover="tip(event,this);"&gt;程序错误&lt;div class="content"&gt;good&lt;/div&gt;&lt;/span&gt;&lt;br&gt; &lt;span onmouseover="tip(event,this);"&gt;程序错误&lt;div class="content"&gt;good&lt;/div&gt;&lt;/span&gt;&lt;br&gt; &lt;span onmouseover="tip(event,this);"&gt;程序错误&lt;div class="content"&gt;good&lt;/div&gt;&lt;/span&gt;&lt;br&gt; &lt;/div&gt; &lt;p id="vtip" style="position:absolute"&gt;&lt;img id="vtipArrow" src="vtip_arrow.png" /&gt;testtest&lt;span class="content"&gt;&lt;/span&gt;&lt;/p&gt; &lt;script&gt; function tip(evt,s){ $('p#vtip').show(); xOffset = -10; // x distance from mouse yOffset = 10; // y distance from mouse alert(evt.pageY+' '+evt.pageX) } &lt;/script&gt; </code></pre> <p>in firefox it is ok, but in ie8 it print 'undefined undefined'</p>
javascript jquery
[3, 5]
3,491,767
3,491,768
How do you reference a custom object outside of the function it was created in with JavaScript?
<p>I'm currently using JavaScript and jQuery.</p> <p>I have an function which executes once the document is ready, and inside that I am creating objects which contain various attributes.</p> <p>Within the same function, I can access these new object's attributes no problem, however once I'm inside a different function I can't seem to reference them properly and therefore cannot access the objects or the information inside them.</p> <p>What's the correct way to reference the attributes of an object which was created in a different function to the one looking for the information?</p>
javascript jquery
[3, 5]
4,881,294
4,881,295
How to convert signs in url/text to hex characters? (converting = to %3D)
<p>With the script I'm making, jquery is getting vars from url parameter. The value that its getting is an url so if its something like </p> <p><code>http://localhost/index.html?url=http://www.example.com/index.php?something=some</code> </p> <p>it reads:</p> <pre><code>url = http://www.example.com/index.php?something </code></pre> <p>If its like</p> <p><code>http://localhost/index.html?url=http://www.example.com/index.php?something%3Dsome</code></p> <p>it reads:</p> <p><code>url = <a href="http://www.example.com/index.php?something%3Dsome" rel="nofollow">http://www.example.com/index.php?something%3Dsome</a></code></p> <p>which would register as a valid url. my question is how can I search for <code>=</code> sign in the <code>url</code> variable and replace it with hex <code>%3D</code> with jquery or javascript?</p>
javascript jquery
[3, 5]
2,560,919
2,560,920
JQuery : Click Everywhere But Some Element?
<p>I have a textbox and a div below it. I want to hide the div when the user clicks outside the textbox or div.</p> <p>Is there any other way other than document.click to handle that user has clicked outside. Because in some of the controls, event.stoppropagation is given, which on click wont trigger the document click event.</p> <p>Thanks</p>
javascript jquery
[3, 5]
3,155,538
3,155,539
Multiple longclicklisteners
<p>I have 10 items that when long clicked, will bring up an item specific dialog. This is not a listview.</p> <p>Right now, I'm registering a long click listener on every item. Is it possible to capture the view of the long clicked item much like you can set android:onClick="buttonClick" and in code have public void buttonClick(View v), where you can then identify the clicked button using v?</p>
java android
[1, 4]
1,658,345
1,658,346
How to create web crawler in java?
<p>Hi i want to create a web crawler in java in which i want to retrive some data like title, description from the web page and store the datas in database</p>
java android
[1, 4]
1,884,427
1,884,428
Getting elements using Javascript
<p>I have a bunch of input elements that have a particular substring in their IDs. Using javascript, is there a way to get these elements as an array? I wouldn't know the full ID - only the substring.</p> <p>Is this any simpler if I use JQuery?</p>
javascript jquery
[3, 5]
4,676,737
4,676,738
JQuery using DateTimePicker addon dont work
<p>I need DateTimePicker on my site, I try <a href="http://trentrichardson.com/examples/timepicker/" rel="nofollow">this example</a></p> <p>and not working. My code <a href="http://pastebin.com/XEUUrtBj" rel="nofollow">is here</a></p> <p>js file is <strong>also included</strong> in my folder in localhost (/var/www). Thanks...</p>
javascript jquery
[3, 5]
375,780
375,781
How can I tell the owner of a selection?
<p>How can I tell who the parent node of a selection is?</p> <p>I'm getting a selection with:</p> <pre><code> var userSelection; if (window.getSelection) { userSelection = window.getSelection(); } else if (document.selection) { userSelection = document.selection.createRange(); } var selectedText = userSelection; if (userSelection.text) selectedText = userSelection.text; </code></pre> <p>But how can i tell who's the parent node of the selection? That is, if the whole selection is from withing a single <code>div</code> I want to know that div.</p>
javascript jquery
[3, 5]
807,071
807,072
Get ID from URL with jQuery
<p>I've got a url like this:</p> <pre><code>http://www.site.com/234234234 </code></pre> <p>I need to grab the Id after <code>/</code>, so in this case <code>234234234</code></p> <p>How can i do this easily?</p>
javascript jquery
[3, 5]
610,023
610,024
Using jquery to capture all hash clicks?
<p>Any way to use jquery to capture all/any hash tag (#xxxxx) clicks? Can't put them under one class.</p>
javascript jquery
[3, 5]
5,840,643
5,840,644
If on .focusout form contains no value, revert to original value?
<p>I'm trying to get my <code>&lt;input.../&gt;</code> fields to go blank on focus, and if on focus out they're still blank, revert them to their original values.</p> <p>I would've thought this would work, but apparently not:</p> <pre><code>$('input').focus( function() { var init_value = $(this).val(); $(this).val(''); }); $('input').focusout( function() { var new_value = $(this).val(); if(new_value == "") { $(this).val(init_value); } }); </code></pre> <p>Any alterations/advice to get it working would be most appreciated ;)!</p>
javascript jquery
[3, 5]
2,207,363
2,207,364
How to let Username column in the GridView to be opened in the Outlook?
<p>I developed a web-based training matrix that shows the training record for each employee in each division in my department in the company. The matrix will show many columns such as the employee name, username, job title... etc. what I want now is to make the username for each employee to be clickable which means when the admin clicks on it, the outlook will be opened with his email and the admin will be able to send him a message. In my company, this is possible because each employee email is mainly as: [email protected] so how to do that?</p> <p>By the way, the username of the employee will be retrieved from the database using a storedprocedure. The user column is the 4th column in the GridView. </p> <p>what I did is the following:</p> <pre><code>protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { ///Add mailto to the Username column e.Row.Cells[3].Text = "&lt;a href='mailto:'" + e.Row.Cells[3].Text + "@aramco.com?Subject=About%20Your%20Safety%20Training%20Record" +" /&gt;" + e.Row.Cells[3].Text + "&lt;/a&gt;"; } } </code></pre> <p>I could be able to let the username of each employee to be clickable, but I could not be able to put his email in the Outlook what it is opened, <b>so how to do that?</b></p>
c# asp.net
[0, 9]
5,295,194
5,295,195
Set value of input
<p>I'm trying to set the input value to 1 when checking the checkbox and empty when unchecking, Can't get it to work, please help.</p> <pre><code>&lt;td id="check-box"&gt;&lt;input type="checkbox" name="checkbox"&gt;&lt;/td&gt; &lt;td id="qty-box"&gt;&lt;input type="text" name="qtybox"&gt;&lt;/td&gt; &lt;script type="text/javascript"&gt; function setValue(a) { if (a &lt; 1) { a = 1; } } var qty = $('#qty-box [name="qtybox"]').val(); $("#check-box").click(function() { if ($(this[name = "checkbox"]).attr('checked', true)) { setValue(qty); } else { qty = 0; } }); &lt;/script&gt; </code></pre>
javascript jquery
[3, 5]
567,583
567,584
Locating text and performing operation based on its existence
<p>I'm trying to learn jQuery, but it's coming slowly as I really don't know any JavaScript. </p> <p>My site is in VB.NET and I'm putting jQuery code on both my actual <code>.ascx</code> <code>UserControl</code> and in a separate file (something like <code>myscripts.js</code>). This is because I'm using webforms as I still don't know MVC well enough to implement it, so I have to get the clientID's on the page.</p> <p>What I would like to do is the following:</p> <ol> <li>Grab text from a textbox and make it all lowercase</li> <li><p>Get the username from the login info. I've done this like so on my actual page: </p> <pre><code>var userName = "&lt;%=Split(System.Web.HttpContext.Current.User.Identity.Name.ToLowerInvariant, '|')%&gt;"; </code></pre></li> <li><p>Check to see if the username is in the text. If it IS in the text, I want to set a variable to "false", othewise to true.</p></li> </ol> <p>How do I do this?</p>
javascript jquery
[3, 5]
1,455,574
1,455,575
What to log when an exception is raised
<p>Until now I was logging the Error message and the stack trace of an exception. However, I don't think doing that is very helpful, if I don't log all the variables used inside the try block. If I can see all the variables used inside the try block, I think I will have a better idea on what caused the exception and may be I can avoid it from happening again. </p> <p>What do you guys log?</p> <p>Thanks</p>
c# asp.net
[0, 9]
2,254,687
2,254,688
jQuery - removing an alert stop code from working
<p>The code below works, but there is an issue with it.</p> <p>That issue is that unless the alert(this.href); - (about line 11) is in the code the following function does not work.</p> <pre><code>//There are pages which make up 2 chapters in this content //We shall attempt to grab all the links from these pages var c; var chapters = new Array(); chapters[0] = "original/html/0/ID0EFJAE.html"; //Loop through each page of links $.each(chapters, function(key, value) { $("#theContent").append("&lt;div class='chapterindex" + key + "'&gt;working&lt;/div&gt;"); $(".chapterindex" + key).load(value + " .content"); alert(this.href); $(".chapterindex" + key + " div.link a").each(function(intIndex) { alert(".chapterindex" + key); }); }); </code></pre> <p>If I take the first alert out of line 11 then the last alert doesn't fire. What am I doing wrong?</p>
javascript jquery
[3, 5]
3,673,292
3,673,293
Javascript URL Location
<p>I want to check to see if part of my url location have this in it: ?TEST=NEWJERSEY</p> <p>How do i write that?</p>
javascript jquery
[3, 5]
2,837,090
2,837,091
jquery trigger change event on checkbox
<p>Is it possible to trigger change event on a checkbox using javascript/jquery?</p> <p>Something like this (I run triggerChange on click of a button):</p> <pre><code>&lt;label&gt;&lt;input type="checkbox" id="chk"/&gt;Label for chk&lt;/label&gt; &lt;script&gt; function triggerChange(){ $("#chk").trigger("change"); } &lt;/script&gt; </code></pre> <p>When I run the above code I get this error: "<strong>trigger is not a function</strong>".</p>
javascript jquery
[3, 5]
4,709,405
4,709,406
selecting 2nd and 3rd list items in a list with jquery
<p>I have a list.</p> <pre><code>&lt;ul id="navigation"&gt; &lt;li&gt;&lt;a href="#"&gt;&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; </code></pre> <p>And using jquery id like to apply a clas to the 2nd and 3rd list items.</p> <p>Is there simple code for me to do this?</p> <p>Thanks</p>
javascript jquery
[3, 5]
4,348,368
4,348,369
match the passwords
<p>I have a piece of code for the password match. I want to verify every character with password field while typing in confirm password field.</p> <pre><code> var npass = $('#password'); var rpass = $('#confirmpassword'); if( npass.val() != rpass.val() ) { Val.errors = true; Val.showerrors = true; $("#confirmpasswordError").html("must match"); $("#confirmpasswordError").addClass('error-Yes-msg').show(); $("#confirmpassword").addClass('error-input'); return false; } else { $("#confirmpasswordError").removeClass('error-msg').html(''); $("#confirmpassword").removeClass('error-input'); } </code></pre>
javascript jquery
[3, 5]
2,322,309
2,322,310
Javascript to validate hours per week/weeks per year entered
<p>I have an HTML form that allows users to enter values for both "Number of hours per week" and "Number of weeks per year". We would like to include a check to ensure users don't enter values that exceed the possible maximum - this would check that "Number of hours per week" is not more than 168 and that "Number of weeks per year" is not more than 52.</p> <p>I already have a script that calculates the "Average number of hours per week" based on the values entered into the previous 2 inputs as follows:</p> <pre><code>function calc(){ $('#lastYear tr:has(.risk)').each(function(i,v){ var $cel = $(v.cells); var $risk = $cel.eq(1).find('option:selected').val(); var $numb = $cel.eq(2).find('input').val(); var $weeks = $cel.eq(3).find('input').val(); var $avg = ($numb * $weeks) / 52; var $avgRounded = Math.round( $avg * 10 ) / 10; $cel.eq(4).find('input').val($avgRounded); }); </code></pre> <p>I somehow need to extend this to also check the inputs are valid values and display a dialog with some text if they do enter an invalid value. I've setup a <a href="http://jsfiddle.net/fmdataweb/zBKUM/" rel="nofollow">jsFiddle here</a> to demonstrate the form. I'm learning Javascript as I go at the moment and are completely stumped on this one.</p> <p>Update: I've added some code to check the number of hours but I'm now getting stuck in an endless loop where it displays the alert dialog box but I click OK and I get the same alert dialog box. See <a href="http://jsfiddle.net/fmdataweb/zBKUM/1/" rel="nofollow">updated jsFiddle</a>:</p>
javascript jquery
[3, 5]
808,476
808,477
why the code in jquery doesn't work?
<p>the url is as this: <code>http://example.com/download/</code> </p> <pre><code>var pathname = window.location.pathname; if(pathname=='download/'){ $("#subnav-content div:first").hide(); $("#subnav-content div:second").show(); } </code></pre> <p>why the above code in jquery doesn't work? i want to when the url is <a href="http://example.com/download/" rel="nofollow">http://example.com/download/</a>. show the secong div. </p> <p>ps*<em>:does this check affect the site performance?</em>*</p>
javascript jquery
[3, 5]
4,681,779
4,681,780
Show Previous and next week dates
<p>I have 2 buttons( Previous and next ) for week. In between the previous and next week button needs to show week ending date (Fridays) for that week. I want to display previous week date from Sun 11/18 to Mon 11/26 when we click the previous week button. Same as the next week button click event to show from Mon 11/26" to Sun 12/2. How it possible to show? and how to take the week ending date (Fridays) for that week?</p>
javascript jquery
[3, 5]
5,914,571
5,914,572
How to get selected index of a Html select in asp.net?
<p>I have code below:</p> <pre><code> &lt;select id="test"&gt; &lt;option value="a"&gt;aaa&lt;/option&gt; &lt;option value="b"&gt;bbb&lt;/option&gt; &lt;/select&gt; &lt;asp:Button ID="btnTest" runat="server" Text="Test it!" onclick="btnTest_Click" /&gt; I need to get selected index not selected value on postback. How can I do this with asp.net? this is my code for filling the select html: &lt;script language="javascript" type="text/javascript"&gt; $(document).ready(function() { $("#&lt;%=btnTest.ClientID %&gt;").click(function(){ $.ajax( { url: "StateCity.asmx/ReferItems?id=" + getParameterByName('id'), contentType: "application/json; charset=utf-8", dataType: "json", type: "POST", success: function(data) { $("#test").empty(); $.each(data.d, function() { $("#test").append($("&lt;option&gt;&lt;/option&gt;").val(this['Value']).html(this['Text'])); }); }, error: function() { alert("Error"); } }) }) &lt;/script&gt; </code></pre>
c# asp.net
[0, 9]
3,220,872
3,220,873
Is there an easy way to find the "javascript equivalent" of jQuery code?
<p>I am doing a presentation on jQuery for some co-workers and I would like to demonstrate how certain tasks in javascript can be made easier using jQuery.</p> <p>I have come up with a small jQuery function that does some element selection/animation and I was hoping to show them the javascript equivalent of this code. </p> <p>My problem is that my javascript is a bit rusty and I'd rather not try to figure out how to implement this using javascript. Does anyone know of a way to generate javascript from jQuery? If not, can anyone recommend a good resource for finding side by side comparisons of equivalent javascript vs jQuery?</p> <p>My code:</p> <pre><code>var move = 200; $('#clickme').click(function() { $('#main div:even').animate({ left:"+="+move }, 2000); move = -move; }); </code></pre>
javascript jquery
[3, 5]
3,442,136
3,442,137
Retrieve data from JS (non JSON format) by php
<p>Data is inside simple JS, NOT in JSON.</p> <p>I want to grab only 'filenamesBig[filenamesBig.length] ='s value that means all urls of 'filenamesBig[filenamesBig.length]'</p> <pre><code>filenames[filenames.length] = "http://usedcarpics.s3.amazonaws.com/780BONNYVILLECOLDLAKECHRYSLER/4350071_6.jpg"; filenamesBig[filenamesBig.length] = "http://usedcarpics.s3.amazonaws.com/780BONNYVILLECOLDLAKECHRYSLER/b4350071_11.jpg"; </code></pre> <p>Please guide me / give a clue.</p>
php javascript
[2, 3]
2,201,844
2,201,845
Show only 2 rows preview of div content
<p>How to show only two rows preview of div content?</p> <p>If I use like substring in C# would cause HTML tag error issue.</p> <p>so, I wonder if I could do this?</p>
javascript jquery
[3, 5]
1,772,328
1,772,329
using jquery in two usercontrol in the same page
<p>I have two user control in my page uc1 and uc2. I want to make sure that the js function inside these two user control fire when the document is ready.</p> <p>When I am using '$(document).ready({function(){//something});' in both the user control only the function of the first user control is loading. the function for the second user control was not called.</p> <p>Can't I use '(document).ready' in two different user control in the same page? If not then how can I make sure that the respective methods are called only when the document is ready?</p>
jquery asp.net
[5, 9]
2,469,140
2,469,141
JQuery wrapInner trigers jQuery(document).ready twice
<p>I am using the <code>wrapInner</code> function but these triggers my <code>jQuery(document).ready</code> event once again.</p> <p>Is this the normal behaviour? How can this be avoided?</p> <p>Thanks</p> <p>Update:</p> <pre><code>miscellaneous : function(){ $('#nav .active a').bind('click',function(){ return false }); $('.type-a, .type-b, .type-c, .type-d, .type-e').append('&lt;div class="type"&gt;&lt;/div&gt;'); //$('body').wrapInner('&lt;div id="root"&gt;&lt;/div&gt;'); $('#content').wrap('&lt;div id="content-wrapper"&gt;&lt;/div&gt;'); $('#filter .time &gt; li').append('&lt;span class="arrow"&gt;&lt;/span&gt;'); $('#filter .category li a').wrapInner('&lt;span&gt;&lt;/span&gt;'); $('#filter .time &gt; li &gt; ul').hide(); $('#filter .time &gt; li').live('mouseenter',function(){ if($(this).children('ul').css('display') != 'block'){ $(this).children('ul').fadeIn('fast',function(){ $(this).css({'display':'block'}); }); } }).live('mouseleave',function(){ if($(this).children('ul').css('display') != 'none'){ $(this).children('ul').fadeOut('fast',function(){ $(this).css({'display':'none'}); }); } }); } </code></pre> <p>If I uncomment the 4th line the following alert is shown twice. With the line commented the alert is shown only once.</p> <pre><code>jQuery(document).ready(function($) { alert('in ready'); }); </code></pre>
javascript jquery
[3, 5]
3,046,051
3,046,052
Getting selected option data
<p>I am trying to fetch data from currently selected option. I came out with this. Could i somehow improve it or is this fine?</p> <p>Im specially not sure about the current option selector.</p> <pre><code>&lt;option data-id='one'&gt;&lt;/option&gt; .... $('select#first').change(function(){ var smth = $("option:selected",this).data('id'); alert(smth); }); </code></pre>
javascript jquery
[3, 5]
2,319,075
2,319,076
Pass to javascript variable attribute from html input id="attribute"
<p>Input</p> <pre><code>&lt;input type="text" value="" id="row1"&gt; &lt;input type="text" value="" id="row2"&gt; </code></pre> <p>Need to get last character from row and pass it to javascript variable. Here is row1 and row2, need to get variables 1 and 2</p> <p>I try to use this, but does not work</p> <pre><code>$('[id^="row"]').each(function (index, row) { var row = row.id.substring(3); alert (row);//this is only to check if value exists (alert or not) }); </code></pre> <p>No alert at all. But need: on first iteration (.each) var row is 1, on second, - 2, etc. </p> <p>Used this as example. The example works, but my code not</p> <pre><code>$.each([52, 97], function(index, value) { alert(index + ': ' + value); }); </code></pre>
javascript jquery
[3, 5]
3,335,063
3,335,064
RegisterStartupScript and order of execution
<p>I am using <code>ScriptManager.RegisterStartupScript</code> to register calls to a large number of JS functions.</p> <pre><code>ScriptManager.RegisterStartupScript(this, this.GetType(), "Script1", "SomeScript1", true); ScriptManager.RegisterStartupScript(this, this.GetType(), "Script2", "SomeScript1", true); ScriptManager.RegisterStartupScript(this, this.GetType(), "EndScript", "EndScript", true); </code></pre> <p>When the HTML is rendered, it's adding them in order.</p> <pre><code>&lt;script type="text/javascript"&gt; //&lt;![CDATA[ other functions calls.. SomeScript1();SomeScript2();EndScript(); //]]&gt; &lt;/script&gt; </code></pre> <p>However, when I step through in debug mode, the execution of scripts are not in order (Ex: <code>EndScript</code> executes first before <code>SomeScript1</code> or <code>SomeScript2</code>)</p> <p>Doesn't <code>ScriptManager.RegisterStartupScript</code> gaurantee execution in the order it was added? If not, what are the alternatives (I want to always execute <code>EndScript</code> in the end)</p>
asp.net javascript
[9, 3]
4,416,293
4,416,294
Need generic utility C# method for populating ASP.NET DropDownList
<p>I have a method like the following in a utility class. I would like to change the parameter dataSource to accept any type of data source, that is, DataSet, DataView, List&lt;T>, DataTable, and ArrayList.</p> <p>Is this possible? How would I change the method signature (and parameters and types) to allow me the flexibility of passing in any acceptable datasource for binding?</p> <pre><code>public void FillCombo(DropDownList ddl, DataTable dataSource, string textField, string valueField, bool addSelect) { ddl.DataValueField = valueField; ddl.DataTextField = textField; ddl.DataSource = dataSource; ddl.DataBind(); if (addSelect) AddSelectCombo(ddl, "Select", -1); } </code></pre>
c# asp.net
[0, 9]
2,764,734
2,764,735
Android resource files
<p>I have a <code>cheerapp.mp3</code> in my <code>/res/raw</code> folder</p> <p>so my code is</p> <pre><code>String filepath="/res/raw/cheerapp"; //or cheerapp.mp3 file = new File(filePath); FileInputStream in = null; try { in = new FileInputStream( file ); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } </code></pre> <p>The error I got file not found. why?</p>
java android
[1, 4]
2,122,323
2,122,324
Syncronize count down time for all users
<p>I need to synchronize the count down time for all users.So it will display identical remaining time to all in asp.net.</p> <p>Waiting for your valuable thoughts </p> <p>Thanking You </p>
c# asp.net
[0, 9]
3,601,097
3,601,098
How do I programatically scroll down the page?
<p>When the page loads, I want to use Javascript/Jquery to automatically take the user to the 500px downwards. But it has to seem natural.</p> <p>How can that be done?</p>
javascript jquery
[3, 5]
4,724,584
4,724,585
Submitting a Javascript object to PHP
<p>Dear fellow developers,<br /> A newbie question from me, please.</p> <p>I have a large data set that I <strong>prefer</strong> to be submitted as an object instead of an array; e.g.</p> <pre><code>foo = bar = baz = {}; $.ajax({ url: "index", type: "post", data: { foo: foo, bar: bar, baz: baz }, dataType: "json" }); </code></pre> <p>Upon submit, Firebug tells me that I have submitted:</p> <pre><code>bar [object Object] baz [object Object] foo [object Object] </code></pre> <p>What I want is to be able to access the contents of foo, bar, baz (contrived example, of course).</p> <p>Is this possible in Javascript? Or do I need to use arrays, which I do not prefer? </p>
javascript jquery
[3, 5]
1,183,365
1,183,366
call to js function from aspx source
<p>I wrote a Javascript function in the code-behind like this:</p> <pre><code>Page.ClientScript.RegisterClientScriptBlock( Page.ClientScript.GetType(), "MyScript", "&lt;script type='text/javascript'&gt;" + "var urls="+s + "function carousel(params) { ... }" + "&lt;/script&gt;"); </code></pre> <p>How can I call to the javascript function <strong>that I wrote in the code-behind</strong> on the client' side (on the level of the ASPX page)?</p>
c# javascript asp.net
[0, 3, 9]
4,878,980
4,878,981
jQuery- Erroneous duplicate append to list
<p>Very much new to web development and I've come across an issue when trying to implement a multi dimensional array, when I append a new li to an ul with the code below it produces 2 li's.</p> <p>The parameters of the function are dest-the ul to append to and list-the multi dim array set as:</p> <pre><code>var webList2 = [["link.html","name"],["link.html","name"]... </code></pre> <p>I'm pretty sure there may be other issues with my code but it seems I may be missing something I'm not familiar with yet.</p> <p>Anyone able to shed some light?</p> <pre><code>function expand(dest,list){ var i = 2; function expandLoop() { setInterval(function() { if(i &lt; list.length) { i++; var $newLi = $('&lt;li&gt;&lt;li&gt;'); var $newA = $('&lt;a&gt;&lt;/a&gt;').attr('href',list[i][0]).text(list[i][1]); $newLi.append($newA).appendTo(dest).hide().fadeIn(20); } }, 20); } $(expandLoop); } </code></pre> <p>Thank you.</p>
javascript jquery
[3, 5]
2,928,236
2,928,237
how to upload an image file without any postback in ASP.NET
<p>I am uploading a file using the <code>&lt;asp:FileUpload&gt;</code> and <code>&lt;asp:button&gt;</code> controls but I want to do it without a postback. On button click I execute the following code. </p> <pre><code>protected void btnUpload_Click(object sender, EventArgs e) { string strFileName = Path.GetFileName(FileUpload1.FileName); //fileupload1 is the &lt;asp:fileupload ID FileUpload1.SaveAs(Server.MapPath("~/UploadFile/" + strFileName + "")); imgUpload.ImageUrl = "../UploadFile/" + strFileName + ""; //imgupload is the &lt;img ID on which I am showing the image after upload imgUpload.Visible = true; } </code></pre> <p>After uploading the file I am showing the saved image from the specified folder in my project solution, but on clicking the upload button the whole page gets loaded and I don't want the postback on clicking the upload button.</p>
c# asp.net
[0, 9]
1,429,410
1,429,411
jQuery methods, order of optional arguments
<p>I just played around a bit with the <a href="http://api.jquery.com/animate/" rel="nofollow">animate()</a> method.</p> <blockquote> <p>.animate( properties [, duration] [, easing] [, complete] )</p> </blockquote> <p>I know that I dont have to pass all the arguments to a function in javascript. But what I would like to know is how jquery figures out that <code>function(){ }</code> refers to the callback function, which is actually the 4:th parameter, instead of the easing string (which is the 3:rd)?</p> <pre><code>$('div').animate({ height: '10px' }, 100, function(){ }); </code></pre>
javascript jquery
[3, 5]
3,138,365
3,138,366
Why am I not able to install Android SDK?
<p>I installed android sdk. When I click the android sdk manager. Then the the following error message is displayed in an alert box </p> <blockquote> <p>Failed to fetch URL <a href="https://dl-ssl.google.com/android/repository/repository.xml" rel="nofollow">https://dl-ssl.google.com/android/repository/repository.xml</a>, reason: sun. Security. Validator. ValidatorException: PKIX path validation failed: java.security.cert.certPathValidatorException: timestamp check failed</p> </blockquote> <p>Please help me to solve the issues.</p>
java android
[1, 4]
4,718,096
4,718,097
Only Allow Numbers to be Typed in Input Field
<p>I'd like to have the phone number field on <a href="http://myfrugaltech.com/dev/savoo/register/" rel="nofollow">this website</a> only accept numbers or digits. I do not have access to edit the HTML code, so can this be done with jQuery by targeting the field's ID? If so, how can it be done?</p> <p>I've already tried a few suggestions on this site and none have worked so far.</p> <p>Thanks in advance for any assistance!</p>
javascript jquery
[3, 5]
1,021,242
1,021,243
Faster string operations
<p>I realise that the users system is a factor in this but if I was working on extracting data from a string, which would be more efficient? PHP or JavaScript?</p> <p>lets say I have <code>ch_123456789abc_wakkawakka</code> (returned from a mysql query), would it be better to explode out the <code>123456789abc</code> part in php or on the client side? Either way the first string will still be transmitted so this is not a question of a smaller response size. I'm just interested in which the faster engine would be.</p>
php javascript
[2, 3]
3,687,710
3,687,711
'slideDown' effect with jquery doesnt seem to work
<p>I want to use <code>slideDown</code> effect with jquery effect, however it doesnt appear to work. I think it is because the element on which I am trying to implement the effect is already visible on the screen. I think it may be required to be hidden before it can show up a slideDown effect but I am unsure as to how to implement that. Any guidance on this appreciated.</p>
javascript jquery
[3, 5]
3,624,033
3,624,034
selecting multiple rows using shift key using jquery
<p>I tried doing selecting multiple rows using jquery but this code look like cranky.</p> <p>some more code added to above one.using shift + up arrow or down arrow using key board.</p> <pre><code>c </code></pre> <p>where am i going wrong?</p>
javascript jquery
[3, 5]
5,591,199
5,591,200
Why does the position method not return the expected values?
<p>Why does the <code>position</code> method not return <code>[left: 100, top: 10]</code> in this case:</p> <pre><code>&lt;!DOCTYPE HTML&gt; &lt;html&gt; &lt;head&gt; &lt;style&gt; #parent1 { width: 300px; height: 200px; border: solid 9px pink; } #child1 { position: relative; left: 100px; top: 10px; width: 100px; height: 100px; border: solid 5px green; } &lt;/style&gt; &lt;script src="http://jquery-local/jquery.all.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; (function ($) { $(document).ready(function () { console.log($('#child1').position()); }); })(jQuery); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="parent1"&gt; &lt;div id="child1"&gt;&lt;/div&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Is the only way to get the position via the <code>css</code> method? </p>
javascript jquery
[3, 5]
1,899,344
1,899,345
Get position of an item within a ListView?
<p>How would one find the position of a specific item within a ListView? (Populated by SimpleCursorAdapter).</p> <p>The reason I ask: The listview is set to singleChoice mode. When the user closes and reopens the app, I'd like the user's selection to be remembered. </p> <p>The way I've done it so far is when the user clicks on an item, the ID of the chosen item is saved to preferences. What I need to learn is how to reselect the item in the activity's onCreate method once it's been repopulated. </p> <p>My code for saving the selected item's ID:</p> <pre><code> @Override protected void onListItemClick(ListView l, View v, int position, long id) { super.onListItemClick(l, v, position, id); Cursor c = (Cursor) l.getItemAtPosition(position); selectedItem = c.getLong(c.getColumnIndex("_id")); } </code></pre> <p>(I've tried googling, but only seem to find how to get the position of the <em>selected</em> item)</p> <p>Thanks!</p>
java android
[1, 4]
5,942,818
5,942,819
How to save 4 drop down list selections to a cookie, and set drops if cookie present
<p>So I am using jQuery and have setup the jquery cookie plugin.</p> <p>I have 4 drop down lists on my page, and I want to save the user's selections in a cookie, so when they come back to the page I automatically pre-select their previous selections.</p> <p>I added a class to all my drop downs "ddl-cookie", and I was just thinking if I could somehow loop through all the drop down lists using the class, and save the selection and also loop to set the selections when the user returns to the page.</p> <pre><code>$(".ddl-cookie").each(function() { }); </code></pre> <p>It seems that given a cookie name, I can save a single key/value in the cookie.</p> <p>So I'm guessing the only way for me to do this would be to have a comma separated list of drop down list names and values (selection value)?</p>
javascript jquery
[3, 5]
4,343,010
4,343,011
Jquery date picker - want display date in an input field
<p>Hava an jquery calendar:</p> <pre><code>$(function() { $("#datepicker").datepicker({ minDate: 'today', maxDate: "+90D", showOn: "button", buttonImage: "images/calendar.gif", buttonImageOnly: true, dateFormat: "D, dd MM, yy" }); }); </code></pre> <p>and </p> <pre><code>&lt;form method="post"&gt; &lt;div id="datepicker"&gt; &lt;input type="text" id="datepicker" name="datepicker"/&gt; &lt;/div&gt; &lt;/form&gt; </code></pre> <p>I want to display the date inside the input field...Please help me</p>
javascript jquery
[3, 5]
4,101,260
4,101,261
ASP.NET Response.End Problem
<p>i got a page users downloading files from there.And when a user click download link and finish downloading file , i am insertin' a new record for my File Download Counter event. (FileID,Date,blalbla..) </p> <p>But there is problem with my script ... after download starts and finish, its adding a new record but after this, its fires event again and making a new record too.So 1 download and 2 new download record. here is my script; </p> <pre><code> if (Page.Request.QueryString["FileID"] != null) { OleDbCommand command = new OleDbCommand("select * from Dosyalar where DosyaID=" + Page.Request.QueryString["FileID"].ToString(), veri.baglan()); string dosyaAdi = ""; int DosyaID = 0; OleDbDataReader dr = command.ExecuteReader(); while (dr.Read()) { dosyaAdi = Server.MapPath("formlar") + "\\" + dr["URL"].ToString(); DosyaID = Convert.ToInt32(dr["FileID"]); } dr.Close(); FileInfo dosya = new FileInfo(dosyaAdi); Response.Clear(); Response.AddHeader("Content-Disposition", "attachment; filename=" + dosya.Name); Response.AddHeader("Content-Length", dosya.Length.ToString()); Response.ContentType = "application/octet-stream"; Response.WriteFile(dosyaAdi); // INSERT A NEW RECORD OleDbCommand ekle = new OleDbCommand("Insert into Indirilenler (FileID,Tarih) values (@p1,@p2)", veri.baglan()); ekle.Parameters.AddWithValue("p1", FileID); ekle.Parameters.AddWithValue("p2", DateTime.Now.ToShortDateString()); ekle.ExecuteNonQuery(); Response.Flush(); Response.End(); </code></pre>
c# asp.net
[0, 9]
4,073,601
4,073,602
Getting text from <td> element using jQuery
<pre><code>if (document.getElementById("td1").innerHTML == "word"){ $("td:first").html("another word"); } </code></pre> <p>I just want to check if this have this text .</p>
javascript jquery
[3, 5]