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
1,066,505
1,066,506
Replace last match in string
<p>Before a problem My string is in this format:</p> <pre><code>string filePath ="F:/jan11/MFrame/Templates/feb11"; </code></pre> <p>I repalce <code>TnaName</code> like this:</p> <pre><code>filePath = filePath.Replace(TnaName, ""); //feb11 is TnaName </code></pre> <p>It's work.But I have a problem when <code>TnaName</code> is same as a <code>folder name</code>.Now I get a string like this:</p> <pre><code>F:/feb11/MFrame/Templates/feb11 </code></pre> <p>Now Its replace both <code>TnaName</code> means <code>feb11</code>.Is there any way to <code>replace</code> only last match .Thanks.</p> <p><strong>note: <code>feb11</code> is <code>TnaName</code> which comes from another process that's not a problem.</strong></p>
c# asp.net
[0, 9]
1,422,862
1,422,863
How can i extract the data that required from web page
<p>Hi all as per the requirement i am having i would like to extract the data from this site</p> <p><a href="http://loving1.tea.state.tx.us/lonestar/Menu_dist.aspx?parameter=101902" rel="nofollow">http://loving1.tea.state.tx.us/lonestar/Menu_dist.aspx?parameter=101902</a></p> <p>I would like to extract the data that was presented in grid how can i can any one help me</p> <p>I tried this</p> <pre><code>WebRequest request = WebRequest.Create("http://loving1.tea.state.tx.us/lonestar/Menu_dist.aspx?parameter=101902"); WebResponse response = request.GetResponse(); Stream data = response.GetResponseStream(); string html = String.Empty; using (StreamReader sr = new StreamReader(data)) { html = sr.ReadToEnd(); } </code></pre> <p><img src="http://i.stack.imgur.com/6ue2x.jpg" alt="enter image description here"></p> <p>The gird data i would like to extract is in the image. Please help</p>
c# asp.net
[0, 9]
2,104,986
2,104,987
JavaScript passing the Value to php query
<p>this is my first post here and hopefuly someone will help me fix this problem. I have this mysql query:</p> <pre><code>$query_history = " SELECT ProductProvider AS NameSS, type, StoreOpinionDate AS dating FROM cd_stores WHERE UserFID = '".$row_Profile['UserFID']."' UNION ALL SELECT BrandName AS NameSS, type, BrandOpinionDate AS dating FROM cd_brandopinions WHERE UserFID = '".$row_Profile['UserFID']."' UNION ALL SELECT CommentTitle AS NameSS, type, CommentDate AS dating from cd_comments WHERE UserFID = '".$row_Profile['UserFID']."' UNION ALL SELECT brands.ProductBrand AS NameSS, type, date AS dating from brandtrack INNER JOIN brands WHERE UserFID = '".$row_Profile['UserFID']."' and brandtrack.BrandID = brands.BrandID ORDER BY dating DESC LIMIT 9 "; </code></pre> <p>and follwing javascript:</p> <pre><code>&lt;script type="text/javascript" src="../admin/config/js/jquery/jquery-1.3.2.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; $(document).ready(function(){ $("#loadmorebutton").click(function (){ $('#loadmorebutton').html('&lt;img src="facebook_style_loader.gif" /&gt;'); $.ajax({ url: "facebook_style_ajax_more.php?lastid=" + $(".postitem:last").attr("dating"), success: function(html){ if(html){ $("#postswrapper").append(html); $('#loadmorebutton').html('Load More'); }else{ $('#loadmorebutton').replaceWith('&lt;center&gt;No more posts to show.&lt;/center&gt;'); } } }); }); }); &lt;/script&gt; </code></pre> <p>now the problem is that when I inside form press submit button the Value "dating" from mysql query is not passed on acebook_style_ajax_more.php page using above JavaScript and Im getting empty value passed. What I need to change inside JS code to make it work?</p> <p>Thanks</p>
php javascript
[2, 3]
5,921,645
5,921,646
maskedextender and calenderextender in asp.net
<p>I am new person in asp.net. I have one text box and one calender image button in my asp.net application. I use the masked extender to display date in the textbox like yyyy-mm--dd. Also i use the calender extender for the purpose of clicking image button it will show the date in the textbox. I use the following code. </p> <pre><code> &amp;nbsp;&lt;asp:ImageButton ID="imgdatefrom" runat="server" ImageUrl="~/images/calendar.jpeg" Height="19px" Width="20px" /&gt; &amp;nbsp;&amp;nbsp;&lt;asp:Label ID="lblTo" runat="server" Text="End Date" ForeColor="Black" Font-Size="Small"&gt;&lt;/asp:Label&gt; &lt;asp:Label ID="enddateval" runat="server" ForeColor="Red" Text="*"&gt;&lt;/asp:Label&gt; &amp;nbsp;&lt;asp:CalendarExtender ID="txtDateFrom_CalendarExtender" runat="server" TargetControlID="txtDateFrom" Format="yyyy-MM-dd" PopupButtonID="imgdatefrom" TodaysDateFormat="yyyy d, MMMM"&gt; &lt;/asp:CalendarExtender&gt; </code></pre> <p>While I executing that code and selecting date by clicking image button the selected date will not displayed in the textbox. Can anyone know how to solve the problem. Thank you</p>
c# asp.net
[0, 9]
5,893,092
5,893,093
NullPointerException with simpleAdapter in android
<p>I am using a simpleAdapter to create a listview, however I get this error:</p> <pre><code>Caused by: java.lang.NullPointerException at com.tab.Activity.onCreate(Activity.java:36) </code></pre> <p>and this the code that I am using:</p> <pre><code>ArrayList&lt;HashMap&lt;String,String&gt;&gt; list = new ArrayList&lt;HashMap&lt;String,String&gt;&gt;(); private SimpleAdapter notes; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.layout); notes = new SimpleAdapter( this, list, R.layout.display_layout, new String[] { "line1" }, new int[] { R.id.text1} ); ListView lv = (ListView) findViewById(R.id.listview); lv.setAdapter( notes ); } </code></pre> <p>line 36 would be</p> <pre><code>new int[] { R.id.text1} ); </code></pre> <p>text1 is defined, so why I am getting nullpointer error?</p>
java android
[1, 4]
944,970
944,971
how to verify password which is store in database as a hash value?
<p>I want to store password in an encrypted form. I have used sha256. My code is as below</p> <pre><code>public static string ComputeHash(string plainText) { int minSaltSize = 4; int maxSaltSize = 8; Random random = new Random(); int saltSize = random.Next(minSaltSize, maxSaltSize); byte[] saltBytes = new byte[saltSize]; RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider(); rng.GetNonZeroBytes(saltBytes); byte[] plainTextBytes = Encoding.UTF8.GetBytes(plainText); byte[] plainTextWithSaltBytes = new byte[plainTextBytes.Length + saltBytes.Length]; for (int i = 0; i &lt; plainTextBytes.Length; i++) plainTextWithSaltBytes[i] = plainTextBytes[i]; for (int i = 0; i &lt; saltBytes.Length; i++) plainTextWithSaltBytes[plainTextBytes.Length + i] = saltBytes[i]; HashAlgorithm hash = new SHA256Managed(); byte[] hashBytes = hash.ComputeHash(plainTextWithSaltBytes); byte[] hashWithSaltBytes = new byte[hashBytes.Length + saltBytes.Length]; for (int i = 0; i &lt; hashBytes.Length; i++) hashWithSaltBytes[i] = hashBytes[i]; for (int i = 0; i &lt; saltBytes.Length; i++) hashWithSaltBytes[hashBytes.Length + i] = saltBytes[i]; string hashValue = Convert.ToBase64String(hashWithSaltBytes); return hashValue; } </code></pre> <p>Now when user login i want to verify this password How can i do that??</p>
c# asp.net
[0, 9]
2,656,378
2,656,379
Finding ID with Multiple ASP UserControl using JavaScript
<p>I have an ASP usercontrol name <code>ListItem</code>. Each <code>ListItem</code> has 2 ASP controls on it : a label <code>lblIndex</code> and a button <code>btnAction</code></p> <p>On my page, I load 10 <code>ListItem</code> into a panel and set <code>lblIndex</code> on each ListPanel an appropriate index.</p> <pre><code>ListItem 1 : lblIndex.value = '#1' ListItem 2 : lblIndex.value = '#2' ... ListItem 10 : lblIndex.value = '#10' </code></pre> <p>How do I write Javascript that, each time when I click the button on a <code>ListItem</code>, the appropriate <code>lblIndex</code>'s value will appear(through an <code>Alert()</code>). I.e. when I click the <code>btnAction</code> on the 2nd <code>ListItem</code>, the text '#2' will come out.</p> <p>Thank you</p>
c# javascript asp.net
[0, 3, 9]
143,179
143,180
How to find the indices of duplicate values in an array after running a count for duplicate?
<p>I am aware that similar questions to this have been asked, but I have looked through these and am absolutly baffled as to a) how they work, and b) how I could adapt them to fit my purpose. I have therefore started a new question.</p> <p>I have an array of only 4 indices, each index holds a number. My aim is to find the lowest value in this array and return the index of that lowest value. This has not been a problem...</p> <p>The problem arises when the lowest value is repeated in more than one index.</p> <p>In this case what I would like is to be able to first run a "count" on the array to find out if the lowest value is repeated, then if the count is >1 then do the following: find the indices of the repeated values, Finally I need to take the values of these indices and do a furthur calculation before finding the lowest value between them.</p> <p>Example:</p> <pre><code> array[ 12.44 , 10.33 , 17.45 , 10.33] //First I need a count to find the number of times the lowest value (10.33) occurs //Then I would like a function to return either a string containing 1,3 to //represent the indices, or an array[ 1 , 3 </code></pre> <p>Once again I apologise if this question has been answered already but please could you explain the answer as I have tried repeatedly to understand he previous answers and can't make head way.</p> <p>Why is it so complicated to find repeated values in an array using js?</p> <p>Thanks in advance for your help, and time!</p> <p>John</p>
javascript jquery
[3, 5]
3,834,814
3,834,815
Adding/Removing Checkbox Values into TextArea
<p>I scoured the the site and found a few examples, I got close but not close enough. I have 2 checkboxes and if a user checks them they are placed in the textarea, if the user removes the check. the value is removed. I want to keep cursor position too.</p> <p>I am able to add but its still clunky. </p> <p>My fiddle is <a href="http://jsfiddle.net/pU2P9/18/" rel="nofollow">http://jsfiddle.net/pU2P9/18/</a></p> <p>here is my code</p> <p> Testing. Values from another field will be inserted here. </p> <pre><code> &lt;form&gt; &lt;p&gt;Favorite Color &lt;label&gt;&lt;input type="checkbox" value="Green" /&gt;Green&lt;/label&gt; &lt;label&gt;&lt;input type="checkbox" value="Red" /&gt;Red&lt;/label&gt;&lt;/p&gt; &lt;/form&gt; var textarea = document.getElementById("myTextArea1"); // $('input[type=checkbox]').click(function () { $('input[type=checkbox]').change(function () { var $parentForm = $(this).closest("form"); // var text = $(".insert-text", $parentForm).val(); var text = $('input[type=checkbox]:checked').val() + " "; // var text = $('input[type=checkbox]:checked', $parentForm).val() + " "; insertAtCursor(textarea, text); }); function insertAtCursor(myField, myValue) { if (document.selection) { myField.focus(); sel = document.selection.createRange(); sel.text = myValue; } else if (myField.selectionStart || myField.selectionStart == '0') { var startPos = myField.selectionStart; var endPos = myField.selectionEnd; myField.value = myField.value.substring(0, startPos) + myValue + myField.value.substring(endPos, myField.value.length); } else { myField.value += myValue; } } ; </code></pre> <p>Any help would be appreciated.</p>
javascript jquery
[3, 5]
1,083,215
1,083,216
getting a result from startActivityForResult
<p>i've a code that will get a image from the gallery and then set a gridSize with it. </p> <p>the main code that will send android to the SizeSelection class.</p> <p>PuzzleAcitivity:</p> <pre><code>if( resultCode == RESULT_OK) { Intent gridSizeIntent = new Intent(); gridSizeIntent.setClass(this, SizeSelection.class); startActivityForResult(gridSizeIntent, GRIDSIZE_VALUE_SELECT); createGameBoard(SizeSelection.getGridSize(this)); } </code></pre> <p>but this is where the trouble kicks in: SizeSelection, when I hit the buttons that should activate and set a gridSize nothing happends. I think the problem is in getting the data from the SizeSelection to the main PuzzleActivity class.</p> <p>sizeSelection:</p> <pre><code>protected static short getGridSize(Context content) { if ( mIbtn3x3 == view) { short gridSize = 3; return gridSize; }else if (mIbtn4x4 == view ) { short gridSize = 4; return gridSize; }else if (mIbtn5x5 == view ) { short gridSize = 5; return gridSize ; } return gridSize; } </code></pre> <p>how am I supposed to finish the getGridSize method? thanks in advance</p>
java android
[1, 4]
110,156
110,157
C# and ASP - Setting a command argument, then command argument disappearing
<p>I'm trying to use a gridviewcommand to delete an entry in the gridview (as well as from the datacontext), but I want to ask the user to confirm or not first. I have a seperate linkbutton to execute the delete code using the ID of the item in the row that the user clicked the delete button in. </p> <p>When the user clicks delete, my codebehind sets the CommandArgument property of the other linkbutton to basically be the same command argument that it passed. But when the user goes to confirm the deletion, all of a sudden the commandargument of the confirmation link is an empty string? Is the property being flushed after the first postback?</p> <p>Here is my code:</p> <p>ASPX</p> <pre><code>&lt;asp:LinkButton ID="lbDelete" runat="server" Text="Delete" CommandName="delete" CommandArgument='&lt;%# Eval("TheId") %&gt;' /&gt; //Delete LinkButton &lt;asp:LinkButton ID="confirmDelete" runat="server" OnClick="confirmDelete_Click" Text="Delete" /&gt; //Confirmation Button </code></pre> <p>C#</p> <pre><code>rowCommandFunction(object sender, GridViewCommandEventArgs e) { // blah blah blah ... confirmDelete.CommandArgument = e.CommandArgument.ToString(); ...// I've put a breakpoint here, and it is setting the value properly... } confirmDelete_Click(object sender, EventArgs e) { //...but when this line tries to run, comfirmDelete.CommandArgument is set to an empty string? int selectedId = int.Parse(confirmDelete.CommandArgument); ... } </code></pre>
c# asp.net
[0, 9]
5,062,572
5,062,573
Did anyone use the Opensudoku java library?
<p>How to create sudoku puzzles using Opensudoku library? And how can I create puzzles with different difficulty levels using this library? Can I get a sample code of sudoku that use this library? </p>
java android
[1, 4]
2,951,120
2,951,121
Load javascript function after other function
<p>I have two functions. I'd like <code>moduleList()</code> to load AFTER <code>reloadModules()</code>:</p> <pre><code>reloadModules(); moduleList(); function reloadModules() { $.get(v2_settings_url + 'v2_nav/', null, function(responseText) { $('#dock ul').html(responseText).parent().fadeIn(); }); $.get(v2_settings_url + 'v2_edit_bar_nav/', null, function(responseText) { var target = $('#edit-nav-bar-settings-div'); target.html(responseText); }); }; </code></pre>
javascript jquery
[3, 5]
4,756,571
4,756,572
How to get the value which is selected in gridview?
<p>When I click on a row I should get the value on which the user is clicked </p> <p>How do I get that?</p>
c# asp.net
[0, 9]
3,275,005
3,275,006
Cant access object via variable?
<p>I have a javascript object defined as follows:</p> <pre><code>var tabs = { 'nav_tweet_search':'tweet-panel', 'nav_shopping_cart':'cart-panel', 'nav_stats':'stats-panel' }; </code></pre> <p>Im trying to access some values using a variable in another function. However, i am getting <code>undefined</code>. I created some console logs .. </p> <pre><code>console.log("panel: "+panel); console.log("tabs: "+tabs); console.log("tabs.panel: "+tabs.panel); </code></pre> <p>Which outputs, </p> <pre><code>panel: nav_tweet_search tabs: [object Object] tabs.panel: undefined </code></pre> <p>Any reason why i wouldnt be able to access the obj using a variable? If i do "tabs.nav_tweet_search" it works </p>
javascript jquery
[3, 5]
834,778
834,779
Play youtube video when clicking on a preview image, php and javascript
<p>I originally was using this javascript to make a preview image play a youtube video on a click event:</p> <pre><code>$(document).ready(function(){ $("#feature_content").click(function(){ var iframe = "&lt;iframe /&gt;"; var url = "http://www.youtube.com/embed/SERIAL_NUMBER?autoplay=1&amp;autohide=1&amp;modestbranding=1&amp;rel=0&amp;hd=1"; var width = 600; var height = 335; var frameborder = 0; $(iframe, { name: 'videoframe', id: 'videoframe', src: url, width: '600', height: '335', frameborder: 0, class: 'youtube-player', type: 'text/html', allowfullscreen: true }).css({'position': 'absolute', 'top': '11px', 'left': '11px'}).appendTo(this); $(this).find('img').fadeOut(function() { $(this).remove();}); }); }); </code></pre> <p>This code works well, the only problem is now I need to switch the url dynamically...and the variable is with php.</p> <pre><code>&lt;?php $url = get_post_meta($id, $youtube[$number], true); // wordpress function ?&gt; </code></pre> <p>How do I pass the url from php to javascript? Do I just do a jquery ajax call?</p>
php jquery
[2, 5]
1,160,584
1,160,585
How to Convert An Enter Key Press Into A Tab Key Press For Web Pages
<p>The enter key press should work like a Tab key press.The enter key press for TextArea and Submit Button should work as usual.Focus should skip from the next element when the next field is disabled/readonly.</p> <p>thanks,</p>
javascript jquery
[3, 5]
5,373,532
5,373,533
android Service to detect that home screen is on
<p>Can I write an service in android which detects that we are on home screen and Toast a message. I want to detect that control is currently on home screen.</p> <p>Let me know if possible.</p> <p>Thanks, Pravin</p>
java android
[1, 4]
961,837
961,838
jQuery onchange select option
<p>Let's say I have this HTML:</p> <pre><code>&lt;select id='list'&gt; &lt;option value='1'&gt;First&lt;/option&gt; &lt;option value='2'&gt;Second&lt;/option&gt; &lt;option value='3'&gt;Third &lt;/option&gt; &lt;/select&gt; &lt;input type ="text" id="text"/&gt; </code></pre> <p>and then this JavaScript</p> <pre><code> //other variables are also declared here var x1 = 5; var x2 = 10; var value = x1 * x2; var list_value =$("#list").change(function() { $(this).val(); // just an example of how i want the function in the variable }); var nwval = value * list_value; $('#text').val(nwval); // some long piece of code // i'm also using the list_value value somewhere in the long piece of code.. </code></pre> <p>I want the val in the textbox to change as the user selects an option, I know it'll work if I wrap the change event around it, but is there any way to go about this while keeping it as that variable <code>list_value</code>?</p>
javascript jquery
[3, 5]
5,973,988
5,973,989
Pop up window in asp.net
<p>I have a send message button and on clicking that I open a website in a new page which has a panel and has few labels and a send button inside the panel. I want to make that panel a pop up on the same window and the source page should be in the background blurred. how to make a pop up in the same window. Please help</p>
c# asp.net
[0, 9]
4,230,409
4,230,410
How can I make this div slide up and down hover effect?
<p>I want to create a <code>&lt;div&gt;</code> animation very much like this site: <a href="http://www.weareinstrument.com/about/" rel="nofollow">http://www.weareinstrument.com/about/</a>. When you hover over the darker grey boxes and the images at the bottom of the screen they seem to slide up and down depending if you're hovering them. I can't seem to find the jQuery in the source code for it. Can anyone inform me on how it would be done?</p>
javascript jquery
[3, 5]
5,643,238
5,643,239
How to get relative position of a draggable item when dropped?
<p>I have the following:</p> <pre><code> $(function() { // Make images draggable. $(".item").draggable({ // Find position where image is dropped. stop: function(event, ui) { // Show dropped position. var Stoppos = $(this).position(); $("div#stop").text("STOP: \nLeft: "+ Stoppos.left + "\nTop: " + Stoppos.top); } }); }); </code></pre> <p>This will get the position of the item when I drop it, but it is relative to the browser window, not the div they are within. How can I get their relative position?</p> <p>edit-> Here is the html/css:</p> <pre><code>&lt;style type="text/css"&gt; .container { margin-top: 50px; cursor:move; } #screen { overflow:hidden; width:500px; height:500px; clear:both; border:1px solid black; } &lt;/style&gt; &lt;body&gt; &lt;div class="container"&gt; &lt;div id="screen"&gt; &lt;img id="productid_1" src="images/KeypadLinc OFF.jpg" class="item" alt="" title="" /&gt; &lt;img id="productid_2" src="images/KeypadLinc ON.jpg" class="item" alt="" title="" /&gt; &lt;/div&gt; &lt;/div&gt; &lt;div id="stop"&gt;Waiting image getting dropped...&lt;/div&gt; &lt;/body&gt; </code></pre>
javascript jquery
[3, 5]
4,365,582
4,365,583
transfer data in functions ? Javascript
<p>how can i transfer certain data in function like <code>test()</code>;</p> <p>I saw some people did this like putting the data in the brackets like test(data);</p> <p>When the function executes it will use the data for example:</p> <pre><code>$('#element').click(function(){ test(somedata); }); function text();{ //how can i get the data stored } </code></pre> <p>am i doing it right? or is there a better way to do this?</p>
javascript jquery
[3, 5]
774,172
774,173
Disabling LinkButton doesn't disable the click event in javascript
<p>I want to disable a <code>LinkButton</code> clink on the client site.</p> <pre><code>objLinkButton.disabled = true; // or objLinkButton.disabled = -1; </code></pre> <p>This disables the link but I am still able to click on the link and do PostBack.</p> <p>Is there any way I can disable the link.</p> <p>Code:</p> <pre><code>&lt;asp:linkbutton id="xyz" runat="server" onClick="javascript:LinkDisable(this)" &gt;&lt;/asp:linkbutton&gt; </code></pre> <p>which renders as a link which does a postback... I am opening the page on postback in a new window. What I want to do is.. when I click on the link for the firsttime.. it will open a new page and then it will disable the link.</p> <p>what I am doing is .. onClick of that link I have a javascript function.. which is something like this..</p> <p>In LinkDisable ...</p> <pre><code>function LinkDisable(obj) { obj.disabled = -1; obj.href = '#'; //Cant return false from here.. otherwise it wont postback... } </code></pre> <p>When I do this.. the link gets grey's out ... but I am still able to click it. I want to stop the user from clicking it the second time.</p> <p>Any help is appreciated.</p>
c# asp.net javascript
[0, 9, 3]
902,426
902,427
detect back button click in browser
<p>I have to detect if a user has clicked back button or not. For this I am using </p> <pre><code>window.onbeforeunload = function (e) { } </code></pre> <p>It works if a user clicks back button. But this event is also fired if a user click F5 or reload button of browser. How do I fix this?</p>
javascript jquery
[3, 5]
1,865,045
1,865,046
Executing math equation in Android
<p>I need to be able to handle a math equation such as "(45+9)/8" in my app. I wanted to just eval it using JavaScript, but realized that I can't use javax.script in Android. So, I found WebView, but I'm having a bit of trouble using it. Most of the examples refer to using an external page with the JS code, or using "javascript: var return ...etc." I'd need to use the latter, but I've been having a bit of trouble with returning the variable to my app. </p> <p>Is it possible to have the JS eval it and then write the value to a hidden TextView?</p>
java javascript android
[1, 3, 4]
4,211,138
4,211,139
Can I call a variable from my .NET codebehind page in the actual aspx?
<p>Say in my codebehind .cs file, I set a variable:</p> <pre><code>protected void Page_Load(object sender, EventArgs e) { int x = 2; } </code></pre> <p>I want to display this dynamically in my aspx page. But this code won't work:</p> <pre><code>&lt;% Response.Write(x); %&gt; </code></pre> <p>How can i accomplish this? Is there any way to pass variables?</p>
c# asp.net
[0, 9]
2,651,984
2,651,985
Unable to get GPS coordinates on Android
<p>I am trying to obtain the GPS coordinates with the following code:</p> <pre><code>public class conTest extends Activity implements LocationListener{ TextView headerText; BufferedReader in = null; private LocationManager lm; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE); lm.requestLocationUpdates(LocationManager.GPS_PROVIDER,0,0,this); } public void onLocationChanged(Location location) { if (location != null) { Toast.makeText(getApplicationContext(),"Location changed : Lat: " + location.getLatitude() + " Lng: " + location.getLongitude(),Toast.LENGTH_SHORT).show(); } } public void onProviderDisabled(String provider) { // TODO Auto-generated method stub } public void onProviderEnabled(String provider) { // TODO Auto-generated method stub } public void onStatusChanged(String provider, int status, Bundle extras) { // TODO Auto-generated method stub } } </code></pre> <p>Problem is that when i try to send gps coordinates using DDMS, a toast will appear and say that the location is 0.0,0.0. This is not what i entered. When i try to send a new and different location, nothing happens.<br> I have allowed mock locations on the emulator and the LOCATION_FINE/INTERNET permissions has been set.<br> I am developing in Eclipse 3.5 using Api 2.1</p> <p>Help! What have I done wrong?</p>
java android
[1, 4]
3,303,769
3,303,770
Problems converting from an object to XML in java
<p>What I'm trying to do is to convert an object to xml, then use a String to transfer it via Web Service so another platform (.Net in this case) can read the xml and then deparse it into the same object. I've been reading this article: </p> <p><a href="http://simple.sourceforge.net/download/stream/doc/tutorial/tutorial.php#start" rel="nofollow">http://simple.sourceforge.net/download/stream/doc/tutorial/tutorial.php#start</a></p> <p>And I've been able to do everything with no problems until here:</p> <pre><code>Serializer serializer = new Persister(); PacienteObj pac = new PacienteObj(); pac.idPaciente = "1"; pac.nomPaciente = "Sonia"; File result = new File("example.xml"); serializer.write(pac, result); </code></pre> <p>I know this will sound silly, but I can't find where Java creates the new File("example.xml"); so I can check the information.</p> <p>And I wanna know if is there any way to convert that xml into a String instead of a File, because that's what I need exactly. I can't find that information at the article.</p> <p>Thanks in advance.</p>
java android
[1, 4]
4,219,955
4,219,956
How to separate data received from $.get() callback function
<p>I have this:</p> <pre><code>&lt;div &gt;&lt;span id="compareResult"&gt;&lt;/span&gt;&amp;nbsp;&amp;nbsp;&lt;span id="result"&gt;&lt;/span&gt;&lt;/div&gt; $.get( 'data.php', { valA: $(this,'option:selected').val() , valB:$(this,'option:selected').val()}, function(childData){ $('#result').html(childData).css('display', 'none')});&gt; </code></pre> <p>PHP:</p> <pre><code>function getData($names,$id,$flag){ if($flag==0){ $strResult = '&lt;select multiple class="sel" id="selectname" size='.count($names).'&gt;'; } if($flag==1){ $strResult = '&lt;select multiple class="sel" id="selname" size='.count($names).'&gt;'; } for($i=0; $i&lt;count($names); $i++) { $strResult.= '&lt;option value='.$id[$i].'&gt;'.$names[$i].'&lt;/option&gt;'; } echo $strResult.= '&lt;/select&gt;';} </code></pre> <p>How do I break apart/parse the response inside .html(childData) so I can put it in different span(i.e. id="compareResult")?</p> <p>Thanks in advance.</p>
php jquery
[2, 5]
2,047,665
2,047,666
Random Text From jQuery Array
<p>I am trying to make an array of strings and then pluck a random string and place it in a div with class "quote". Below is my current code.</p> <pre><code>$(document).ready(function() { var quotes = new Array("foo", "bar", "baz", "chuck"); var randno = Math.floor ( Math.random() * quotes.length ); $('.quote').add(quotes[randno]); }); </code></pre> <p>What am I doing incorrectly?</p> <p>Thanks</p>
javascript jquery
[3, 5]
4,628,003
4,628,004
$(element).data("dataAtribute") vs $(element).hasClass("className")
<p>Which is quicker in jQuery?</p> <p>$(element).data("dataAtribute") vs $(element).hasClass("className")</p> <p>Thanks in advance? Sniffer</p>
javascript jquery
[3, 5]
2,808,125
2,808,126
Make fields non editable using javascript
<p>How can I set a div as non editable with its id or class using jQuery or JavaScript after submission?</p> <pre><code>$('#id').attr("disabled",true); </code></pre> <p>is not working for a div.</p>
javascript jquery
[3, 5]
129,185
129,186
How can I lock(freeze) a div into a jquery application?
<p>I made a jquery application, and I want to add a watermark (a small picture in the top-left corner) to it for the free version. I'm struggling to make as hard as possible for the users to remove it using javascript. I'm loading that image into a div and position it with a high value for it's z-index property, so it's always on top.</p> <p>So I've came up with this solution, but it isn't strong enough:</p> <ul> <li>a timer that adds the watermark periodicaly if it has been reemoved (doesn't works if the user makes it's own timer that removes the watermark periodicaly).</li> </ul> <p>Do you have any other ideeas? But not something very hard to code.</p> <p>Thanks.</p>
javascript jquery
[3, 5]
2,774,014
2,774,015
How read a local xml file in android
<p>I am trying to read a local xml file from res/xml/myxml.xml This is the xml,</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt; &lt;Books&gt; &lt;Number id ="1"&gt; &lt;Description&gt;This is science book. &lt;/Description&gt; &lt;/Number&gt; &lt;Number id = "2"&gt; &lt;Description&gt;This is about cooking. &lt;/Description&gt; &lt;/Number&gt; &lt;/Books&gt; </code></pre> <p>Here is the code,</p> <pre><code>XmlResourceParser pars = res.getXml(R.xml.myxml); while (pars.getEventType() != XmlResourceParser.END_DOCUMENT) { if (pars.getEventType() == XmlResourceParser.START_TAG) { if(pars.getName().equals("Number")) { int id = pars.getAttributeIntValue(null, "id", 0); } } pars.next(); } pars.close(); </code></pre> <p>The above code returns the last id of the xml. How can I check to see if the id == certain integer, than display the description in the textview. Sorry I am new to android and java. I will really appreciate your help. Thanks</p>
java android
[1, 4]
3,719,193
3,719,194
Force keydown event to fire only once per keyCode
<p><strong>Situation</strong>: I have a <code>keydown</code> handler with a <code>switch</code> for what key is pressed, fairly standard stuff, but when any key is held down the <code>keydown</code> event fires repeatedly (rather than just once when the key is actually pressed).</p> <p><strong>Why it's a problem</strong>: I want to keep the <code>keydown</code> listener active, i.e. be able to detect more than one key being pressed at once, but only have the event fire once per <code>keydown</code>. I will want to do something on the <code>keyup</code> for that <code>keyCode</code> based on the time between down and up, but that timing is getting screwed up because of the multiple firings.</p> <p><strong>What I've tried</strong>: I am currently keeping a list of <code>keyCodes</code> that are down, and checking against those in my <code>keydown</code> handler to keep the default behaviour from happening if the <code>keyCode</code> is in my list. However, the event is still firing very often and I'm concerned about the efficiency/elegance of this solution.</p> <p><strong>The actual question</strong>: Is there a good way to limit firing of the <code>keydown</code> event to <em>just</em> when the key is physically pushed down, or to only listen for specific keyCodes?</p>
javascript jquery
[3, 5]
4,360,948
4,360,949
how to jquery replace space also
<pre><code>$(this).html().replace("0 days",""); </code></pre> <p>i want to replace "0 days" to become "". Currently the above statement will replace "0" to "" . that is not what i want. i want to replace entire statement "0 days"</p>
javascript jquery
[3, 5]
3,796,672
3,796,673
detect click inside iframe
<p>i wanna detect click INSIDE iframe not onclick on iframe itself i tried onclick event u must click on iframe itself to trigger function i even tried addeventlistener to window or document nothing work as if the iframe isn't there the function never triger when i click inside iframe :( plz help</p>
javascript jquery
[3, 5]
3,795,545
3,795,546
Getting the first table cell value in a column with jQuery
<p>I have a table with some values. The first row and first column contain values of such called vertical and horizontal sizes respectfully. What I need to do is to click on a table cell and get the horizontal and vertical values for that clicked table cell. What it basically means - get the value of first table cell in the row where the clicked table cell is located and get the first table cell value of the column where the clicked table cell is located. I'm getting the horizontal value with the following code:</p> <pre><code>var horizSize = $('th:first', $(this).parents('tr')).text(); </code></pre> <p>But I'm not sure how to do that for the vertical line. How to get to the first table cell value of the column?</p> <p>Thanks for helping. </p>
javascript jquery
[3, 5]
1,529,344
1,529,345
What causes this error? The TargetControlID of <CheckBoxControlName> is not valid. The value cannot be null or empty
<p>I have searched on the net for this error, but there doesn't appear to be alot on it.</p> <pre><code>The TargetControlID of 'CheckBoxControlName' is not valid. The value cannot be null or empty. </code></pre> <p>Does anyone know of the main causes for this error?</p>
c# asp.net
[0, 9]
1,670,628
1,670,629
jQuery multiple callbacks to one callback counting calls
<p><strong>I need just one callback at the and of multiple callbacks. With a simple "class" MultiCallback that count the calls it seems to be solved. But the fadeIn function of jQuery calls mCallback just once.</strong></p> <p>It have to call mCallback 3 times. That happens by using a callback function directly inside top scope.</p> <p>Tested my MultiCallback class also on my own functions without any problems. I know there a other ways like <a href="http://stackoverflow.com/questions/7378349/hide-multiple-elements-with-jquery-and-get-one-callback">Hide multiple elements with jQuery and get one callback</a>... Just wanna know what is wrong with my logic.</p> <pre><code>&lt;div id="1" style="display: none; background-color: green;"&gt;&lt;/div&gt; &lt;div id="2" style="display: none; background-color: red;"&gt;&lt;/div&gt; &lt;div id="3" style="display: none; background-color: blue;"&gt;&lt;/div&gt; &lt;script&gt; var allElements = "#1, #2, #3"; var multiCallback = new MultiCallback( $(allElements).length, function() { console.log("NEVER ENTER CALLBACK"); }); $(allElements).fadeIn(400, multiCallback.mCallback()); function MultiCallback(limit, fn) { var finishedCalls = 0; function mCallback() { // Just enter one time ! if (++finishedCalls == limit) { fn(); } } return { mCallback : mCallback } } &lt;/script&gt; </code></pre>
javascript jquery
[3, 5]
3,394,935
3,394,936
ARRAY of method functions
<p>Is it posible to store functions in an array in java? Like for example..</p> <pre><code>public void getMyname(){ // do something here; } public void getLastname(){ //do something here; } Array arr = {getLastName,getMyname}; </code></pre> <p>Like that? if so is it right?</p>
java android
[1, 4]
3,306,412
3,306,413
get Unique info for a machine in asp.net
<p>So i have a aspx that gets IP Addresses. but if i have multiple machines coming from an IP address I need some info that will distinguish each machine differently. </p> <p>What would you use?</p>
c# asp.net
[0, 9]
3,372,417
3,372,418
Multiple javascripts not collaborating together properly
<p>I'm new here, I'm a self-taught web designer who frankly have no knowledge of any javascript or jquery. However, I'm able to follow instructions and use plug-ins of course :)</p> <p>I've been trying to search for a solution for the problem I'm experiencing currently.</p> <p>I have a multiple js plug-ins and I think some of them are overlapping and cancelling each other out at the moment.</p> <p>The following is what I have between &lt; /body> and &lt; /html></p> <p>*Sorry, I tried posting the codes but got a warning telling me that they were from another domain, which is blocked / failed to load. So here's a screenshot image file!</p> <pre><code>http://i.imgur.com/QHBCNjM.jpg </code></pre> <p>All of these were working properly until I added the Content Switcher plug-in (source: <a href="https://github.com/cheynewallace/jquery-content-panel-switcher/tree/master/demo%20and%20instructions" rel="nofollow">https://github.com/cheynewallace/jquery-content-panel-switcher/tree/master/demo%20and%20instructions</a>) </p> <p>When I load the page, MouseOn caption plug-in and Lytebox plug-in work fine. But the moment I trigger the Content Switch plug-in, the aforementioned plug-ins become disabled.</p> <p>Should I give up the content switcher? I've tried other plug-ins and non-javascript methods, but this works and fits my purpose the best so far.. So I'm a little agitated :(</p> <p>If someone could help, that would save my day.</p> <p>Thank you very much!</p>
javascript jquery
[3, 5]
2,925,406
2,925,407
Get the values according to the rearranged unordered list in a textbox
<p>I want to arrange values in a text field according to the order of the list items in an unordered list. List is as following:-</p> <pre><code>&lt;ul id="sort"&gt; &lt;li&gt;1&lt;/li&gt; &lt;li&gt;2&lt;/li&gt; &lt;li&gt;3&lt;/li&gt; &lt;li&gt;4&lt;/li&gt; &lt;li&gt;5&lt;/li&gt; &lt;/ul&gt; </code></pre> <p>I am using <code>sortable()</code> function of Jquery UI on the list mentioned above. I need to copy the same arrangement in a textbox value:-</p> <pre><code>&lt;input type="text" value="" /&gt; </code></pre> <p>For example - If the list is rearranged as <code>3,2,5,4,1</code>, textbox value should be <code>3,2,5,4,1</code> :-</p> <pre><code>&lt;input type="text" value="3,2,5,4,1" /&gt; </code></pre> <p>Thanks in advance!</p>
javascript jquery
[3, 5]
4,402,607
4,402,608
How to retrieve a value from js file?
<p>Basically my question is <strong>How do you get the value of a variable inside a js file.</strong></p> <p>E.g</p> <pre><code>var now = (new Date() - 0); other_var = 'Whats up';//how to pull the value of the other_var which is 'Whats Up' key.embed(); </code></pre> <p>How do get the value of the <code>other_var</code> using php? I only need the value of the variable which is 'whats up'. </p> <p>Made some digging on my own, now I am able to get the content of the js file using <code>file_get_content</code> function in php, just don't know how to pull get the variable and pull its value.</p>
php javascript
[2, 3]
2,203,782
2,203,783
Java calendar method
<p>Why does this keep returning 0? </p> <pre><code>Calendar calendar = Calendar.getInstance(); calendar.get(Calendar.HOUR_OF_DAY)? </code></pre>
java android
[1, 4]
5,731,135
5,731,136
Redirecting to another page with jQuery works in IE, but not Firefox, Safari
<p>I wrote this jQuery code:</p> <pre><code>&lt;script type="text/javascript"&gt; $.ajax({ url: "http://www.mysite.com/login.aspx", context: document.body, success: function(html) { $('body').append(html); } }); &lt;/script&gt; </code></pre> <p>It works in IE in that it's successfully redirected but nothing happens in Firefox and Safari.</p> <p>Why?</p>
javascript jquery
[3, 5]
1,093,422
1,093,423
Where does this code go?
<p>Ok, hopefully this will be my last question. The code I have can be previewed working just fine over here: <a href="http://jsfiddle.net/adeneo/PT523/3/" rel="nofollow">http://jsfiddle.net/adeneo/PT523/3/</a></p> <p>So, when you type in na picture one changes, ma= the second one changes etc</p> <p>But when I put it into my site, nothing happens. Could someone put it in the form of an HTML document/setup so I can see how it needs to be put together in order for it to work and display everything properly? Thank you so much!</p>
javascript jquery
[3, 5]
2,122,423
2,122,424
how to get value from java script then store in php variable
<blockquote> <p><strong>Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/2338942/access-a-javascript-variable-from-php">http://stackoverflow.com/questions/2338942/access-a-javascript-variable-from-php</a></p> </blockquote> <p>hi</p> <p>i want get value from java script, then i will use the value in php, both are in single php file.</p> <p>send how to connect with these two in single file....</p> <p>thanks</p>
php javascript
[2, 3]
705,898
705,899
Getting a div's "scrollWidth" when it has an absolute positioned child-div
<p>I have a problem getting the width of a div's content (of the content, not the div itself).</p> <p>The usual approach would be Javascript's <code>scrollWidth</code> property, I think.</p> <p>The problem: within this div, another div is positioned absolute and has a negative <code>right</code> value (-350px). I can't change this (it's a menu, sliding in when you click a button, overlapping other elements. It needs to be positioned like that).</p> <p>The <code>scrollWidth</code> returns the width of the outer div's content PLUS the negative right-value (in Chrome, didn't test other browsers).</p> <p>Here's a short example:</p> <pre><code>/* ... */ </code></pre> <p><a href="http://jsfiddle.net/R4Cs5/12/" rel="nofollow">http://jsfiddle.net/R4Cs5/12/</a></p> <p>But I need the content's width that is accessible by scrollbars.</p> <p>Any ideas?</p> <p>Please use Jquery, no plain Javascript.</p> <p>Thanks in advance.</p>
javascript jquery
[3, 5]
5,294,918
5,294,919
adding tow events
<p>i have an form which will send some data to an php file , then return some results as example:</p> <pre><code>&lt;form action"&lt;?php $_SERVER['PHP_SELF']?&gt;" method="post" id="data"&gt; &lt;input type"text" name="first_name"/&gt; &lt;input type="text" name="last_name"/&gt; &lt;/form&gt; </code></pre> <p>then in javascript i want catch clcik event in submit form as example :</p> <pre><code>$("#data").submit(function(){ some code ..... }); </code></pre> <p>which that will prevent the default action for submitting inputs form to the php file , the question is can i send data of a form for php file and same time catch event for the same form ?</p> <blockquote> <p>NOTE the returned data from php file will be needed by another php function</p> </blockquote>
php javascript jquery
[2, 3, 5]
2,696,649
2,696,650
Chrome brings the integer value for $('.abc').css("top");
<p>The following javascript code returns two different values for Chrome and Firefox for the same page element.</p> <pre><code>$('.abc').css("top"); </code></pre> <p>Chrome returns: <strong>114px</strong><br> while Firefox returns <strong>114.1230px</strong></p> <p>I've tried this several times on the same page and Chrome consistently chops off the decimal point and the following digits.</p> <p>Any suggestions on how I can get the full value within Chrome as well?</p>
javascript jquery
[3, 5]
1,545,152
1,545,153
Using variables in Asp.NET Control Attributes in Html View
<p>I wonder if there is any way to do this:</p> <pre><code>&lt;asp:Label ID="lblSomething" runat="server" Visible="this.ShowLabel"/&gt; </code></pre> <p>and in the code behind:</p> <pre><code>public bool ShowLabel {get;set;} </code></pre> <p>I know some of you may ask me why I need it but I find this approach cleaner than saying this in the code behind:</p> <pre><code>lblSomething.Visible = this.ShowLabel </code></pre> <p>And also I could say this in source view:</p> <pre><code>&lt;% if(this.ShowLabel){ %&gt; &lt;asp:Label ID="lblSomething" runat="server" Text="Something"/&gt; &lt;% } %&gt; </code></pre> <p>but again, the first one would be more intuitive to me. Any ideas?</p>
c# asp.net
[0, 9]
5,161,063
5,161,064
Passing values between asp.net page and to GA server using JavaScript
<pre><code>protected void Button_Click(object sender, CommandEventArgs e) { Response.Redirect("EnterSession.aspx?session=" + e.CommandArgument.ToString()); } </code></pre> <p>the above code pass the session_id as query string to EnterSession.aspx</p> <p>and I have the following c# related code to the EnterSession.aspx</p> <pre><code>protected string _SessionName = null; public string SessionName; public string sessionId { get { if (null == _SessionName) { SqlConnection thisConnection = new SqlConnection(@"data Source=sorce"); { thisConnection.Open(); SqlCommand thisCommand = thisConnection.CreateCommand(); thisCommand.CommandText = " SELECT session_name FROM myapp_Session WHERE session_id = @SessionId;"; { thisCommand.Parameters.AddWithValue("sessionId", sessionId); SqlDataReader thisReader = thisCommand.ExecuteReader(); thisCommand.Parameters["@SessionId"].Value = Convert.ToInt32(Request.QueryString["session"]); using (var reader = thisCommand.ExecuteReader()) { if (reader.Read()) { _SessionName = reader.GetString(0); } else { throw new ArgumentException("Invalid session id"); } } } } } return _SessionName; } } </code></pre> <p>Now in EnterSession.aspx i used this code to pass the session_name to GA</p> <pre><code>_gaq.push(['pageTrackerTime._trackEvent', document.getElementById('session_name').value, 'test', document.location.href, roundleaveSiteEnd]); </code></pre> <p>and i include this code also in EnterSession.aspx page</p> <pre><code> &lt;input type="hidden" id="session_name" /&gt; &lt;script type="text/javascript"&gt; document.getElementById('session_name').value = '&lt;%= this.SessionName %&gt;'; &lt;/script&gt; </code></pre> <p>Now I cannot find the session_name passed to GA server.</p> <p>can somebody tell me where i made the mistake ..thanx </p>
c# javascript asp.net
[0, 3, 9]
1,045,061
1,045,062
Is this a javascript array with objects in it?
<p>Square brackets is an array, and curly brackets are objects correct?</p> <p>What exactly is this data structure:</p> <pre><code>Some.thing = [ { "swatch_src" : "/images/91388044000.jpg", "color" : "black multi", "inventory" : { "F" : [ 797113, 797114 ], "X" : [ 797111, 797112 ] }, "images" : [ { "postfix" : "jpg?53_1291146215000", "prefix" : "/images/share/uploads/0000/0000/5244/52445892" }, { "postfix" : "jpg?53_1291146217000", "prefix" : "/images/share/uploads/0000/0000/5244/52445904" }, { "postfix" : "jpg?53_1291146218000", "prefix" : "/images/share/uploads/0000/0000/5244/52445909" } ], "skus" : [ { "sale_price" : 199, "sku_id" : 797111, "msrp_price" : 428, "size" : "s" }, { "sale_price" : 199, "sku_id" : 797112, "msrp_price" : 428, "size" : "m" }, { "sale_price" : 199, "sku_id" : 797113, "msrp_price" : 428, "size" : "l" }, { "sale_price" : 199, "sku_id" : 797114, "msrp_price" : 428, "size" : "xl" } ], "look_id" : 37731360 } ];; </code></pre>
javascript jquery
[3, 5]
1,469,653
1,469,654
If statement for Jquery / Javascript
<p>Here's what I'm trying to achieve:</p> <p>I have a div that switches between fixed and absolute positioning depending on the scroll position. I have an example that works but I noticed that it's a little slow because it constantly changes the position on each and every pixel of scroll. So I thought that adding an additional if statement (as kind of a on and off switch) would remedy it a bit. But of course it broke.</p> <p>I rarely use jquery/javascript so to my eyes this seems right but it's not.. any help? Maybe there's even a better way of doing this than if statements.</p> <pre><code>var top = blah; var bottom = blah; var ison=0; $(window).scroll(function (event) { var y = $(this).scrollTop(); if (y &gt;= top &amp;&amp; y &lt;= bottom) { if (ison===0) { $('#float-contain').addClass('fixed'); var ison = 1; } } else { if (ison===1) { $('#float-contain').removeClass('fixed'); var ison = 0; } } }); </code></pre>
javascript jquery
[3, 5]
5,222,065
5,222,066
where does object reside in c#?
<p>i am a java programmer and i know in java objects are stored on heap. Just for curiosity wanted to where does objects reside in c#. </p>
c# java
[0, 1]
3,934,615
3,934,616
Can I create script tag by jQuery?
<p>I want to create a script tag by jQuery.</p> <p>I use the following code:</p> <pre><code>$("&lt;body&gt;").append("&lt;script&gt;&lt;/script&gt;"); </code></pre> <p>It doesn't work. What will you do to acheive it?</p>
javascript jquery
[3, 5]
1,627,664
1,627,665
Using an application in Landscape mode also?
<p>I've an application running successfully, the application runs only in portrait mode only, if i'm going to change this to landscape, it's also possible to change. But, it won't never come to portrait mode. How can i use these (portrait &amp; landscape) in same time? Is it possible? Thanks in advance.</p>
java android
[1, 4]
1,131,201
1,131,202
How to check window close event in php, in an "if" condition?
<p>How can I check if the user is closing the window after filling in one or more forms (parts) of a multipart form, but not all the parts.</p> <p>I have to send the data collected from all/some parts of multipart form to the external server.</p> <p>One condition is that, I can send the data to the external server only once for one complete form.</p> <p>edit: after 2 answersi have edited my question a bit</p>
php javascript
[2, 3]
5,826,876
5,826,877
Dynamic Page Replacing Content causing flickering page
<p>In searching I couldn't find anyone with a similar issue. I'm trying to implement: <a href="http://css-tricks.com/6336-dynamic-page-replacing-content/" rel="nofollow">http://css-tricks.com/6336-dynamic-page-replacing-content/</a> -- I also posted this in their forums as well. </p> <p>You can see my problem in action at - <a href="http://brycestudio.com/test2/" rel="nofollow">http://brycestudio.com/test2/</a> The index loads fine, but once a user tries to navigate to another page through the menu, the new page will load and then keeping loading on top of itself, but shifted to the right. </p> <p>I'm not sure if I'm having a conflict with my current jQuery sliding toggles (I doubt this is the problem) or if its the underlying PHP structure - there is something about the # tag not being liked in the url.</p> <p>the individual php pages look like this:</p> <p>index.php:</p> <pre><code>&lt;?php include('header.php'); ?&gt; &lt;?php include('footer.php'); ?&gt; </code></pre> <p>random image page - wet.php:</p> <pre><code>&lt;?php include('header.php'); ?&gt; &lt;?php include('images.php'); ?&gt; &lt;?php echo $wet ?&gt; &lt;?php include('footer.php'); ?&gt; </code></pre> <p>The header.php is obviously everything from the doctype --> start of #images div and footer.php just closes up any open divs</p> <p>for implementing the "dynamic replacing content" I basically copy/pasted and then modified to call the correct divs.</p> <p>if anyone can, take a look at my code and help me figure out what I'm doing wrong. Thanks. Im really at a loss as my set up seems fairly similar to their example/demo: <a href="http://css-tricks.com/examples/DynamicPage/" rel="nofollow">http://css-tricks.com/examples/DynamicPage/</a></p>
php jquery
[2, 5]
4,477,183
4,477,184
How can i know if all <img> loaded in div using jQuery
<p>How can i know if all loaded in div using jQuery</p> <p>i want to do this after load all img in #slider div</p> <pre><code>var imgHeight = $("#slider img").height(); alert(imgHeight); </code></pre>
javascript jquery
[3, 5]
3,716,249
3,716,250
giving null pointer when using InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
<p>Hi I'm trying to input this piece of code to hide the soft keyboard on the android, but it's returning a null pointer.</p> <p>code:</p> <pre><code>public void testSetTestEnvironment (){ solo.clickInList(4); solo.clickOnMenuItem(ConfigVariables.CATALOGSERVER); assertTrue(solo.searchText(ConfigVariables.CATALOGSERVERURL)); //Enter KeyCode solo.clickInList(5); View myEditText = solo.getViews().get(0); InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(myEditText.getWindowToken(), InputMethodManager.HIDE_IMPLICIT_ONLY); solo.enterText(solo.getEditText(0), ""); solo.enterText(0, ConfigVariables.KEYCODE); assertTrue(popupClickButtonHandler("Enter KeyCode", "OK")); </code></pre> <p>the logs show:</p> <p>java.lang.NullPointerException</p> <p>Thanks.</p>
java android
[1, 4]
4,924,007
4,924,008
Javascript: adding the print function to the body element
<p>I need to implement a print page functionality with the following restrictions:</p> <ul> <li>i cannot have a print view (no print.jsp to point to)</li> <li>i cannot rely on print.css alone (because i have to move stuff around a lot in the DOM to get the page i want to print)</li> </ul> <p>So i implemented this little script that can help clarifying where i'm going with this:</p> <pre><code>$(document).ready(function(){ $('a#print').click(function(){ var body = $('body'); var pageClone = body.clone(true); $('div#search, div.chapters, div#footer').hide(); $('div.content').css('width', '100%'); $('div#logo').css('float', 'right'); window.print(); //reset the content and then copy it back body.html(''); body.html(pageClone); return false; }); }); </code></pre> <p>Now what this prints is the whole page before my DOM changes. So that's not what i want, so i was thinking i could graft the window.print() function to the body element, something like this:</p> <pre><code>var body = $('body'); jQuery.extend(body, {print:function(){return window.print(); }}); body.print(); </code></pre> <p>Except this approach still prints the window content, not the body content if that was ever the problem.</p> <p>Can you help me to print only the body as implemented in the DOM after my changes?</p> <p>Thanks</p>
javascript jquery
[3, 5]
695,568
695,569
How to read android sim contacts and phone contacts separately
<p>I want to read all sim contacts and phone contacts separately in Android. I searched for this and found lots of people having problem with this and I couldn't find any solution yet. I fond some answer <a href="http://stackoverflow.com/a/4409453/559185">here</a>, but it doesn't work for me. When I test this it give me google contacts: </p> <pre><code>RawContacts.ACCOUNT_TYPE + " = 'com.google' " </code></pre> <p>But when I test this it does not give me sim contacts: </p> <pre><code>RawContacts.ACCOUNT_TYPE + " = 'com.android.contacts.sim' " </code></pre> <p>Then I found RawContacts are contacts that created by sync adapter in <a href="https://groups.google.com/group/android-developers/browse_thread/thread/133816827efc8eb9/8671f76b4111f215?pli=1" rel="nofollow">here</a>. That may be the problem. So can anyone tell me the way of getting </p> <ul> <li>All simcontacts</li> <li>All phone contacts</li> </ul> <p>Thanks.</p>
java android
[1, 4]
5,826,906
5,826,907
Length of an object filled with objects?
<p>I've got an object filled with objects and I want to know how many items are in it. How can I do this with JS? Also running jQuery in the page. </p> <p><img src="http://i.stack.imgur.com/8Wnhz.png" alt="enter image description here"></p>
javascript jquery
[3, 5]
2,808,562
2,808,563
Select form option on page load
<p>I would like to select the option contained within a php variable on page load.</p> <pre><code>&lt;?php $pre = 78; ?&gt; &lt;select id="form8" name="form8"&gt; &lt;option value="15"&gt;15&lt;/option&gt; &lt;option value="25"&gt;25&lt;/option&gt; &lt;option value="64"&gt;64&lt;/option&gt; &lt;option value="78"&gt;78&lt;/option&gt; &lt;option value="82"&gt;82&lt;/option&gt; &lt;/select&gt; &lt;script&gt; $(document).ready(function(){ $("form8").val("&lt;?php echo $pre; ?&gt;"); } &lt;/script&gt; </code></pre> <p>Expected output should be, </p> <pre><code>&lt;select id="form8" name="form8"&gt; &lt;option value="15"&gt;15&lt;/option&gt; &lt;option value="25"&gt;25&lt;/option&gt; &lt;option value="64"&gt;64&lt;/option&gt; &lt;option value="78" selected="selected"&gt;78&lt;/option&gt; &lt;option value="82"&gt;82&lt;/option&gt; &lt;/select&gt; </code></pre> <p><a href="http://jsfiddle.net/qQZVN/1/" rel="nofollow">http://jsfiddle.net/qQZVN/1/</a></p>
php javascript jquery
[2, 3, 5]
4,605,431
4,605,432
Convert function from JS to PHP
<p>I have a function in javascript and it works just fine, but now I need same function in PHP and it has very strange behavior. It seems to me that functions are identical, still I missed something and cannot find it.</p> <p>borders, neighbors are pre-defined arrays and base is predefined string.</p> <p><strong>Java Script</strong></p> <pre><code>function calculateAdjacent(sourceBase, direction) { sourceBase = sourceBase.toLowerCase(); var lastChar = sourceBase.charAt(sourceBase.length-1); var type = (sourceBase.length % 2) ? 'odd' : 'even'; var base = sourceBase.substring(0,sourceBase.length-1); if (BORDERS[direction][type].indexOf(lastChar)!=-1) { base = calculateAdjacent(base, direction); } return base + TABLE[NEIGHBORS[direction][type].indexOf(lastChar)]; } </code></pre> <p><strong>PHP</strong></p> <p>($table, $neighbors, $borders are defined, they take a lot of space but I can but them in.)</p> <pre><code>function calculateAdjacent($sourceBase, $direction) { $sourceBase = strtolower($sourceBase); $lastChar = $sourceBase[strlen($sourceBase) - 1]; if (strlen($sourceBase) % 2) { $type = "odd"; } else { $type = "even"; } $base = substr($sourceBase, 0, strlen($sourceBase) - 1); if (strpos($borders[$direction][$type], $lastChar) === false) { $base = calculateAdjacent($base, $direction); } // Problem in this line, need to fix '+' to '.' return $base + $table[strpos($neighbors[$direction][$type], $lastChar)]; } </code></pre>
php javascript
[2, 3]
109,856
109,857
Interested in writing a computer game to improve my programming
<p>I've been trying to think of a good project to improve my programming skills. I'm heavilly interested in finance, but getting the data isn't so easy, therefore I thought I would try to make a simple computer game. The problem I have is I am not very 'graphics' savy. To be honest I dont know much about computer graphics. </p> <p>I should say a little about my background before you provide advice- I am very mathematical and I can do Physics (not to postgraduate level, but I know a fair amount of trig and calculus etc).</p> <p>At the moment my initial idea is some sort of game similar to command and conquer, but for prospecting for oil across a large map. To begin with, nothing fancy just entering coordinates and I could randomise the locations of oil found. However, eventually it'd be nice to make it look good- moving vehicles etc. How do companies create graphics? As far as I am aware they don't employ hosts of PhD mathematicians so they must be using libraries?</p> <p>ps if anybody could edit this to add any more relevant tags, please do</p>
java c++
[1, 6]
1,493,932
1,493,933
the IndexOf() method returns -1 all the time
<p>i have two data tables with the same structure</p> <p>the first one has one row of the second one</p> <p>the second one has set of rows </p> <p>what i want is to get the row which comes next to the row of the first data table in the second data table.</p> <p>the first data table his name is :: temp</p> <p>the second data table his name is :: dt</p> <p>i do the following:</p> <pre><code>DataTable temp = new DataTable(); temp = dt.Clone(); DataColumn[] keyColumn = new DataColumn[1]; keyColumn[0] = temp.Columns["photoId"]; temp.PrimaryKey = keyColumn; temp = (DataTable)(Session["currentImage"]); DataRow[] drr = new DataRow[1]; index = dt.Rows.IndexOf(temp.Rows[0]); </code></pre> <p>but the index always comes with one value = -1 </p> <p>although the temp.rows[0] its contents changed all the time</p> <p>when i write dt.Rows.IndexOf(dt.Rows[1]) for examble i get 1</p> <p>but this is not what i want to do ,, what i want to do exactly is to get the datarow next to the datarow of the first dataTable in the second dataTable</p> <p>please help me.</p>
c# asp.net
[0, 9]
453,437
453,438
Including a single javascript file on multiple domains
<p>I have multiple domains with multiple copies of jQuery.js in separate subfolders. I want to consolidate them so there's only one, and so there's no reference in one domain to another so I can use the same one for work and personal.</p> <p>Furthermore, I don't want to use symbolic links because I'll be moving servers sometime this year and I feel that a lot of symlinks could complicate things. One idea I had was instead of this in the HTML:</p> <pre><code>&lt;script src="js/jquery.min.js" type="text/javascript"&gt;&lt;/script&gt; </code></pre> <p>to do this:</p> <pre><code>&lt;script src="jquery_min_js.php" type="text/javascript"&gt;&lt;/script&gt; </code></pre> <p>And that file will look like this:</p> <pre><code>&lt;?php echo '/home/path/to/js_files/js/jquery.min.js' ?&gt; </code></pre> <p>Is there a smarter way to do this? I'd like to somehow make a function so like </p> <pre><code>&lt;script src="get_javascript.php?script=jquery_min_js" type="text/javascript"&gt;&lt;/script&gt; </code></pre> <p>and then get_javascript.php might look like:</p> <pre><code>&lt;?php echo '/home/path/to/js_files/js/'.str_replace('_','.',$_GET['script']).'.js' ?&gt; </code></pre> <p>Am I barking up the wrong tree? Am I even in the right forest?</p>
php javascript jquery
[2, 3, 5]
1,129,499
1,129,500
Differentiate jquery and javascript
<p>How can we differentiate <code>jquery</code> and <code>javascript</code>.?<br> Where we can use <code>jquery</code> not <code>javascript</code> and vice-versa.?</p>
javascript jquery
[3, 5]
644,725
644,726
Why aren't $.put() and $.delete() native in jQuery?
<p>We were having a discussion internally here at work about jQuery having built-in support for $.get() and $.post(), but not for $.put() and $.delete(). </p> <p>Some think that its to keep the js library size smaller. Others think that its not a feature that is often asked for, so is left to plugin developers to make.</p> <p>What are some thoughts from the SO community?</p>
javascript jquery
[3, 5]
4,654,597
4,654,598
How two start two different events at different time?
<p>Here is my code:</p> <p>public class SplashScreen extends Activity {</p> <pre><code>private ImageView poweredByImage; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.requestWindowFeature(Window.FEATURE_NO_TITLE); this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN ); setContentView(R.layout.splash); poweredByImage = (ImageView)findViewById(R.id.ImageView); poweredByImage.setImageResource(R.drawable.powered_by); this.handleAnimation(poweredByImage); Handler handler = null; handler = new Handler(); handler.postDelayed(new Runnable(){ public void run(){ Intent intent = new Intent(SplashScreen.this, HomeScreen.class); startActivity(intent); } }, 3000); } public void handleAnimation(View v) { v.startAnimation(AnimationUtils.loadAnimation(this, R.anim.fadein)); } </code></pre> <p>}</p> <p>I navigate from one screen (SplashScreen) to another (HomeScreen), 3 seconds after the first one appears, but before that to happen I want to start the fade-in animation 1 second after it appears and then the transition to new screen to happen.</p> <p>So how can I do it? What should I use? Any help will be useful!</p>
java android
[1, 4]
1,955,365
1,955,366
Prevent background Activity from being killed?
<p>I have an app that has a list of menu items. When you click a menu item it opens a corresponding activity. Now in that new activity when you click the back button and return to the main list, that activity gets killed and it does not return to its past state when you start it again.</p> <p>My question is, is it possible to not kill the activity when you leave it?</p> <p>I tried saving values like so:</p> <pre><code> protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putString("TO_REMEMBER", "Remember this"); } </code></pre> <p>However once the activity gets killed and than re-started, the oncreate method is not reading any data:</p> <pre><code> protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (savedInstanceState != null) { //This is not getting fired Toast.makeText(this, savedInstanceState.getString("TO_REMEMBER"), Toast.LENGTH_LONG).show(); } } </code></pre> <p>Any help on this is appreciated.</p>
java android
[1, 4]
773,098
773,099
Javascript AJAX call to Jquery Call
<p>In order to have my code written almost fully written in Jquery, I want to rewrite an AJAX call in Jquery.</p> <p>It's a call from a webpage to a Tomcat servlet.</p> <p>Similar code of my present situation:</p> <pre><code>var http = new XMLhttpRequest(); var url = "http://example.com/MessageController?action=send"; http.onreadystatechange = function () if (http.readyState == 4) { if (http.status == 200){ var response = http.responseText;} else {/*code2*/} }; http.async = false; http.open("POST", url, true); http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); http.send(string); </code></pre> <p>Which would be the best way to do this? <code>.ajax</code> or <code>.post</code>? Could you help me with some pseudo code to start this?</p>
javascript jquery
[3, 5]
5,596,980
5,596,981
ASP Login template custom drop down list
<p>I am using the standard authentication (using AD) with the <code>asp:login</code>. I would like to add Dropdown List to the login template (elements would be retreived from the DB). However if I just simply add: </p> <pre><code>&lt;asp:DropDownList ID="ddlDomain" runat="server"/&gt; </code></pre> <p>It is not accessible from the code. After the login is successful I want the value from ddlDomain to be added to the session.</p> <p>Do I need to handle whole login by myself or is there a way to add the element to the template?</p>
c# asp.net
[0, 9]
2,734,134
2,734,135
Easy way to remove ghost text default value on submit
<p>The script code below makes ghost text </p> <pre><code>$('.ghost-text').each(function(){ var d = $(this).val(); $(this).focus(function(){ if ($(this).val() == d){ $(this).val('').removeClass('ghost-text'); } }); $(this).blur(function(){ if ($(this).val() == ''){ $(this).val(d).addClass('ghost-text'); } }); }); </code></pre> <p>But on submit it passes that default ghost value. How to delete it on submit?</p>
javascript jquery
[3, 5]
5,681,746
5,681,747
How To Pass a PHP Variable To Javascript
<pre><code>&lt;html&gt; &lt;head&gt; &lt;?php $your_name=$_POST['name']; ?&gt; &lt;script language="javascript"&gt; function fash(at1,at2) { alert(at1+at2); } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;?php echo $your_name; echo '&lt;script language="javascript"&gt;fash("the key is: "+'&lt;?php echo $your_name; ?&gt;');&lt;/script&gt;'; ?&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>The output is:</p> <blockquote> <p>the key is : undefined</p> </blockquote> <p>How can I fix this?</p>
php javascript
[2, 3]
63,053
63,054
Compare lists after one is dropped
<p>I working on a page in which I need to drag items from one list, drop them in a drop zone, then compare the order in which they were dropped with an answer key using a submit button. Basically a very simple drag and drop quiz. My problem is figuring out the best way to accomplish this. I know a small amount of JQuery, and PHP so any help would be appreciated.</p> <pre><code>&lt;ul id="answerList"&gt; &lt;li&gt;&lt;a draggable="true" href"#" id="one"&gt;Question 1&lt;/li&gt; &lt;li&gt;&lt;a draggable="true" href"#" id="two"&gt;Question 2&lt;/li&gt; &lt;li&gt;&lt;a draggable="true" href"#" id="three"&gt;Question 3&lt;/li&gt; &lt;/ul&gt; &lt;ul id="answerDrop"&gt; &lt;li&gt;Drop Answer Here&lt;/li&gt; &lt;/ul&gt; &lt;div id="submitBtn"&gt; &lt;input type="button"&gt; &lt;/div&gt; </code></pre>
php jquery
[2, 5]
4,469,370
4,469,371
need help understanding this code
<p>this code in book <a href="http://rads.stackoverflow.com/amzn/click/1935182323" rel="nofollow">jQuery in action</a> page 131</p> <p>i don't understand </p> <p><em><strong>.trigger('adjustName');</em></strong></p> <p>what is adjustName</p> <p>and Simple explanation for trigger()</p> <p>thanks :)</p> <pre><code>$('#addFilterButton').click( function() { var filterItem = $('&lt;div&gt;') .addClass('filterItem') .appendTo('#filterPane') .data('suffix','.' + (filterCount++)); $('div.template.filterChooser') .children().clone().appendTo(filterItem) .trigger('adjustName'); }); </code></pre>
javascript jquery
[3, 5]
643,200
643,201
serializing session object in json string
<p>I built a strongly typed session object that looks like this:</p> <pre><code>class MySession { public string UsedID {get;set;} public List&lt;int&gt; ListOfInt {get;set;} public List&lt;string ListOfString {get;set;} ..... } </code></pre> <p>I'm currently using InProc session so when a page loads, I write:</p> <pre><code>MySession TheSession = Session["UserSession"] as MySession; </code></pre> <p>and then later in the code I can access each property with <code>TheSession.XYZ</code> syntax.</p> <p>This is really cool but I'm thinking that it might be better to store the session in the DB.</p> <p>I'm thinking about serializing the MySession object in a json string and store the string in a DB that I can retrieve and deserialize when a page loads.</p> <p>Is this a good way to do it?</p> <p>Thanks for your suggestions.</p>
c# asp.net
[0, 9]
2,871,680
2,871,681
create a CalendarView with my own properties
<p>hello I'm a beginner in android programming and I have a small problem with the CalendarView, I try to change the properties by changing the color of the numbers of days but it does not really change. Does anyone can help me please.</p>
java android
[1, 4]
742,369
742,370
Good advice for coming to javascript (from Python)
<p>I am coming to JavaScript, from Python. </p> <p>I want to write testable, modular JS code, and want advice on tools, best practices and the like. I know about:</p> <ul> <li><a href="http://www.jslint.com/" rel="nofollow">JSLint</a> (and the existence of <a href="http://javascript.crockford.com/" rel="nofollow">Douglas Crockford</a>)</li> <li>Paul Irish (hi Paul!) and the <a href="http://paulirish.com/2010/10-things-i-learned-from-the-jquery-source/" rel="nofollow">10 Things...From the jQuery Source</a> podcast</li> <li>jQuery, jQuery.ui and Themeroller</li> <li>the existence of freenode#javascript and freenode#jquery</li> <li><a href="https://developer.mozilla.org/en/JavaScript" rel="nofollow">Mozilla's MDC Doc Center</a></li> </ul> <p>Stumbling blocks (so far):</p> <p>What am I missing? Idioms / techniques / tools welcome, particularly around arrays (which seem crippled compared to python lists... what am I missing?), namespacing, testing, and documentation (no docstrings? what do I do instead?)</p> <p>(also, are we not allowed to tag things as community wiki anymore? I don't need the rep!)</p> <p>Also, one answer per response please!</p>
javascript python
[3, 7]
3,856,503
3,856,504
Is there means for synchronizing data of my application and MS Outlook?
<p>I have been developing Android applicatiom which should get dates from MS Outlook calendar. I can't find information/tutorials about how I can do it using USB connection. Please, tell me, is there any means for my task? Is there any tutorials how can I do it programmatically? </p>
java android
[1, 4]
6,008,247
6,008,248
JavaScript -- take a picture of a website
<p>On my website I want to load an image that is an exact picture of what you would see on your screen if you were scrolled to the top of a target website -- just a snapshot with no functionality behind it. So if I ran this code with an NY Times article an image of the article's page would be returned. How do I do this?</p>
javascript jquery
[3, 5]
3,623,530
3,623,531
How to prevent execution of event handler?
<p>I wish to authenticate a user each time they click a button. If the user is logged out, and they attempt to click on a button, they are redirected home.</p> <p>However the code after <code>validate()</code> is executes before the user is redirected home. In this example the popup always displays before the user is directed back home. How do I wait for the execution of <code>validate()</code> to complete before the rest of the event handler attempts to execute?</p> <pre><code>$("#main-display").on('click', 'button', function (event){ validate(); hello = window.open( '', '', "height = 100, width = 100"); hello.document.write('hello'); }); function validate(){ $.ajax({ url: 'validate_user.php', dataType: "json", success: function(response) { if(response.status == 'false') { location.href = 'home.php'; } } }); } </code></pre> <p><strong>validate_user.php</strong></p> <pre><code>&lt;?php session_start(); if(!isset($_SESSION['userId'])){ session_destroy(); $response['status'] = 'false'; } else { $response['status'] = 'true'; } echo json_encode($response); ?&gt; </code></pre> <h1>EDIT</h1> <p>Thanks for the answers, however the popup still displays before the user is directed back even with the code bits of the most upvoted answers.</p>
php javascript jquery
[2, 3, 5]
2,863,103
2,863,104
how to make my application support for all devices resolution
<p>I have develop an app which runs very well in my emulator and in my Samsung device. But when I test it in the Motorola emulator, which I have downloaded in my android SDK, it doesn't work. Can anyone help me out to figure this problem of supporting multiple devices?</p>
java android
[1, 4]
3,363,348
3,363,349
Make first and last column not clickable
<p>I have a table being generated in an ASP.net web app. The table has 4 columns. Currently each cell of each row can be clicked to get more detailed info. However, I do not want the first and the last cell in each row to be clickable. How can I make it so that only the first second and third cell can be clicked?</p> <p>Below is some of the code (from the .cs file):</p> <pre><code>if(e.Row.RowType == DataControlRowType.DataRow) { e.Row.BackColor = TRADER_BACKCOLOR; e.Row.Cells[0].Font.Bold = true; e.Row.Attributes.Add("onmouseover", "style.backgroundColor = 'Silver'"); e.Row.Attributes.Add("onmouseout", "style.backgroundColor = '" + TRADER_HEX + "'"); e.Row.Attributes.Add("onclick", "RowClick(this, '" + e.Row.Cells[0].Text + "');"); </code></pre> <p>From the .aspx file:</p> <pre><code>function RowClick(caller, id) { if(document.getElementById(id).style.display == "block") { if(last != "" &amp;&amp; parent == id) { HideDetailed(); } document.getElementById(id).style.display = "none"; } else { document.getElementById(id).style.display = "block"; } } </code></pre>
c# javascript asp.net
[0, 3, 9]
3,379,328
3,379,329
Is there a way to do a 'scoped' add() in jQuery?
<p>The main jQuery method takes a second optional argument to provide context for the search. eg </p> <pre><code>$(".setA", ancestorOfSetsA); </code></pre> <p>However, the jQuery <code>add()</code> method does not accept this context argument. What I am trying to accomplish is:</p> <pre><code>$(".setA", ancestorOfSetsA).add(".setB", ancestorOfSetsB); </code></pre> <p>I am attempting this through a plugin that will overload the <code>add()</code> method but I can't figure out how to combine two jQuery objects into one jQuery object.</p> <p>I would like to find a way to do a scoped <code>add()</code> with jQuery, but failing that, I'll write one myself if I can find a way to merge to jQuery objects.</p>
javascript jquery
[3, 5]
4,414,756
4,414,757
ASP.NET Adding Javascript to page if page not secure
<p>I'm trying to add some share this javascript in between the head tags of an asp.net page but only if the page is not secure (!Request.IsSecureConnection). How do I get the code in the head tags to check for secure connection and then write the javascript if not secure. I've tried using &lt;% %> blocks and RegisterStartupScriptBlock and it's not working</p> <p>UPDATE:</p> <p>Was able to get it to work using this in the Page_Load</p> <pre><code>if(!Request.IsSecureConnection) { HtmlGenericControl Include = new HtmlGenericControl("script"); Include.Attributes.Add("type", "text/javascript"); Include.Attributes.Add("src", "http...."); this.Page.Header.Controls.Add(Include); } </code></pre>
asp.net javascript
[9, 3]
4,009,035
4,009,036
How to replace part of one text field with a value from another text field in jQuery?
<p>I am trying to use jQuery to update a URL (in a text field) dynamically based on the user typing a value in another field.</p> <p>Here's what I've got so far: <a href="http://jsbin.com/isiqus/10/edit" rel="nofollow">http://jsbin.com/isiqus/10/edit</a></p> <p>It works for the first trigger of the keyup event, but not on subsequent keyups. Can anybody tell me where I am going wrong (I'm just getting to grips with jQuery).</p>
javascript jquery
[3, 5]
658,844
658,845
Hide submit button after server validation
<p>I have found this online:</p> <pre><code>function submitButtonClick(button) { if (typeof (Page_ClientValidate) == 'function') { if (Page_ClientValidate() == false) { return false; } } button.style.display = 'none'; // disable won't work return true; } </code></pre> <p>I am not good with Javascript so I couldn't tell what to change...I have a usercontrol with a few buttons, including a submit button. And they are used on every page of my site. And on some pages I have customvalidators. So when a custom validator doesn't validate, the button is gone and there is nothing left to do. What should I change here for the things to work the way I need? Thanks</p>
javascript asp.net
[3, 9]
1,941,601
1,941,602
How to get data from serverside from JavaScript in vs2010
<p>I call another page with an id, which returns the data based on id. I need the result value in JavaScript.</p> <p>Then I need to bind the result to current page content area and display it to the user.</p> <p>Initially, the user clicks one link in current page, then the id of the link should be passed to another page, and processed some function and get result from db.</p> <p>I want to display the result in current page.</p> <p>I am using vs2010. How can I do this?</p>
c# javascript asp.net
[0, 3, 9]
5,114,476
5,114,477
onclick second click
<p>New to asp.net, I am having a problem on a website I am creating, I am using a master page to build my pages. I am trying to change the css class of a li tag using the onclick event in linkbuttons: </p> <pre><code>&lt;asp:LinkButton runat="server" id="AboutButton" OnClick="about_click" PostBackUrl="about.aspx"&gt;&lt;span&gt;About&lt;/span&gt;&lt;/asp:LinkButton&gt; </code></pre> <p>This linkbutton calls a function in the master page's code behind:</p> <pre><code>protected void about_click(object sender, EventArgs e) { if(Page.IsPostBack) { about.Attributes.Add`enter code here`("class", "current"); } } </code></pre> <p>This only works when the page is loaded and the button is clicked again. Any help would be greatly appreciated.</p>
c# asp.net
[0, 9]
128,949
128,950
How to include array content in HTML?
<p>I have this code</p> <pre><code>var users = result.users; // array $("#dialog:ui-dialog").dialog("destroy"); $("#dialog-confirm").dialog({ resizable: false, height: 140, modal: true, open: function() { $(this).children('div.dialog-text').replaceWith("&lt;b&gt;New text goes here&lt;/b&gt;"); }, buttons: { "Okay": function() { $(this).dialog("close"); }, Cancel: function() { is_okay = 0; $(this).dialog("close"); } } }); </code></pre> <p>where the array contain data in the form of</p> <pre><code>{"ss":"Sandra Schlichting","fn":"Full name"} </code></pre> <p>What I am trying to accomplish is to get the content of the arrays in the form of (white space inserted for readability)</p> <pre><code>&lt;table&gt; &lt;tr&gt; &lt;td&gt;Initials&lt;/td&gt; &lt;td&gt;Full Name &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;ss &lt;/td&gt; &lt;td&gt;Sandra Schlichting&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;fn &lt;/td&gt; &lt;td&gt;Full name &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; </code></pre> <p>and have that replaced with <code>&lt;b&gt;New text goes here&lt;/b&gt;</code> in</p> <pre><code>$(this).children('div.dialog-text').replaceWith("&lt;b&gt;New text goes here&lt;/b&gt;"); </code></pre> <p>From what I can tell <a href="http://api.jquery.com/jQuery.each/" rel="nofollow"><code>$.each()</code></a> should be used for this.</p> <p>But still I can't quite figure out how to get started.</p> <p>Can anyone help me out?</p>
javascript jquery
[3, 5]
5,809,438
5,809,439
Is it possible to change form attr name dynamically?
<p>I have one form which it's dynamic depends on parameters. the form name attribute should be different for each dynamic built form. Is there a way how to change form name attribute? or sufficient work around?</p> <p>this way is not working or I'm missing something</p> <pre><code>&lt;form action="get" name="oldname"&gt; &lt;/form&gt; $('#formid').attr('name', 'dynamicname'); </code></pre> <p>I'd like to change the "oldname" via client-side javascript so it ends up like this:</p> <pre><code>&lt;form action="get" name="dynamicname"&gt; &lt;/form&gt; </code></pre> <p>Thanks</p>
javascript jquery
[3, 5]
767,759
767,760
Having problem with jQuery Countdown? Function serverSync: serverTime
<p>serverSync: serverTime Function return value from server but I have checked both server and client time both are same.When i called server to sync with server it will not display countdown. help me ?</p> <pre><code> $(function() { var shortly = new Date(); var newTime = new Date('April 9, 2010 20:38:10'); //for loop divid /// $('#defaultCountdown').countdown({ until: shortly, onExpiry: liftOff, onTick: watchCountdown, serverSync: serverTime }); $('#div1').countdown({ until: newTime }); }); function serverTime() { var time = null; $.ajax({ type: "POST", //Page Name (in which the method should be called) and method name url: "Default.aspx/GetTime", // If you want to pass parameter or data to server side function you can try line contentType: "application/json; charset=utf-8", dataType: "json", data: "{}", async: false, //else If you don't want to pass any value to server side function leave the data to blank line below //data: "{}", success: function(msg) { //Got the response from server and render to the client time = new Date(msg.d); alert(time); }, error: function(msg) { time = new Date(); alert('1'); } }); shortly = time; return time; } [WebMethod] public static String GetTime() { DateTime dt = new DateTime(); dt = Convert.ToDateTime("April 9, 2010 22:38:10"); return dt.ToString("dddd, dd MMMM yyyy HH:mm:ss"); } </code></pre>
c# asp.net jquery
[0, 9, 5]
615,595
615,596
jquery get indexes of all items in a list from a select box
<p>I have a select box like:</p> <pre><code>&lt;select name="blah" id="meh"&gt; &lt;option value="1"&gt;Car&lt;/option&gt; &lt;option value="2"&gt;Horse&lt;/option&gt; &lt;option value="3"&gt;Van&lt;/option&gt; &lt;/select&gt; </code></pre> <p>I then have some Json like:</p> <pre><code>[Object { id="1", label="Car", value="1"}, Object { id="3", label="Van", value="3"}] </code></pre> <p>What I want to do is get the indexes from the select that match the values in my json and also i want to get the indexes from my select that are not in my json. So i've written this bit of code:</p> <pre><code>$.map( data, function( item ) { $('#meh option').filter(function() { if($(this).text() == item.label){ $('ul.chzn-results').append('&lt;li id="meh_chzn_o_'+$(this).index()+'" class="active-result"&gt;' + item.label + '&lt;/li&gt;'); } }); }); </code></pre> <p>Now this get's me the indexes that are in my json; however, i'm struggling with getting those that are not in the json and then doing a <code>$('#meh_chzn_c_'+$(this).index()+').remove();</code> on those that are not part of the json.</p>
javascript jquery
[3, 5]