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,814,481
1,814,482
Toggle element visibility with jQuery!
<p>I have the following markup:</p> <pre><code>&lt;div class="header"&gt;Text&lt;/div&gt; &lt;div class="hiddenArea"&gt;sdsada&lt;/div&gt; &lt;div class="header"&gt;Text2&lt;/div&gt; &lt;div class="hiddenArea"&gt;sdsada&lt;/div&gt; </code></pre> <p>and the following jQuery:</p> <pre><code>$('.header').click(function() { var t = $(this).next('.hiddenArea').slideToggle(); }); </code></pre> <p>When the hiddenArea is revealed I want to hide the other hiddenArea if it is visible? I want to make this so that I can add other headers and hiddenAreas if I need them.</p> <h3>Update:</h3> <p>Thanks Guys, ended up doing this:</p> <pre><code>$('#messages .header').click(function() { if (!$(this).next().is(':visible')) { $('.hiddenArea').slideToggle(); } }); </code></pre>
javascript jquery
[3, 5]
1,209,812
1,209,813
Alternative to document.getElementById().setAttribute() function
<p>Is there any alternative to doing the following line:</p> <pre><code> document.getElementById("btn").setAttribute("onclick", "save(" + id + ");"); </code></pre> <p>This line basically changes the <code>onclick()</code> event of a button to something like: <code>save(34); , save(35);</code> etc. However it fails in IE 7 and 6 but works in IE 8 and Firefox.</p> <p>I can use jquery for this as well.</p>
javascript jquery
[3, 5]
2,001,069
2,001,070
Data not displaying in dynamic drop down list asp.net & C# (no errors too)
<p>// aspx code</p> <pre><code> &lt;asp:DropDownList ID="DropDownList1" runat="server" DataTextField="fullname" DataValueField="username" AutoPostBack="True" Width="125px" Height="22px"&gt;&lt;/asp:DropDownList&gt; </code></pre> <p>// Code behind</p> <pre><code> SqlConnection myConnection = new SqlConnection("Server=xyz;Database=db;Uid=db;Pwd=12345"); myConnection.Open(); SqlDataReader myReaderddl = null; SqlCommand myCommandddl = new SqlCommand("SELECT [username], [fullname] FROM [qa_users]", myConnection); myReaderddl = myCommandddl.ExecuteReader(); myReaderddl.Read(); ddlrep.DataSource = myReaderddl; ddlrep.DataValueField = "[username]"; ddlrep.DataTextField = "[fullname]"; ddlrep.DataBind(); myReaderddl.Close(); </code></pre>
c# asp.net
[0, 9]
1,695,936
1,695,937
Can we get the jQuery Validate error type?
<p>I am using the jQuery Validation Plugin. Is there any way to get the type of error from the jQuery form validation? For example,</p> <pre><code>$('registration-form').validate({ rules: { email: { required: true, email: true } }, messages: { email: { required: "This is a required field.", email: "This is not a valid email address" } }, errorPlacement: function(error, element) { error.appendTo(element.parent()); } }); </code></pre> <p>I would like to place only the error message generated from a "required" error inside a "div" somewhere on the html page rather than appending it to "element.parent()". If I can get the error type, e.g. "required" or "email" error, I can write the code to do this.</p> <p>Any help is appreciated! Thanks!</p> <p>aobs</p>
javascript jquery
[3, 5]
1,743,815
1,743,816
IPhone and Android website design
<p>How do you design and build your website to make it usable on both IPhone and Android, does it have to be pure html?</p>
iphone android
[8, 4]
885,244
885,245
Basic Android development questions
<pre><code>onCreate(Bundle State) { TextView label = new TextView(this); lable.setText("My new Label"); } </code></pre> <p>I read that the <code>TextView</code> has a reference to the <code>Activity</code>. What does it mean for something to have a reference on something else?</p>
java android
[1, 4]
4,546,313
4,546,314
OnBeforeUnload if qty inputs are differents of 0
<p>I have html table like this : </p> <pre><code>&lt;table border="1"&gt; &lt;tr&gt; &lt;td&gt;Prod name &lt;/td&gt; &lt;td&gt;Qty&lt;/td&gt; &lt;td&gt;Add to cart &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;product 1 &lt;/td&gt; &lt;td&gt;&lt;input name="super_group[961]" type="text" class="input-text qty" title="Qty" value="0" size="5" maxlength="12"&gt;&lt;/td&gt; &lt;td&gt;&lt;input type="submit" name="Submit" value="Envoyer" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;product 2 &lt;/td&gt; &lt;td&gt;&lt;input name="super_group[962]" type="text" class="input-text qty" title="Qty" value="0" size="5" maxlength="12"&gt;&lt;/td&gt; &lt;td&gt;&lt;input type="submit" name="Submit2" value="Envoyer" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; </code></pre> <p>and I want to avoid that user quit the page when there is a quantity typed in the qty input fields.</p> <p>(I have to show a message only if a quantity field is not 0).</p>
javascript jquery
[3, 5]
2,137,198
2,137,199
Can't set property to object
<pre><code>var data = {}; .... data[someprop][someotherprop] = 'bla bla' </code></pre> <p>I get</p> <p><code>Uncaught TypeError: Cannot read property ... of undefined</code> and <code>Cannot set property of...</code></p> <p>Yes, the object doesn't have these properties ..yet, but I'm setting them in that line where I get the error lol. So what's up with that?</p>
javascript jquery
[3, 5]
1,382,034
1,382,035
get first occurred only in an array
<p>i have an arrayX of three elements , and i'm using $.inArray() to search for this three element in another arrayY ... and returning the location for each X element in Y</p> <pre><code>X = [1,2,3] ; y = [1,5,6,1,6,9,3,2] ; </code></pre> <p>But there is duplication in <code>y</code>, 1 occurred twice in <code>y[0]</code> and <code>y[3]</code> </p> <p>The real example is here <a href="http://jsfiddle.net/minagabriel/kHG9K/" rel="nofollow">http://jsfiddle.net/minagabriel/kHG9K/</a></p> <p>How do I get the first 1 occupancy and skip the others? </p> <p>I'm pushing the location of 1,2,3 in an array with the first occurred of each one </p>
javascript jquery
[3, 5]
742,700
742,701
jQuery: How to remove this code redundancy?
<pre><code> clone.find('[id]').each(function() { id = $(this).attr('id'); ind = id.search(/\d+$/); $(this).attr('id', id.substr(0,ind)+id_counter); }); clone.find('[for]').each(function() { id = $(this).attr('for'); ind = id.search(/\d+$/); $(this).attr('for', id.substr(0,ind)+id_counter); }); </code></pre> <p>I know I can find elements that have either the <code>id</code> attribute <em>or</em> the <code>for</code> attribute, but then how do I know which one I need to set?</p>
javascript jquery
[3, 5]
3,673,312
3,673,313
why does jquery work differently in various browsers
<ol> <li><p>If jQuery is just a bunch of javascript libraries why would some features not work in certain browsers?</p></li> <li><p>If the jQuery tests have been ran on a WebkitBased browser, can it automatically be assumed that all other WebkitBased browsers will have the exact same behavior whether mobile/desktop or other, if not what would make it act differently?</p></li> <li><p>I need to automatically run jquery unit tests daily and track any variation in results, for visual and other changes how would you go about tracking these?</p></li> </ol>
javascript jquery
[3, 5]
1,398,246
1,398,247
How to force a directory listing using SimpleHTTPServer?
<p>I have an <code>index.html</code> on the folder where SimpleHTTPServer is running, but depending on the value of a URL GET parameter I want to show a directory listing instead. Is that possible? I was trying to query the root directory using ajax, but it returns <code>index.html</code>by default. </p> <p>I guess one possible option is to rename <code>index.html</code> to something like <code>main.html</code> and never use index.html.</p>
javascript python
[3, 7]
5,411,674
5,411,675
Parse Contact details from a block of text
<p>Im trying to create a Business card reader</p> <p>Im having a block of text for example</p> <pre><code>Name Head - Business Development Company Name # 2/324, ll Floor, Some Road, Street, City-Zip, State, Country. Tel : +987654321 Mobile: +123456789 Email : mail@comany.com Website : www.comany.com </code></pre> <p>I want to parse the details out of this text like name, company name, designation, address. I was able to parse number, email address and website. Can anyone help me with it. I dont want to use any webservices, I want it to be done offline.</p>
java android
[1, 4]
5,064,191
5,064,192
Asp.Net Get Screen Width
<p>How can I get the screen width in server side in Asp.net (C#) project?</p> <p>Thanks, John</p>
c# asp.net
[0, 9]
994,816
994,817
Get values of called file
<p>I am calling a .php file in this code. In the file "fetchvalues.php", I am fetching results from the database and want to return the column values back to the calling JQuery function and display them on HTML controls of my page.</p> <p>How to do so?</p> <pre><code>$(document).ready(function() { $("#Edit").click(function() { $.get('fetchvalues.php', null, function() { alert('reached'); }); }); }); </code></pre> <p><strong>Edited:</strong> Code: fetchvalues.php</p> <pre><code>&lt;?PHP //Get selected row's RecordID column value $SelectedRowID = $_GET['UpdateRecordID']; //Open Connection $connection = mysql_connect("localhost:3306", "abcd", "abcd"); mysql_select_db("pglobal", $connection); //Prepare query to retrieve results $FetchResultsQuery = "SELECT * FROM listing WHERE recordid=" . $SelectedRowID; try { $result = mysql_query($FetchResultsQuery); $row = mysql_fetch_row($result); if ($row) { $PostedDate = date('d.M.Y', strtotime($row[0])); $Places = html_entity_decode($row[1]); $Company = html_entity_decode($row[2]); $Designation = html_entity_decode($row[3]); $ProjectDetails = html_entity_decode($row[4]); $DesiredCandidate = html_entity_decode($row[5]); $HRName = html_entity_decode($row[6]); $HRContact = html_entity_decode($row[7]); $Email = html_entity_decode($row[8]); $_SESSION['WorkMode'] = 'Edit'; $_SESSION['DataToBeEdited'] = $PostedDate .'+'. $Places .'+'. $Company .'+'. $Designation .'+'. $ProjectDetails .'+'. $DesiredCandidate .'+'. $HRName .'+'. $HRContact .'+'. $Email; } else { $_SESSION['DataToBeEdited'] = ""; return; } } catch(exception $err) { echo $err; } ?&gt; </code></pre>
php jquery
[2, 5]
1,784,566
1,784,567
Is it possible to have "inherited partial structs" in c#?
<p>Is it possible to use partial structs to achieve something like this: Have an asp.net page base class with the following defined:</p> <pre><code>public partial struct QuerystringKeys { public const string Username = "username"; public const string CurrentUser = "currentUser"; } </code></pre> <p>Have an asp.net page, which inherits from the base class mentioned above, extend the partial declaration:</p> <pre><code>public partial struct QuerystringKeys { /// &lt;summary&gt; /// The page number of the review instances list /// &lt;/summary&gt; public const string Page = "page"; } </code></pre> <p>The final goal is a QuerystringKeys struct with all three constant strings defined in it available to the asp.net page.</p>
c# asp.net
[0, 9]
1,152,387
1,152,388
Adding Content During Runtime
<p>I've just started learning Android, and have been working on a simple application where the user has a simple conversation with the computer.</p> <p>My question is, how can I set up the UI in a way that allows the input from the user to be displayed on the view, during runtime? As the input prompts increase, there will be more content to be displayed, so I'll need to use a scrolling bar, which I believe could be taken care of by the scrollview layout. </p> <p>Basically, what I'm trying to achieve is very similar to how chat applications display content, during runtime. How do I go about doing that? I've looked around, but can't exactly point myself in the right direction.</p>
java android
[1, 4]
1,113,196
1,113,197
JQuery - clone element and change attributes for multiple attributes
<p>I have several elements like this:</p> <pre><code> &lt;div class="image_insert clearfix"&gt; &lt;label for="userfile3"&gt;Image 3&lt;/label&gt; &lt;input type="file" name="userfile3" id="userfile3"&gt; &lt;label for="slika_naziv_eng3"&gt;Image Title&lt;/label&gt; &lt;input type="text" name="slika_naziv_eng3" id="slika_naziv_eng3"/&gt; &lt;/div&gt; </code></pre> <p>And JS for cloning:</p> <pre><code>var img_add = $('.img_add'); img_add.on('click', function(){ var img_ins = $('.image_insert'), i = img_ins.length, clon = img_ins.first().clone().attr({'class' : 'image_insert clearfix', 'name' : 'userfile' + i}).insertAfter(img_ins.last()); }); </code></pre> <p>I need to change all attributes where there is a number. Every time new element is added, it needs to count number of elements and the new number will be number of elements + 1. How can I do this?</p>
javascript jquery
[3, 5]
2,641,934
2,641,935
Save a file where user wants, and in HTML or XML format only
<p>I'm developing a web application using asp.net. There is a text box which contains a HTML or XML file(loaded from server). After validating the file, I want to store that file where the user wishes to save(client), and the user must save in HTML or XML format only. I had developed a code, but it automatically saves, without asking the user.</p> <pre><code> protected void btnsave_Click(object sender, EventArgs e) { string getnote = txtdisplay.Text.Trim(); String filepath = Server.MapPath(@"img\new1.txt"); System.IO.FileStream ab = new System.IO.FileStream(filepath, System.IO.FileMode.Create); System.IO.StreamWriter Write101 = new System.IO.StreamWriter(ab); Write101.WriteLine(getnote); Write101.Close(); } </code></pre> <p>Any help is appreciated</p>
javascript asp.net
[3, 9]
3,119,185
3,119,186
Android Development: Class That Creates an Object, Calls Some Methods Then Returns That Object (How?)
<p>I'm wondering how I'd go about making a class, let's call it Class Master, where: - You call Class Master and it calls Class A, and calls some of that Class A's methods, then returns Class A so you can call methods from the returned Class A where ever you called Class Master.</p> <p>Basically, I want to turn this code:</p> <pre><code>//Create FTPClient object and connect FTPClient ftpClient = new FTPClient(); ftpClient.connect(server); ftpClient.enterLocalPassiveMode(); ftpClient.login(username); ftpClient.listFiles("/"); </code></pre> <p>Into this code:</p> <pre><code>FTPClient ftpClient = new ftpConnection(); //Connects, enters passive mode and logs in then returns the FTPClient object we created so we can do other stuff with it, like below: ftpClient.listFiles("/"); </code></pre> <p>So that I can have one single call that I can use in different activites to connect to an FTP, if you understand what I mean.</p> <p>I tried myself but I didn't get the desired effect for some reason (don't have the code I tried anymore)</p> <p>Thanks, Alex.</p>
java android
[1, 4]
2,401,337
2,401,338
How do I access the ASP control within span through span ID?
<p>I use custom control which creates a span and 2 asp controls with int.</p> <pre><code>&lt;abc:edf runat="server" ID="testing" ... /&gt; </code></pre> <p>Now my questions is how do I access the asp control within span through span ID in javascript?</p> <p>I can get to it by </p> <pre><code>var test = $get('&lt;%=testing.ClientID %&gt;'); alert(test.all.[hard coded client ID of inner asp control].value) </code></pre> <p>but obviously I don't want to hard code the client ID so is there any better way to handle this?</p>
c# javascript asp.net
[0, 3, 9]
2,200,055
2,200,056
JS Function Wrapping
<p>Consider the following two code examples:</p> <pre><code>// Example 1 $('#myButton').click(function() { alert('I was clicked'); }); // Example 2 $('#myButton').click( alert('I was clicked'); ); </code></pre> <p>Why specifically does example 2 not work?</p>
javascript jquery
[3, 5]
5,964,442
5,964,443
Replace Div with content
<p>I'm new to javascript/jquery and there is something fundamental that I am overlooking. I want to replace the content of a div with some text by calling a function. Absolutely every thing I have tried has failed. </p> <p><a href="http://jsfiddle.net/spuder/dTGBy/" rel="nofollow">http://jsfiddle.net/spuder/dTGBy/</a></p> <p>html </p> <pre><code>&lt;body&gt; &lt;div id=test&gt; &lt;/div&gt; &lt;/body&gt; </code></pre> <p>script</p> <pre><code>$(document).ready( function() { getTest(); } function getTest() { $("#test").html("Hello World"); //$('#test').replaceWith('&lt;h2&gt;New heading&lt;/h2&gt;'); //$("#test").attr("text","http://www.w3schools.com/jquery"); //$("#test").attr("href","http://www.w3schools.com/jquery"); //$("#test").html("New text"); //$(".test").html("New text"); //$("test")html.("New text"); //$("test").update("New text"); //document.getElementById("testSpan").innerHTML = "42"; // $("#test").html("&lt;b&gt;Hello world!&lt;/b&gt;"); } //This is supposed to be super easy ^ //http://www.w3schools.com/jquery/tryit.asp?filename=tryjquery_dom_html_set //http://www.w3schools.com/jquery/tryit.asp?filename=tryjquery_dom_attr_set //http://www.willmaster.com/library/web-development/replace-div-content.php //http://api.jquery.com/replaceWith/ </code></pre>
javascript jquery
[3, 5]
4,183,208
4,183,209
How does jQuery's .delay method work under-the-hood?
<p>I just saw this and think it's cool.</p> <pre><code>console.log("Starting..."); $("#my_element") .fadeIn() .delay(3000) .fadeOut(); console.log("Finishing..."); </code></pre> <p>How does the .delay method work under-the-hood? I mean, how does it figure out how to wait 3 seconds but not interrupt the main control flow?</p>
javascript jquery
[3, 5]
5,570,026
5,570,027
Piece of code to execute AFTER execution of other code
<p>I have a piece of code I want to execute after another piece of code. Now I'm using setTimeout but it's not a good solution.</p> <p>For example, I'm using a text editor which of course needs time for initialization.</p> <pre><code>myTextEditor.initialize(); setHeightToMyTextEditor(); </code></pre> <p>In this example, the height to myTextEditor isn't right. It stays the same, because the text editor still isn't initialized. So, I'm using setTimeout and execute setHeightToMyTextEditor() after 3 seconds. But, if someone has much slower internet I guess it will be a problem.</p> <p>So, how to make setHeightToMyTextEditor() execute after the text editor is initialized?</p>
javascript jquery
[3, 5]
4,241,434
4,241,435
Very Simple Routing on One page website
<p>I'm developing a simple one page website, where the pages scroll horizontally using the scrollTo() javascript library. I have a home / about / contact page. I was wondering if there was a way to still use some form of URL routing like www.example.com/about, to get the about page, and would get updated in the browser when the page was clicked in the navigation.</p>
javascript jquery
[3, 5]
3,674,840
3,674,841
how to change textbox textmode using jquery
<p>i have a login component and within it the password field has a textmode of singlline </p> <p>what i am trying to do is on focus the textmode will change to password</p> <p>i tried this :</p> <pre><code>$(function () { $(".PassTextBox").focus(function (pas) { $(".PassTextBox").attr("TextMode", "Password"); }); }); </code></pre> <p>but it didn't work</p> <p>using asp.net 3.5 , thanks</p>
jquery asp.net
[5, 9]
2,220,610
2,220,611
Can I get jQuery autocomplete to match input without going through dropdown?
<p>I would like to get my autocomplete to return a "hidden" property when I blur out of the textbox or press enter. The data is in format <code>{value: "Pal", pts: "30"}</code>. I want to obtain <code>pts</code>. Here's an example:</p> <p><a href="http://jsfiddle.net/ctuAg/4/" rel="nofollow">http://jsfiddle.net/ctuAg/4/</a></p> <p>Typing a letter or two and choosing a name from the dropdown updates the "points" textbox as expected (10 times the name length). Now, I'd like to know if there's a way of triggering this points update when a name is fully typed and then Enter is pressed, or blurred (tab or mouse click). That is, have the autocomplete search a match to the textbox value and update points.</p> <p>So far as I've seen only clicking on a name in the dropdown causes the points to be updated.</p> <p>I did some searching and the closest function/trigger I found was <code>search</code>. I tried placing this inside blur but .pts returns undefined. This might be the answer, how should I use it in my case?</p> <pre><code> $("#autocomp").autocomplete({ search: function(event, ui) { alert(ui.item.pts); } }); </code></pre>
javascript jquery
[3, 5]
737,634
737,635
How to check current tag element in javascript?
<p>I've a GridView with three rows like this</p> <pre><code>&lt;tr&gt; &lt;th&gt;SlNo&lt;/th&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;1&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;2&lt;/td&gt; &lt;/tr&gt; </code></pre> <p>I've the following code to traverse through the rows</p> <pre><code>var GridViewRow=GridView.getElementsByTagName('tr') </code></pre> <p>Here the row length is 3.</p> <p>I travese through the <code>GridViewRow</code> using for loop .Here how will i get the tag name of the current element ie (<code>th or td</code>).</p> <p>If the tagname is "<code>TH</code>" it should return and if it is "<code>TD</code>" it should take the value of TD.</p>
javascript asp.net
[3, 9]
2,547,428
2,547,429
data appear and disapear when jquery loads
<p>i have this code bellow and i have select options with <code>$menucompare</code> values .</p> <pre><code>&lt;script&gt; function displayVals() { var singleValues = $("#menucompare").val(); $("#hiddenselect").attr("value", singleValues ); $("p").html("Procent of: " + singleValues); } $("select").change(displayVals); displayVals(); &lt;/script&gt; &lt;table width='100%' border='1' cellspacing='0' cellpadding='0'&gt; &lt;th&gt;weeks&lt;/th&gt; &lt;th style="text-align: left; padding-left:5%;"&gt;&lt;?php echo "&lt;p&gt;&lt;/p&gt;"; ?&gt;&lt;/th&gt; </code></pre> <p>which i can get this value (Procent of: $menucompare) . but the problem is when i select one option , the value appears right when jquery is loading , and when jquery is finished loading it disapears this (Procent of: $menucompare) , of course the variable $menucompare commes with the right value. </p> <p>so i want even when jquery finished loading this value stays in the table . hope can get some fix for this .</p>
php jquery
[2, 5]
1,026,480
1,026,481
Show button if input is not empty
<p>I am not much of a JavaScript guru, so I would need help with a simple code. I have a button that clears the value of an input field. </p> <p>I would like it (the button) to be hidden if input field is empty and vice versa (visible if there is text inside the input field).</p> <p>The solution can be pure JavaScript or jQuery, it doesn't matter. The simpler, the better.</p>
javascript jquery
[3, 5]
3,466,738
3,466,739
pop up until jquery finishes processing
<p>I am new to jquery and I need to figure out how to do the following:</p> <p>I have a submit button on my page and when clicked a jquery function is executed. The function will load some information from mysql and echo a table with that information.</p> <p>My problem is that this takes time and meanwhile the user is waiting or even resubmitting.</p> <p>What I would like is to have a popup screen that will be displayed before I start fetching the data from mysql and removed after the data is echoed onto the page.</p> <p>What would I be looking for? what is this called? how can I implement such a think.</p> <p>This is my code:</p> <pre><code>&lt;script type="text/javascript"&gt; $(document).ready(function(){ $('#form-lecturer-login').submit(function(event){ event.preventDefault(); //I need: Display a pop up //This is working : Code to fetch mysql data and echo a table //I need: Remove popup } </code></pre> <p>Here's my full code: pastebin.com/JVCfWbLD </p>
php jquery
[2, 5]
5,635,367
5,635,368
jQuery code placement suggestion
<p>I <em>know</em> this is going to sound like a dumb question, but as I'm learning jQuery by example, I'm finding that the placement of the scripts and functions varies a lot from example to example. Case in point, somewhere I read that the .onReady function should be placed below everything else to insure that the whole DOM is actually ready, and things of that nature.</p> <p>The question is simply this, aside from obvous script tags, is there a Best Practices of where in the PHP file jquery should located? What about one-off inline scripts? Sorry for the naive nature of this, but I'd to be trying these examples in a "right" way as I figure out how to bring it all together.</p> <p>This site seems to have some very insightful folks contributing, so thanks in advance for any guidance! :)</p> <p>Aparently it wasn't as dumb as I thought - thank you everyone for the insights - I feel a little more clarity on what I was trying to understand in the big picture.</p>
php jquery
[2, 5]
3,867,928
3,867,929
JavaScript function pointer problem
<p>just starting out with JavaScript and jQuery, and i have this problem:</p> <pre><code>foo(validation); function foo(func) { var time = new Date().getTime(); // do some other stuff func("foobar" + time); } function validation(elementName) { // do stuff } </code></pre> <p>but when i call function foo with the validation function pointer, i would also like to pass in the string "foobar" at that point.</p>
javascript jquery
[3, 5]
1,899,694
1,899,695
android http post request
<p>I am trying to continuously save sensor data from my Android app into txt file online. At the same time I want my html page read that data. However, I am getting server time-out warning for my server. In fact, I set up a setInterval("RedisplayBall()", 1000) inside my javascript which gets txt data using ajax:</p> <pre><code> var xmlHttp = getXMLHttp(); xmlHttp.onreadystatechange = function() { if(xmlHttp.readyState == 4) { AssignResult(xmlHttp.responseText); } } xmlHttp.open("GET", "TINBCoordinates.txt", true); xmlHttp.send(); </code></pre> <p>In my Android app, I send data as:</p> <pre><code> private class FuncionsActivity extends AsyncTask&lt;ArrayList&lt;NameValuePair&gt;, Integer, Integer &gt; { @Override protected Integer doInBackground(ArrayList&lt;NameValuePair&gt;... data) { // 1) Connect via HTTP. 2) Encode data. 3) Send data. try { HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost("http://mysite/saveData.php"); httppost.setEntity(new UrlEncodedFormEntity(data[0])); HttpResponse response = httpclient.execute(httppost); Log.i("postData", response.getStatusLine().toString()); this.onPostExecute(null); //Could do something better with response. } catch(Exception e) { Log.e("log_tag", "Error1: " + e.toString()); } return 0; } protected void onProgressUpdate(Integer... item){ Log.d("TestP", item[0] + " item has been processed"); } protected void onPostExecute(Integer result){ Log.d("TestP", "AsyncTask returned : " + result); } } </code></pre> <p>I also have a problem with my AsyncTask. After some time app is getting turn off. Any idea how to fix server time-out and AsyncTask problems? Thanks!!!!! </p>
javascript android
[3, 4]
3,232,536
3,232,537
preventDefault() on an <a> tag
<p>I have some html/jquery that slides a div up and down to show/hide it, when a link is clicked:</p> <pre><code>&lt;ul class="product-info"&gt; &lt;li&gt; &lt;a href="#"&gt;YOU CLICK THIS TO SHOW/HIDE&lt;/a&gt; &lt;div class="toggle"&gt; &lt;p&gt;CONTENT TO SHOW/HIDE&lt;/p&gt; &lt;/div&gt; &lt;/li&gt; &lt;/ul&gt; </code></pre> <p>and my jquery...</p> <pre><code>$('div.toggle').hide(); $('ul.product-info li a').click(function(event){ $(this).next('div').slideToggle(200); } ); </code></pre> <p>My question is: How do I use preventDefault() to stop the link acting as a link and adding # to the end of my URL &amp; jumping to the top of the page? I can't figure out the right syntax, I just keep getting an error saying that preventDefault() is not a function.</p>
javascript jquery
[3, 5]
14,023
14,024
How to get jQuery added values in aspx page at server side on Submit button click?
<p>When user clicks 'add new' button I want to add more textbox into the page, so that he can add n number of values. I will do this with jQuery. But on submit click I want to get values from all the fields at server side. How can I accomplish this? </p>
javascript jquery asp.net
[3, 5, 9]
3,388,745
3,388,746
how to bind function on dynamically created node
<p>I'm writing a placeholder enabling function</p> <pre><code>var t=document.createElement("input"); "placeholder" in t||$("input").each(function(){ if("submit"!==$(this).attr("type")){ var n=$(this),l=n.attr("placeholder"); n.css("color","#ccc").val(l); n.focus(function(){("#ccc"==n.css("color")||"rgb(204, 204, 204)"==n.css("color"))&amp;&amp;n.val("").css("color","#000")}); n.blur(function(){""==n.val()&amp;&amp;n.css("color","#ccc").val(l)})} }) </code></pre> <p>I can call this function on dom ready, but how to use this function on newly created <code>input</code>?</p>
javascript jquery
[3, 5]
5,719,607
5,719,608
linkbutton will not fire
<p>This is continued from <a href="http://stackoverflow.com/questions/11849539/link-button-in-repeater-to-pass-session-variable">link button in repeater to pass session variable</a> but nothing happens when I try to click the link button I added to my repeater. Here is what I have</p> <pre><code>&lt;asp:Repeater ID="rptList" runat="server" EnableViewState="false" OnItemCommand="rptList_ItemCommand" DataSourceID="SqlDataSource3"&gt; &lt;ItemTemplate&gt; &lt;div&gt; &lt;p&gt; &lt;b&gt;Title: &lt;/b&gt; &lt;asp:LinkButton ID="lbnCookieVar" CommandName="click" CommandArgument='&lt;%# Eval("Job_Title")%&gt;' Text='&lt;%# Eval("Job_Title")%&gt;' runat="server" /&gt; &lt;br /&gt; &lt;b&gt;Status: &lt;/b&gt;&lt;%# Eval("Status")%&gt;&lt;br /&gt; &lt;b&gt;Department: &lt;/b&gt;&lt;%# Eval("Department")%&gt;&lt;br /&gt; &lt;b&gt;Date Position Available: &lt;/b&gt;&lt;%# Eval("Date_Position_Available")%&gt;&lt;br /&gt; &lt;/p&gt; &lt;/div&gt; &lt;/ItemTemplate&gt; &lt;/asp:Repeater&gt; </code></pre> <p>Code Behind:</p> <pre><code>protected void rptList_ItemCommand(object sender, CommandEventArgs e) { if (e.CommandName == "click") { Session["Data"] = e.CommandArgument.ToString(); Response.Redirect("default.aspx"); } } </code></pre> <p>I apologize for the new post but for whatever reason I was not allowed post on the last one kept saying "User not alllowed to comment to this post"</p>
c# asp.net
[0, 9]
4,989,311
4,989,312
Add smoothness between changing images with jQuery
<p>I have this code that changes the image when a user rolls over a map area on my United States map. It is working perfectly. But I want the the images to have a smooth appearance and then a gradual fade away. What do I need to add to this code? Thanks! </p> <pre><code>$(document).ready(function() { //set off state var nav_off = "/images/state-map.png"; // functions for over and off function over(image) { $("#main-nav").attr("src", image); } function off() { $("#main-nav").attr("src", nav_off); } $("#imagemap area").hover( function () { var button = $(this).attr("id"); over("/images/state-" + button + ".png"); }, function () { off(); }); }); </code></pre>
javascript jquery
[3, 5]
4,187,527
4,187,528
How do I add an option to a select box in a parent window using jquery?
<p>In my child window I have </p> <pre><code>$('#opfile').addOption("someval",sometext"); </code></pre> <p>Problem is #opfile is an a parent window I cant get it to communicate</p> <p>I tried</p> <p>window.opener.$('#opfile').addOption("someval",sometext");</p> <p>but no luck any ideas?</p> <p>Update</p> <p>Embarssing but I got the above to work might have been caching something</p> <p>Thanks for the suggestions</p>
javascript jquery
[3, 5]
1,785,471
1,785,472
How to call a sever side contol on Jquery Model pop up click
<p>I want to call a server side grid control on jquery model pop up's OK button click. Could some body tell me on it, i have been toiling for long.</p> <p>as i have following model pop up code</p> <pre><code>&lt;script type='text/javascript'&gt; $(function dressing() { var v; $("#dialog-modal").dialog({ resizable: true, autoOpen: false, autosize:true, show: "blind", hide: "explode", width: 500, modal: false, buttons: { "OK": function () { CheckItem(); $(this).dialog("close"); // __doPostBack('_ctl00$ContentPlaceHolder1$grdOrder$_ctl02$btnSpIns', '') //__doPostBack('ctl00$ContentPlaceHolder1$grdOrder$ctl02$btnDress', '') }, Cancel: function () { $(this).dialog("close"); } } }); $('[id$=btnDress]').click(function () { $("#dialog-modal").dialog("open"); return false; }); }); &lt;/script&gt; </code></pre> <p>and on it ok botton click i want to call grid views row data bound event..</p>
jquery asp.net
[5, 9]
4,167,736
4,167,737
Not choosing existing selection when randomising
<p>I have created a speech bubble that displays quotes that I store in lists. When I click the bubble it picks another quote from the list at random, but sometimes chooses the one it is already displaying. How would I prevent it from doing this?</p> <pre><code>&lt;ul class="joke-list"&gt; &lt;li id="quotes"&gt; &lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span style="font-size: medium;"&gt;Charles Darwin wanted to be a doctor but did not like the sight of blood.&lt;/span&gt;&lt;/span&gt;&lt;/li&gt; &lt;li id="quotes"&gt; &lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span style="font-size: medium;"&gt;Charles Darwin was a member of the Gourmet Club. He ate lots of animals including armadillos, owls and tigers.&lt;/span&gt;&lt;/span&gt;&lt;/li&gt; &lt;li id="quotes"&gt; &lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span style="font-size: medium;"&gt;For his 25th Birthday, Charles Darwin had a mountain named after him in Zimbabwe. &lt;/span&gt;&lt;/span&gt;&lt;/li&gt; &lt;/ul&gt; </code></pre> <p>fiddle: <a href="http://jsfiddle.net/FsjkM/236/" rel="nofollow">http://jsfiddle.net/FsjkM/236/</a></p>
javascript jquery
[3, 5]
1,243,135
1,243,136
Best practice to organize image picking and store it into private folder
<p>I'm developing some android application what's need a image picking functionality (from camera and from galery)</p> <p>After some research I know how to start intents for it, and how to store it in directory. But I don't know how can I easily show pictures to user.</p> <p>My opinion is to save camera images as far as I can into directory, and save galery images URI's in runtime. Then show every image as ImageView in HorizontalScrollView. So, if user clicks Done, I copy galery images to my app private folder with some extension like *.bin to prevent galery to cache my images.</p> <p>Is it good practice or not? Maybe there is already component to implement my functionality?</p>
java android
[1, 4]
4,602,602
4,602,603
Auto fill text boxes based on drop down selected
<p>I am working on .asp webpage. I used javascript as the script language. I have a drop down with values populated from agencies table in database. In that agencies table , there are many other columns like contact information, phone number ,E-mail etc. If user selects an agency from drop down , the text boxes below the drop down contains contact information. I want the text boxes to be auto filled from database when user selects an agency name from the drop down. I tried searching in Google but I could not find proper resources. </p> <p>Note- Drop down database and Contact information are from same table.</p>
javascript asp.net
[3, 9]
4,474,580
4,474,581
Updating TextView
<p>I can't seem to get things to display programatically using text views? I have a main.xml:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" &gt; &lt;TextView android:id="@+id/username" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Name" /&gt; &lt;Button android:id="@+id/button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Hello, I am a Button" /&gt; &lt;/LinearLayout&gt; </code></pre> <p>Then in my code, I use:</p> <pre><code>//Update the GUI setContentView(R.layout.main); TextView guiStr; guiStr = (TextView)findViewById(R.id.username); guiStr.setText(username); </code></pre> <p>But the username does not display on the screen. I get just the default text in the XML. What am I doing wrong?</p>
java android
[1, 4]
1,481,801
1,481,802
Android: Can we store the user input in a variable, Permanently?
<p>For example, I have an EditText and user inserts some text in it. We can store the input in the variable until the app is running. But can we store it permanently, so that after the user restarts the app, the variable will still hold the previously entered text.</p>
java android
[1, 4]
2,325,213
2,325,214
Want to stop countdown and give out put as time up
<p>Hello i want when my countdown end it should give out as:</p> <pre><code>document.getElementById("remain").innerHTML = "Time up"; </code></pre> <p>Live countdown here : <a href="http://ffsng.deewayz.in/counter/" rel="nofollow">http://ffsng.deewayz.in/counter/</a></p> <p>As its about to end i want to give out put that "Time up"</p> <p>i tried some thing this way but dint work out.</p> <pre><code>function setCountDown() { seconds--; if (seconds &lt; 0) { minutes--; seconds = 59; } if (minutes &lt; 0) { hours--; minutes = 59; } if (hours &lt; 0) { days--; hours = 23; } document.getElementById("remain").innerHTML = days + " days, " + hours + " hours, " + minutes + " minutes, " + seconds + " seconds"; if ((seconds = 0) &amp;&amp; (minutes = 0) &amp;&amp; (hours = 0) &amp;&amp; (days = 0))( document.getElementById("remain").innerHTML = "time up"; ) else ( setTimeout("setCountDown()", 1000); ); } </code></pre> <p>My full codes is here : <a href="http://stackoverflow.com/questions/12594438/countdown-timer-not-working-with-gmt-time">Countdown timer not working with gmt time</a></p>
php javascript
[2, 3]
4,649,215
4,649,216
Javascript: How to remove an array item(JSON object) based on the item property value?
<p>like this: </p> <pre><code>var arr = [ { name: "robin", age: 19 }, { name: "tom", age: 29 }, { name: "test", age: 39 } ]; </code></pre> <p>I want to remove array item like this(an array prototype method):</p> <pre><code>arr.remove("name", "test"); // remove by name arr.remove("age", "29"); // remove by age </code></pre> <p>currently, I do it by this method(use jQuery):</p> <pre><code>Array.prototype.remove = function(name, value) { array = this; var rest = $.grep(this, function(item){ return (item[name] != value); }); array.length = rest.length; $.each(rest, function(n, obj) { array[n] = obj; }); }; </code></pre> <p>but I think the solution has some performance issue,so any good idea? </p>
javascript jquery
[3, 5]
3,450,911
3,450,912
Uploading a file using android without using MultiPartEntity
<p>Hi i have to upload a file without using MultiPartEntity in android because it set the content format to multi-part /form data.this format is not supported in my api call.can any one help how to upload a file using httppost method.i wrote the code for HttpPost method but its showing the error that api dont support multi-part/ form data in the api call.</p>
java android
[1, 4]
4,219,786
4,219,787
The remote server returned an error: 227 Entering Passive Mode (89,202,213,212,6,32)
<p>Briefly,<br> I'm trying to read 5000 xml files from ftp but it throws The remote server returned an error: 227 Entering Passive Mode (89,202,213,212,6,32) on reading 1500th xml file. what shall i do somebody help me. </p> <pre><code>string[] files; files = GetFileList(); foreach (string file in files) { xmlDoc.Load("ftp.Test.com/stats/" + file); XmlNodeList itemNodes = xmlDoc.SelectNodes("//Sport"); } </code></pre> <p>on reading 1600th xml file i get the Exception like <strong>The remote server returned an error: 227 Entering Passive Mode (89,202,213,212,6,32)</strong> </p>
c# asp.net
[0, 9]
5,672,378
5,672,379
Javascript not working as expected, why?
<p>I have javascript to set equal column heights of two divs contained by a parent div. Somebody even coded an working example that works (mine doesn't). What I have found is that it IS setting the height of the container which contains the two divs I intended to set. Why is my script setting the container height rather than it's children? Please see my previous question at: </p> <p><a href="http://stackoverflow.com/questions/1458233/dont-understand-jquery-setting-equal-height-contained-divs">http://stackoverflow.com/questions/1458233/dont-understand-jquery-setting-equal-height-contained-divs</a></p> <p>What does the following line actually do? I don't understand the "> div" part.</p> <p>setEqualHeight($(".instructionsParent > div"));</p>
asp.net javascript jquery
[9, 3, 5]
2,712,858
2,712,859
How do I set the body of a HttpPut on Android? (without adding libraries)
<p>I want to upload some data from an Android application to Pachube.</p> <p><a href="http://hurl.it/?url=http://api.pachube.com/v2/feeds/YOUR_FEED_ID.json&amp;header-keys%5B%5D=X-PachubeApiKey&amp;header-vals%5B%5D=YOUR_API_KEY_HERE&amp;method=PUT&amp;post-body=%7B%22title%22%3a%22Your%20Changed%20Title%22,%22version%22%3a%221.0.0%22,%22datastreams%22%3a%5B%7B%22id%22%3a%22stream0%22,%22current_value%22:12.3%7D,%7B%22id%22%3a%22stream1%22,%22current_value%22:24.2%7D%5D%7D" rel="nofollow">This hurl</a> is provided by their <a href="https://pachube.com/docs/v2/feed/update.html" rel="nofollow">documentation</a> as an example.</p> <p>How can I achieve this with Android's implementation of HttpPut (or HttpPost)?</p> <p>I don't really want to have to add any extra libraries, as I want to keep the application as small as possible.</p> <p>I already have a JSONObject with my data in it.</p>
java android
[1, 4]
1,785,900
1,785,901
Create javascript property like C# property
<p>Is it possible to create a property on a javascript object that behaves similar to a property in C#.</p> <p>Example: I've created an auto-sizing textarea widget using dojo. In order to get the "value" property out of my widget, I've hooked up to the onchange event and I'm setting a variable everytime the value of the textarea changes.</p> <p>Is there a way to accomplish this without hooking up to the onchange event.</p> <p><b>Edit</b></p> <p>In other words, is it possible to write something in JavaScript that behaves like getters and/or setters.</p>
c# javascript
[0, 3]
5,354,658
5,354,659
Regex ReplaceAll Doesn't Work
<p>I copied this code from another StackOverflow post. However, I am having some issues with it. The items matching the pattern specified should be replaced but they are not.</p> <p>The code is:</p> <pre><code>protected String FixHexValuesInString(String str){ Log.v(TAG, "before fix: "+ str); Matcher matcher = Pattern.compile("\\\\x([0-9a-f]{2})").matcher(str); while (matcher.find()) { int codepoint = Integer.valueOf(matcher.group(1), 16); Log.v(TAG, "matcher group 0: " + matcher.group(0)); Log.v(TAG, "matcher group 1: " + matcher.group(1)); str = str.replaceAll(matcher.group(0), String.valueOf((char) codepoint)); } Log.v(TAG, " after fix: "+ str); return str; } </code></pre> <p>Here an example that I wrote to LogCat:</p> <pre><code>before fix: 'id': 1268, 'name': 'Reserva de Usos M\xfaltiples de la Cuenca del Lago de Atitl\xe1n-RUMCLA (Atitl\xe1n Watershed Multiple Use Reserve)' matcher group 0: \xfa matcher group 1: fa matcher group 0: \xe1 matcher group 1: e1 matcher group 0: \xe1 matcher group 1: e1 after fix: 'id': 1268, 'name': 'Reserva de Usos M\xfaltiples de la Cuenca del Lago de Atitl\xe1n-RUMCLA (Atitl\xe1n Watershed Multiple Use Reserve)' </code></pre> <p>Anybody see why this doesn't work?</p>
java android
[1, 4]
760,576
760,577
How can I control the usage of a custom jar library?
<p>I need a way to essentially secure my jar library to allow registered apps to use it in their projects and deny usage to apps that weren't approved by me.</p> <p>It is fine if I hard code things in the lib for each distribution. I currently have this jar obfuscated.</p> <p>What are good approaches to restrict the usage of a jar?</p> <p>One idea was to lock the lib to a specific package so if the developer tries to use it in another project they can't. But I'm not sure if they can easily provide a custom fake Context to make it work...</p>
java android
[1, 4]
203,559
203,560
textboxes on dropsown select
<p>I am beginner with jQuery. I want to use drop down in my page. Depending upon the selection of drop down value, no of text boxes should appear in page. Suppose I selected 8 than 8 text boxes appear and if then I select 4 than rest four should be removed. Please give me idea how to do it using jQuery.</p>
javascript jquery
[3, 5]
2,400,033
2,400,034
jQuery AJAX tabs + PHP
<p>seems like I'm stuck with jQuery tabs. I'm trying to pass selected tab name to some php script but is seems like it doesn't get any data. </p> <p>This is how tabs normally work without any response from server side: <a href="http://pastebin.com/KBxj7p5k" rel="nofollow">http://pastebin.com/KBxj7p5k</a></p> <p>And this is how I try to pass the the current tab name to the server:</p> <pre><code>$(document).ready(function() { $('ul.tabs li').css('cursor', 'pointer'); $('ul.tabs.tabs1 li').click(function(){ var thisClass = this.className.slice(0,2); $('div.t1').hide(); $('div.t2').hide(); $('div.t3').hide(); $('div.t4').hide(); $('div.' + thisClass).show('fast'); $('ul.tabs.tabs1 li').removeClass('tab-current'); $(this).addClass('tab-current'); var name = thisClass; var data = 'name='+name; $.ajax ({ type:"GET", url:"handler.php", data:data, success:function(html) { thisClass.html(html); } }); }); </code></pre> <p>Thanks.</p>
php jquery
[2, 5]
1,746,498
1,746,499
how to create the div on the fly in javascript / jquery in this way
<p>i have asp.net mvc 2 application where i have a scenario as follows: I want to create the parent div and in side it want to create n-number of divs with controls.like</p> <pre><code> for(j=0;j&lt;parentCount;j++) { //Create the parent div for(i=0;i&lt;childDivCount;i++) { //create child div, with controls (like radio,checkboxes).and attach to parentDiv } //Attach parent div to document. } </code></pre> <p>how to achieve this . </p> <p><strong>Edited:</strong> i am bit get satisfaction with answers. but when i am using getJson in each loop as:</p> <pre><code> //$.getJSON(url1,,function(data1){ //for each item in data1 :- for(j=0;j&lt;parentCount;j++) { //Create the parent div //$.getJSON(url2,,function(data2){ //**** here j automatically get j++ , why ? ****// //For each item in data2 :- for(i=0;i&lt;childDivCount;i++) { //create child div, with controls (like radio,checkboxes).and attach to parentDiv } }); //Attach parent div to document. } }); </code></pre> <p>when entering for getJson of data2 (subloop) var j get automatically incremented. why that should be ? </p> <p><strong>Edited:-</strong> in fact i want to create the question-answer scenario. since in first getJson call i am getting all questions and then in sub getJson call i am getting answers of each question. for each question i am creating div as parent div , and for its answers appending parent div with answers child div. thats all. i didn't wanted to use user control here , so i used the json-jquery combination to generate scenario. this is what i want to achieve.</p>
javascript jquery
[3, 5]
117,036
117,037
How to make a form to submit itself
<p>I have a form with a <code>&lt;select&gt;</code> on the page. when the user selects an option, I want the form to submit itself. How can I do this? Thanks</p>
php javascript jquery
[2, 3, 5]
1,900,591
1,900,592
Travel though all <img /> and replace .png with .svg
<p>How can I, in javascript or jquery, travel through each of the <code>&lt;img /&gt;</code> tag in a page, check if it is a .png extension, replace the .png extension, if it is a .png extension, with .svg?</p>
javascript jquery
[3, 5]
1,842,178
1,842,179
How to tell what is passed when no value exists
<p>For this code, how do you know that null is returned if there is no value in the querystring?</p> <pre><code>HttpContext context = HttpContext.Current; string strValue = context.Request[name]; </code></pre> <p>I'm asking because I never know what's being returned in many cases in the .NET framework when you don't get the value expected when it does not exist.</p> <p>so if <code>context.Request[name];</code> is called and the name doesn't exist in the querystring, how do you know it returns null or an empty string so that I can properly handle the case where it does not exist?</p>
c# asp.net
[0, 9]
519,184
519,185
Writing a string to textfile in Android
<p>How Can I write a String to a text file,I should be able to specify the location of the file(or some how open and see its content,It is not necessary that it should be located in Computers memory), please provide me with the code snippet. Thank you in advance for all the responses.</p>
java android
[1, 4]
4,120,543
4,120,544
Jquery to call next step after returning false?
<p>I am writing validation on a custom dropdown DD1 and DD2, but when it checks for DD1, and return false, it doesn't check for DD2. Can you please suggest me?</p> <p>In the below script, i am calling Validatechecked function where it checks whether the dropdown has selected values, it works for only one dropdown. How to make it work for more than 2 dropdowns??</p> <pre><code>&lt;script type="text/javascript" language="javascript"&gt; function Validatechecked(val) { var selectedItems = ""; $('[id*='+val+']'+" "+ "input:checked").each(function () { if (selectedItems == "") { selectedItems = "Selected Items:\r\n\r\n"; } selectedItems += $(this).next().html() + "\r\n"; }); if (selectedItems == "") { selectedItems = ""; return false; } else { selectedItems = ""; return true; } } $(document).ready(function () { $('[id*="InsertNSTBtn"]').click(function () { if (!Validatechecked("DD1")) { $('#&lt;%=valid1.ClientID%&gt;').html("*"); return false; } if (!Validatechecked("DD2")) { $('#&lt;%=Valid1.ClientID%&gt;').html("*"); return false; } }); }); </code></pre>
jquery asp.net
[5, 9]
2,067,008
2,067,009
How to store the variable returned from a closure function?
<p>Noticed the code of the <code>submitHandler</code> was being used in several places, and tried to refactor it out.</p> <pre><code>var validator = $("#form_id").validate({ errorClass: "ui-state-error", submitHandler: function(form) { jQuery(form).ajaxSubmit({ dataType: 'json', success: function(entity) { //dostuff }, error: function(errors) { validator.showErrors(errors); } }); } }); </code></pre> <p>I took the code above and extracted the submithandler to a function like so;</p> <pre><code>$("#generated_form_id").validate({ errorClass: "ui-state-error", submitHandler: bindSubmitHandler(formId) } }); function bindSubmitHandler(formId){ return function(form) { jQuery(form).ajaxSubmit({ dataType: 'json', success: function(object) { //do stuff }); }, error: function(errors) { validator.showErrors(errors); //throws an exception } }); } } </code></pre> <p>This code throws an exception because the validator object is undefined. </p> <p><em>My own reasoning</em> which may be false has been as follows: I can't store the variable, because the forms are being created dynamically. One page could create ten of these forms using the same <code>bindSubmitHandler</code> function. I thought about the solution of getting the validator via the form, but couldn't find any such method in the validator API. If there is such a method, I could write something like <code>$('#formid').getValidator().showErrors(errors);</code> </p> <p><strong>Does anyone have an idea for a solution to this problem?</strong></p>
javascript jquery
[3, 5]
249,006
249,007
moving the content of a div to another div with jquery
<p><a href="http://www.frostjedi.com/terra/scripts/demo/jquery02.html" rel="nofollow">http://www.frostjedi.com/terra/scripts/demo/jquery02.html</a></p> <p>According to <a href="http://www.elated.com/articles/jquery-removing-replacing-moving-elements/" rel="nofollow">this link</a> elements can be moved around by doing $('#container1').append($('#container2')). Unfortunately, it doesn't seem to be working for me. Any ideas?</p>
javascript jquery
[3, 5]
1,889,499
1,889,500
Get Mouse click position and Set that position as cursor Position in asp.net texbox with ajaxToolkit:MaskedEditExtender
<pre><code>&lt;asp:TextBox ID="txtZip" runat="server" class="inputbtn" MaxLength="5" TabIndex="10" Width="80px" OnBlur="return SetZip()"&gt;&lt;/asp:TextBox&gt; &lt;ajaxToolkit:MaskedEditExtender ID="meeZip" runat="server" AutoComplete="false" InputDirection="LeftToRight" Mask="99999" MaskType="Number" MessageValidatorTip="true" OnFocusCssClass="MaskedEditFocus" OnInvalidCssClass="MaskedEditError" TargetControlID="txtZip"&gt; &lt;/ajaxToolkit:MaskedEditExtender&gt; </code></pre> <p>My Problem is suppose i have entered Zip Code as 12345 in textbox then perform some other operation. Then i want to edit ZipCode from 12345 to 12335 so i have clicked between 3 and 4. But whenever i click by default cursor take position at left side. so i have to click again if i want to go between 3 and 4. So can any one help me to get mouse positon onfocus of that textbox and set that position as cursor position </p>
c# javascript asp.net
[0, 3, 9]
3,421,162
3,421,163
Open a File Share link from Window.open javascript
<p>I am trying to open a file share link from the window.open ....... but its adding the <a href="http://localhost/vdir/" rel="nofollow">http://localhost/vdir/</a> before the path can any one say what is the problem?</p>
javascript asp.net
[3, 9]
1,268,620
1,268,621
How to split the content of a DIV tag to multiple DIVs?
<p>I have a <code>DIV</code>tag with specific Width and height attributes.</p> <pre><code>&lt;div style="width:793px;height:1096px"&gt; A long text and pictures&lt;/div&gt; </code></pre> <p>I want to separate the <code>DIV tag</code> to multiple <code>DIV tags</code> when the lines and pictures are exceeded the first <code>DIV</code> and want to show the remaining text and pictures in next <code>DIV</code> instead of having overflow and scrolling.</p> <p>how to do it?</p>
javascript jquery asp.net
[3, 5, 9]
6,022,860
6,022,861
Make Parent Attribute
<p>can someone help me with jquery. i have a html TAG like this</p> <p><code>&lt;p class="celak"&gt;hohohohoho&lt;/p&gt;</code></p> <p>and i want to make the output (give its parent) be like this</p> <p><code>&lt;div class="celak-parent"&gt;&lt;p class="celak"&gt;hohohohoho&lt;/p&gt;&lt;/div&gt;</code></p> <p>is there somebody know which jquery method can do that?</p> <p><code>$('.class').???</code></p> <p>sorry if my write not very good. this first time i asking here.</p>
javascript jquery
[3, 5]
5,902,740
5,902,741
How can we make the backward button disable in the all browsers?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/961188/disable-browsers-back-button">Disable browser&#39;s back button</a> </p> </blockquote> <p>Hi everyone,I have a portal site and i want to make the backward button to disable state after the user gets logout.Is it possible by C# programming?Or we need to go for client side scripts like Javascript or jquery?Please help me regarding this .</p>
c# asp.net
[0, 9]
3,965,768
3,965,769
clone values of select fields into span or any other html elements
<p><img src="http://i.stack.imgur.com/aH5Pp.png" alt="enter image description here"></p> <p>this is the fields I have in the app, I need to clone this values into some span elements or any other html elements, so it will be a clone of the date that I select from selectors:</p> <pre><code>&lt;select id="massmedium_register_date_1i" name="massmedium[register_date(1i)]"&gt;&lt;/select&gt; &lt;select id="massmedium_register_date_2i" name="massmedium[register_date(2i)]"&gt;&lt;/select&gt; &lt;select id="massmedium_register_date_3i" name="massmedium[register_date(3i)]"&gt;&lt;/select&gt; </code></pre> <p>ex:</p> <p>I select: <code>15 - 06 - 1982</code> </p> <p>clone to: </p> <pre><code>&lt;span class="date"&gt;15&lt;/span&gt;&lt;span class="date"&gt;06&lt;/span&gt;&lt;span class="date"&gt;1982&lt;/span&gt; </code></pre> <p>any help is welcome. Thank you.</p>
javascript jquery
[3, 5]
5,865,158
5,865,159
Can I write an Android app in Java and convert it later?
<p>I've got a lot of experience in Java but none developing mobile apps. I'd like to write an application using Java/Swing and then convert it for use on an Android phone.</p> <p>Is this feasible or do I really need to develop from the ground up for the Android platform?</p> <p>I don't own an Android phone as I can't afford one at the moment, and the Android emulator is so slow that I find myself wasting a lot of time sitting around waiting.</p>
java android
[1, 4]
2,991,008
2,991,009
How can i create a online catch tool which can capture part of a web page?
<p>I saw this demo: <a href="http://www.gbin1.com/technology/democenter/20120720jsoupjquerysnatchpage/index.html" rel="nofollow">Capture demo</a>, it looks it use jsoup to capture the web element. Do we have any other choice for capture the web page content better? FOR example, capture the part of web page, and also include js, so it can function correctly just like original page. any ideas? thanks!</p>
java javascript jquery
[1, 3, 5]
768,965
768,966
get a forms values via jquery, post to a php script, and have php script process for errors and return value
<p>I have this form:</p> <pre><code>&lt;form action= 'addperm.php' class = 'addperm' method='post'&gt; &lt;input type='text' name='user' /&gt;&lt;br /&gt; &lt;input type='radio' name='perm' value='1' CHECKED /&gt; Can view only&lt;br /&gt; &lt;input type='radio' name='perm' value='2' /&gt; Can make changes &lt;br /&gt; &lt;input type='submit' value='Add'&gt; &lt;/form&gt; </code></pre> <p>I want to know how, without redirecting to another page, I can get these two input values (user and perm), post them to a php script via ajax, and then have the php return the results</p>
php jquery
[2, 5]
3,945,901
3,945,902
execute string as javascript function
<p>My object has a call back:</p> <pre><code>var MyObject = { CallBack: "function (whichSubMenuIsClicked, subMenuObjectTag) { self.doStuff(whichSubMenuIsClicked.SubMenuItem, whichSubMenuIsClicked.HeaderColumnName, whichSubMenuIsClicked.DivIdentifier);}", } </code></pre> <p>The callback is a string. Now I need to execute it using MyObject.CallBack(param1, param2) How can this be done using jquery or javascript. The self in this case is the original widget calling another widget. Thus the call back is on the original widget.</p>
javascript jquery
[3, 5]
4,925,972
4,925,973
color an image using jquery or javascript
<p>I want to color the various parts of an image like this demo <code>http://www.nickjr.com/kids-games/color-with-dora.html</code>. This demo uses flash. Is there any possibility do this in javascript or jquery?</p> <p>Please give any reference.</p>
javascript jquery
[3, 5]
3,220,438
3,220,439
big Ajax problem .. can't figure it out
<p>Hy, </p> <p>I have a live username validation using ajax :</p> <pre><code>&lt;td id="user_process_live"&gt;&lt;input type="text" id="user_live_ver" name="user" /&gt;&lt;/td&gt; </code></pre> <p>abnd the following java :</p> <pre><code> $("input#user_live_ver").blur(function() { var username=$(this).val(); var dataString = 'username=' + username; $.ajax({ type: "POST", url: "ajax/login_ajax.php", data: dataString, cache: false, success: function(html) { $("td#user_process_live").html(html); } }); }); </code></pre> <p>The <code>login_ajax.php</code> returns the same <code>&lt;input type=text id=user_live_ver name=user /&gt;</code> but with different styles applied (background-color and border-color) : red if username already exist and green if user does not exist ...</p> <p>The problem is the script does this just one time .. just one <code>.blur()</code> ... </p> <p>If i remove the <code>.ajax({ ... etc });</code> and insert <code>alert(dataString);</code> every time i click out that input the <code>alert()</code> is triggered but not the same for the <code>.ajax()</code> ...</p> <p>What seems to be the problem ? Thanks a lot</p>
php jquery
[2, 5]
421,563
421,564
Javascript function in PHP fromCharCode()
<pre><code>var test = String.fromCharCode(112, 108, 97, 105, 110); document.write(test); // Output: plain </code></pre> <p>Is there any PHP Code to work as <code>String.fromCharCode()</code> of javascript?</p>
php javascript
[2, 3]
3,920,921
3,920,922
Select appended item jquery
<p>How would i select the below item, i <strong>do not</strong> want to select every LI of <code>.top</code> but just the LI i have just created on the append.</p> <p>How is this possible?</p> <pre><code>$('.top').append('&lt;li&gt;&lt;span&gt;' + html + '&lt;/span&gt;&lt;/li&gt;'); </code></pre>
javascript jquery
[3, 5]
1,248,925
1,248,926
how to paint on an image and save the image to phone gallery in android
<p>** my intent is to save the painted image along with my background view to gallery** //</p> <pre><code>public boolean onTouch(View view, MotionEvent event) { // draw the new Points to our internal canvas / bitmap System.out.println("onTouch(View vc) { IS CALLING11111111111"); if (event.getAction() == MotionEvent.ACTION_DOWN) { paint.setColor(Color.RED); path = new Path(); path.moveTo(event.getX(), event.getY()); } else if (event.getAction() == MotionEvent.ACTION_MOVE) { int historySize = event.getHistorySize(); for (int i = 0; i &lt; historySize; i++) { path.lineTo(event.getHistoricalX(i), event.getHistoricalY(i)); } path.lineTo(event.getX(), event.getY()); canvas.drawPath(path, paint); } else { return super.onTouchEvent(event); } invalidate(); return true; } </code></pre>
java android
[1, 4]
5,336,890
5,336,891
JQuery/JavaScript - Creating a table from list of words
<p>At the moment this creates the table for the list of words, but only in one column. How do I get it to print into a 4x5 table? </p> <pre><code>var listOfWords = ["mat","cat","dog", "pit", "pot", "fog", "log", "pan", "can", "man"]; var innerTable = ''; for (var i = 0, len = listOfWords.length; i &lt; len; i++) { innerTable += '&lt;tr&gt;&lt;td&gt;'+listOfWords[i]+'&lt;/td&gt;&lt;/tr&gt;'; } $('&lt;table&gt;'+innerTable+'&lt;/table&gt;').appendTo('body'); </code></pre>
javascript jquery
[3, 5]
3,510,001
3,510,002
Is it good practice to include other dom elements actions into another dom elements action like common actions for both in javascript
<p>Is it good practice code below?(jquery)</p> <p>common.js (dom elements of two files written in same js action)</p> <pre><code>$('.list_item').click(function () { $('#yes_button').addClass('selected'); $('#no_button').addClass('selected_no'); }); </code></pre> <p>yes_button.html</p> <pre><code>&lt;div class='list_item yes_class' &gt; Muhammad s.a.w &lt;/div&gt; &lt;div id='yes_button' &gt; Yes &lt;/div&gt; </code></pre> <p>no_button.html</p> <pre><code>&lt;div class='list_item no_class'&gt; Muhammad s.a.w &lt;/div&gt; &lt;div id='no_button' &gt; No &lt;/div&gt; </code></pre> <p>is the above practice good or should we write like below</p> <pre><code>$('.yes_class').click(function () { $('#yes_button').addClass('selected'); }); $('.no_class').click(function () { $('#no_button').addClass('selected_no'); }); </code></pre> <p>I have two files with same class for DOM elements, I'm writing JS code based on unique class name, my question is it the good practice to follow such way.</p>
javascript jquery
[3, 5]
4,245,207
4,245,208
JavaScript: Whats the difference between 'Document' and 'HTML'
<p>Example:</p> <pre><code>$(document).click(function() { blah }); // and $('html').click(function() { blah }); </code></pre>
javascript jquery
[3, 5]
1,384,572
1,384,573
jquery shortcut for multiple clicks
<p>well i am still new to js/programming. can anyhow guide me on how can i optimize my code? i am sure that there are multiple ways to write a small and fast code that does the same thing.</p> <pre><code>$('.ourservices-content .left ul li:nth-child(1)').click(function(){ $('.our-services-content-box &gt; ul.box').stop().animate({ marginLeft: '0px' },800) }) $('.ourservices-content .left ul li:nth-child(2)').click(function(){ $('.our-services-content-box &gt; ul.box').stop().animate({ marginLeft: '-600px' },800) }) $('.ourservices-content .left ul li:nth-child(3)').click(function(){ $('.our-services-content-box &gt; ul.box').stop().animate({ marginLeft: '-1200px' },800) }) $('.ourservices-content .left ul li:nth-child(4)').click(function(){ $('.our-services-content-box &gt; ul.box').stop().animate({ marginLeft: '-1800px' },800) }) $('.ourservices-content .left ul li:nth-child(5)').click(function(){ $('.our-services-content-box &gt; ul.box').stop().animate({ marginLeft: '-2400px' },800) }) $('.ourservices-content .left ul li:nth-child(6)').click(function(){ $('.our-services-content-box &gt; ul.box').stop().animate({ marginLeft: '-3000px' },800) }) $('.ourservices-content .left ul li:nth-child(7)').click(function(){ $('.our-services-content-box &gt; ul.box').stop().animate({ marginLeft: '-3600px' },800) }) </code></pre>
javascript jquery
[3, 5]
1,710,445
1,710,446
How to bind Complex Entity type to Gridview using ObjectDataSource
<p>I have an entity</p> <pre><code>class Person { public int Age{get;set;} public string Name{get;set;} public Department Dept{get;set;} } class Department { public int DeptId{get;set;} public string DeptName{get;set} } </code></pre> <p>Now I binds Collection to GridView using ObjectDataSource Control. Under the TemplateField for Dept of Person class looks like</p> <pre><code>&lt;EditItemTemplate&gt; &lt;asp:DropDownList ID="cmbStatus" DataTextField="DeptName" SelectedValue='&lt;%# Bind("Dept.DeptId") %&gt;' DataValueField="DeptId" runat="server" CssClass="ddl150px ddlbg" DataSourceID="deptCollection" /&gt; &lt;asp:ObjectDataSource ID="deptCollection" runat="server" SelectMethod="GetDeptList" TypeName="LIMS.BusinessObject.Department" &gt; &lt;/asp:ObjectDataSource&gt; &lt;/EditItemTemplate&gt; </code></pre> <p>Now my Grid gets binded using </p> <pre><code> &lt;asp:ObjectDataSource ID="PersonCollection" runat="server" SelectMethod="GetPersonList" TypeName="LIMS.BusinessObject.Person" DataObjectTypeName="LIMS.DomainModel.Person" DeleteMethod="Delete" InsertMethod="Create" UpdateMethod="Update" ondeleting="PersonCollection_Deleting" onupdating="PersonCollection_Updating"&gt; &lt;/asp:ObjectDataSource&gt; </code></pre> <p>Now when I tries to update this Person entity, it throws error because dropdown displays Value field and text field and Person entity needs a Dept Entity which is actually binded to dropdownlist</p>
c# asp.net
[0, 9]
5,463,218
5,463,219
accessing multiple instances in jquery
<p>so i have a page of products, and for each one i want to cycle through some images on mouseover, and have it stop on mouseout. the following code is my current state...</p> <p>initially i had it working where it checked a global variable called repeatCycle to see if it should rotate to the next image. this caused problems because all the instances of this function were checking &amp; setting the same variable. i would often get multiple instances running at once. so i want to set something for each instance instead, but was not able to do it.</p> <p>i also tried passing it in as an argument to the function, but on the mouseout event when i passed in repeatCycle: false, it would just initialize another instance.</p> <p>anyone have any suggestions as to how to accomplish this?</p> <pre><code>$.fn.image_cycler = function(options){ // default configuration properties var defaults = { fade_delay: 150, image_duration: 1500, }; var options = $.extend(defaults, options); this.each(function(){ var product = $(this); var image = $('div.image&gt;a.product_link&gt;img', product); var description = $('div.image&gt;div.description', product); var all_images = $('div.all_images', product); var next_image = ($(all_images).find('img[src="' + $(image).attr('src') + '"]').next('img').attr('src')) ? $(all_images).find('img[src="' + $(image).attr('src') + '"]').next('img') : $(all_images).children('img').first();; // mouseover image.fadeOut(options.fade_delay, function(){ image.attr('src', next_image.attr('src')); image.fadeIn(options.fade_delay); }); if (this.repeatCycle){ var loop = function() { return this.image_cycler(options); } setTimeout(loop,options.image_duration); } }); }; $(document).ready(function() { $('div.product').hover(function(){ $(this).image_cycler(); }, function(){ $(this).image_cycler.repeatCycle = false; }); }); </code></pre>
javascript jquery
[3, 5]
2,908,271
2,908,272
how to combine jquery code into a javascript function
<p>I need to add a jquery script into a javascript function and then call that function when <code>#sortby</code> is added to the url. Is this possible?</p> <p><strong>the jQuery</strong></p> <pre><code>$("#myselect option[value='availability']").attr("selected","selected"); </code></pre> <p><strong>the Javascript</strong></p> <pre><code>function sortBy(){ performanceQuery(perfpage); tourQuery(tourpage); return false; } </code></pre>
javascript jquery
[3, 5]
3,744,295
3,744,296
Delete text and other elements before and after the element
<p>I need to delete everything (text and other elements) before and after the element <code>&lt;a&gt;</code> with value class <code>chatlink</code>. All this, within each element <code>&lt;div&gt;</code> with value class <code>main</code>.</p> <p><strong>But only if <code>&lt;div&gt;</code> element with the value <code>main</code> contains a link with the value of <code>chatlink</code>.</strong></p> <p>For example:</p> <pre><code>&lt;div class="main"&gt; Bla bla bla :) &lt;a href="#" class="chatlink"&gt;&lt;img src="#" /&gt;&lt;/a&gt; bla bla bla ... &lt;a href="#" class="chatlink"&gt;&lt;img src="#" /&gt;&lt;/a&gt; tra la la la laaa &lt;a href="#" class="postlink"&gt;some text&lt;/a&gt; tralalaaa &lt;/div&gt; </code></pre> <p>Final code:</p> <pre><code>&lt;div class="main"&gt; &lt;a href="#" class="chatlink"&gt;&lt;img src="#" /&gt;&lt;/a&gt; &lt;a href="#" class="chatlink"&gt;&lt;img src="#" /&gt;&lt;/a&gt; &lt;/div&gt; </code></pre> <p>Is it possible?</p>
javascript jquery
[3, 5]
5,663,645
5,663,646
iframe source problem with Safari
<p>I have a problem with Safari</p> <p>Whenever the source of the iframe changes the new source is not displayed it instead shown as a download file.</p> <p>Here is a sample of the code:</p> <pre><code>&lt;?php echo "&lt;iframe id='myframe' width='600' height='200' src='image3.php?id=$content' style='margin-left:25; background-color:#ffffff'&gt;&lt;/iframe&gt;";?&gt; </code></pre> <p>and in JS:</p> <pre><code>function refreshConsole() { var url = "image3.php?id=&lt;?php echo $content; ?&gt;"; document.getElementById("myframe").src=url; setInterval("refreshConsole()", 15000); } $(document).ready(function() { refreshConsole(); }); </code></pre> <p>It works fine with FireFox and Chrome but not in Safari.Is the problem with code or with the browser</p> <p>Editted:</p> <p>Here is image3 file</p> <pre><code>&lt;?php require("db.php"); db_connect(); $id=addslashes($_REQUEST['id']); $image3=mysql_query("select * from image where id=$id"); $image2=mysql_fetch_array($image3); $content2=$image2['image']; header('Content-type: image/jpg'); echo $content2; ?&gt; </code></pre>
php javascript
[2, 3]
4,992,639
4,992,640
PHP and mySQL Data Errors
<p>I currently have 2 users registered on my website; jason and jason1.</p> <p>I have a mySQL database that stores the following fields: <code>id message reciever sender</code></p> <p>When a message is sent from jason1 to jason, the data comes up correctly. However, when a message is sent from jason to jason1 both the <code>sender</code> and <code>reciever</code> fields come up as having the value of jason1. Here is some script info:</p> <p>The way the function is called: <a href="http://pastebin.com/BqVQ7vVE" rel="nofollow">http://pastebin.com/BqVQ7vVE</a><br> The function itself: <a href="http://pastebin.com/1hTEhxAN" rel="nofollow">http://pastebin.com/1hTEhxAN</a><br> <code>getmessage.php</code>, called with XHR: <a href="http://pastebin.com/u1A4hPG3" rel="nofollow">http://pastebin.com/u1A4hPG3</a><br> And a screenshot of the database: <a href="http://img263.imageshack.us/img263/7804/mysqlz.png" rel="nofollow">http://img263.imageshack.us/img263/7804/mysqlz.png</a></p> <p>I will take any suggestions, this is really frustrating. </p>
php javascript
[2, 3]
4,351,295
4,351,296
DefaultHttpClient or HttpURLConnection on Android
<p>In building web service designed to to interact with mobile devices, I am not sure what the best approach is for implementing HTTP requests on Android.</p> <p>I came across this post, which finishes by stating <code>HttpURLConnection</code> is the preferred method for making HTTP requests, and I have had success using the <code>HttpsURLConnection</code>.</p> <p>When searching for answers or reading other sample code (even fairly recent posts), all seem to use <code>DefaultHttpClient</code>, which seems to go against the official word from Google.</p> <p>I am trying to future proof my Android application as much as possible. With that in mind, is the <code>HttpURLConnection</code> the best choice?</p>
java android
[1, 4]
2,997,493
2,997,494
How to create bread crumb using Menu items in asp.net?
<p>I have two XMl files. One is for top navigation menu and other for left navigation menu.Based on the top navigation the left hand menu gets changed .It works fine but i am having problem to create bread crumb using these two xml files. Any suggestion on how to create bread crumb for this scenario?</p>
c# asp.net
[0, 9]
5,921,159
5,921,160
Hide page when second click on menu
<p>I use jQuery to display an accordion menu when clicking on a menu title.</p> <p>The first click displays the corresponding details page, and it works fine. Now, I need to hide this details page when the user clicks on that link for the second time.</p> <p>Thanks in advance for help.</p>
javascript jquery
[3, 5]
1,358,424
1,358,425
Get value of element created at "future"
<p>How to check element value if it will be create at the "future" on page. I know about live method but it works with an event.</p>
javascript jquery
[3, 5]
3,435,210
3,435,211
I would like all my select classes including those that might be added later to use select2
<p>I am using the following code:</p> <pre><code>$(".select2") .select2(); </code></pre> <p>All the select2 classes have the the .select2() applied to them. </p> <p>However I have code that adds html (including selects to my web page. Do I need to run the same code above after the new content is added? </p>
javascript jquery
[3, 5]
3,442,422
3,442,423
how to insert this javascript in php
<p>how to insert this javascript code :</p> <p>thejavascript</p> <pre><code>&lt;A HREF="javascript:void(0)" onclick="window.open('welcome.html','welcome')"&gt; &lt;/A&gt; </code></pre> <p>inside img src in php </p> <pre><code>&lt;img src="http:'.$iv[$j].'.jpg" height="220" width="200" alt="Image '.ucwords($kw).'" "thejavascript"&gt; </code></pre> <p>Thanks</p>
php javascript
[2, 3]
3,976,641
3,976,642
Why is it possible to query jQuery('div') like an array?
<p>I got another question regarding jQuery's architecture. <code>$('div')</code> constructs a new <code>jQuery</code> object:</p> <pre><code>$('div') instanceof jQuery; // true </code></pre> <p>I'd like to know why it is possible to query it like an array, allthough it isn't an array?</p> <pre><code>$('div')[0]; // returns the first div in the document as a DOM node. $.isArray($('div')); // false </code></pre> <p>I just love this syntax, it looks so clean! I also noticed this returns the DOM nodes as an array:</p> <pre><code>console.log($('div')); </code></pre> <p>Can somebody explain me how to implement this behaviour to my own objects? </p> <hr> <p>My own approach was to make an array with some methods like this:</p> <pre><code>var a = ['a', 'b', 'c']; a.method = function(){ return 'test'; }; a; // ['a', 'b', 'c'] a[0]; // 'a' a.method(); // 'test' </code></pre> <p>However this doesn't seem to be the way jQuery does it as this is actually an array:</p> <pre><code>$.isArray(a); // true </code></pre> <p>I'd like to know how jQuery does this to learn and to see if it's a better solution than mine.</p>
javascript jquery
[3, 5]
3,779,999
3,780,000
Android months of Year
<p>How can i get all days of particular month and particular year..</p>
java android
[1, 4]
995,894
995,895
Create different fragment types by one function
<p>I need a function in my Activity, that sets fragment to my ViewGroup (FrameLayout in this case). Of course, I can use such construction:</p> <pre><code>public void setFragment(Fragment fragment){ FragmentManager fm=getFragmentManager(); //etc } </code></pre> <p>But with this solution I need to create <code>fragment</code> somewhere else, not in my function. So, if class <code>MyFragment</code> extends <code>Fragment</code>, I need something like this:</p> <pre><code>setFragment(MyFragment); </code></pre> <p>Is it possible? <strong>Can I pass class as a parameter of function and then create instance of it</strong></p> <p>And if it's not - is it a bad idea to create fragment behind the function? Like</p> <pre><code>MyFragment my=new MyFragment(); setFragment(my); </code></pre>
java android
[1, 4]