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,881,153 | 1,881,154 | Change <body> to <body id"something" runat="server'> | <p>We have a huge website with main.master that is used in a lot of places.. If I change the tag to runat="server", would any other regular stuff continue working or it would not get affected if I change it?</p>
<p>Thank you</p>
| c# asp.net | [0, 9] |
5,266,504 | 5,266,505 | C# Call Event Handler Dynamic | <p>I am trying to save all the controls from one WebForm using a serialized Dictionary (controlId - string, controlValue - string). Next i want to deserialize that Dictionary and dynamically fill the controls with their values.</p>
<p>The problem is that some of my controls have AutoPostBack true and also event handlers. <strong>Is there a way to dynamically call these event handlers?</strong> I want to avoid another switch by control's id.</p>
<p>Ex:</p>
<pre><code>foreach (KeyValuePair<string, string> kvp in dict)
{
Control c = findControlRecursive(Page, kvp.Key);
if (c != null)
{
switch (c.GetType().Name)
{
case "TextBox":
((TextBox)c).Text = kvp.Value;
if (((TextBox)c).AutoPostBack) .......
</code></pre>
<p>EDIT:</p>
<p>Let's say that I have 10 different forms. each has about 50 controls. I want to add/edit a set of data. I try to avoid tables in database with columns for each control, that's why I want to use serialization.</p>
| c# asp.net | [0, 9] |
1,475,395 | 1,475,396 | Execute javascript function from java | <p>I want to know if it's possible to execute a javascript function from java. Basically I have a javascript function to which I want to pass a string and then get the output from that function.</p>
<p>If it's possible, how do I accomplish it?</p>
<p>EDIT - </p>
<p>I couldn't find a solution to this, what I did was re-write all the javascript code in Java. But I am guessing, Rhino ported on Android should do the trick. If someone has tried it out, please post a solution. </p>
| java javascript android | [1, 3, 4] |
3,835,985 | 3,835,986 | How to remove row on click on confirm message true? | <p>I have a asp gridview. On row databound I add onclick event to view item details. I have also delete button. The problem is <strong>When I click item delete, it deletes item but also redirect to item preview page.</strong> It should not do a postback and redirect</p>
<p>here is my code</p>
<pre><code> protected void Grid_DataBound(object sender, GridViewRowEventArgs e)
{
e.Row.Attributes["onClick"] = String.Format("location.href='" + "/Url/page.aspx?id=" + "{0}", DataBinder.Eval(e.Row.DataItem, "Id") + "'");
}
</code></pre>
<p>delete button</p>
<pre><code>public void GvDeleteHabit(object source, CommandEventArgs e)
{
int id= Convert.ToInt32(e.CommandName);
Delete(id);
}
<asp:LinkButton OnCommand="Delete" title="Delete" OnClientClick="javascript:return confirm('Do you want to delete?')"
CommandName='<%# Eval("Id")%>' runat="server" ID="BtnDelete"></asp:LinkButton>
</code></pre>
<p>on client side I have confirm message. So what I'm trying to achieve is when user click delete button and Yes, I need to remove onclick event from row and delete item.</p>
<p>if user click No stop page from loading. so user can click somewhere on row and view details of item</p>
| c# javascript jquery asp.net | [0, 3, 5, 9] |
1,333,607 | 1,333,608 | Array Dynamic Menu Logic? | <p>Ok what I am trying to do is create a dynamic menu based on an array
First dimesion elements will be top level and Second dimension levels will be sub items of said parent how will I do this?</p>
<pre><code>$(document).ready(function(e) {
//var maxLevels = 3;//Max Levels Of The List TO Traverse
var nav = new Array();
nav[0] = "Item A";
nav[0][0] = "Item AB";
nav[1] = "Item B";
nav[1][0] = "Item BA";
var menu = "";
nav.forEach(function(e) {
menu += "<li>" + e + "</li>";
});
$('#info').html(menu);
});
</code></pre>
| javascript jquery | [3, 5] |
2,321,872 | 2,321,873 | How to avoid duplicate items being added from one CheckBoxList to another CheckBoxList | <p>While adding items from one <code>CheckBoxList</code> to another <code>CheckBoxList</code> how to check if the item is already present in the second <code>CheckBoxList</code> using asp.net c#</p>
<p>The code I have written to move between <code>CheckBoxLists</code> is:</p>
<pre><code>protected void add_Click(object sender, EventArgs e)
{
for (int i = 0; i <= CheckBoxList2.Items.Count - 1; i++)
{
if (CheckBoxList2.Items[i].Selected)
{
CheckBoxList3.Items.Add(CheckBoxList2.Items[i]);
CheckBoxList3.ClearSelection();
}
}
}
</code></pre>
<p>I am using <strong>add_Click</strong> button to move items between lists.
I need to validate while adding items.</p>
<p>Kindly help. Thank you..!!</p>
| c# asp.net | [0, 9] |
4,772,684 | 4,772,685 | When to use Literal vs LiteralControl? | <p>What are the appropriate use of these two controls? From time to time I build up HTML in the code behind. Sometimes I want to output white space and I end up doing something like this.</p>
<pre><code>const string twoSpaces = "&nbsp;&nbsp;";
p.Controls.Add(new Literal { Text = twoSpaces });
</code></pre>
<p>or</p>
<pre><code>const string twoSpaces = "&nbsp;&nbsp;";
p.Controls.Add(new LiteralControl { Text = twoSpaces });
</code></pre>
<p>My question is, is this an appropriate use of these controls? Should I be adding whitespace this way? When do I use one over the other?</p>
<p>I realize I could probably do something with CSS, but I really want to know what are the purposes of these two controls, and is there anything inherently wrong with using them in this fashion.</p>
| c# asp.net | [0, 9] |
5,389,915 | 5,389,916 | Any way to clear the data of a DataInputStream in Java? (an Android application) | <p>First of all thanks for helping and apologize for my English, I'm from Spain.</p>
<p>I'm receiving images from a computer via TCP using a socket. For every image I get the number of layers (RGB), rows and columns of every layer, then the values of each pixel. To collect the data I use a <code>DataInputStream</code>.</p>
<p>Usually it works fine, but sometimes I get wrong values of the number of rows and columns causing problems in the next functions i.e. the app freezes waiting for data that will never be sent, or simply causes an index error on the array which holds the data.</p>
<p>So I want to clear the data if the number of rows and columns is too high, but I can't find any way to clear the <code>DataInputStream</code>, full of wrong bytes of pixel values.</p>
<p>In addition, I dont't know the size of the <code>DataInputStream</code>, because the size is calculated the following way: <code>Layers * Width * height</code>. So if I don't get the real values of this camps, I can't know the number of bytes that I have to skip.</p>
<p>Questions:</p>
<ol>
<li><p>Anyone knows some way to just clear a <code>DataInputStream</code>?</p></li>
<li><p>If not, should I use another type of Input way like
<code>BufferedInputStream</code>?</p></li>
</ol>
| java android | [1, 4] |
2,803,133 | 2,803,134 | Android: Obtain Java source code from jar | <p>I have a jar library that I use for my app and I want to make changes to the source code.
After using JD-GUI to obtain the source code from the class files, I put the files in my project in Eclipse. But the source code contains many errors. For example, it says that the constructor does not exists, but the source code clearly has this constructor.</p>
<p>Please provide help. Thank you.</p>
| java android | [1, 4] |
4,220,491 | 4,220,492 | DropDownList in Repeater control, can't fire SelectedIndexChanged | <p>I have a repeater control where in the footer I have a DropDownList. In my code-behind I have:</p>
<pre><code>protected void ddMyRepeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item
|| e.Item.ItemType == ListItemType.AlternatingItem)
{
// Item binding code
}
else if (e.Item.ItemType == ListItemType.Footer)
{
DropDownList ddl = e.Item.FindDropDownList("ddMyDropDownList");
// Fill the list control
ddl.SelectedIndexChanged += new
EventHandler(ddMyDropDownList_SelectedIndexChanged);
ddl.AutoPostBack = true;
}
}
</code></pre>
<p>The page appear to PostBack however my EventHandler does not get called. Any ideas?</p>
| c# asp.net | [0, 9] |
4,670,331 | 4,670,332 | my first jQuery plugin, only seems to bind to the first form of eight forms on the page | <p>I'm writing a small jQuery plugin that binds to 8 divs on a page, each of which contains a form. There are two links for each widget that increment or decrement a field within the form and then POSTs the form. The problem is that all 16 links on the page all submit the first form on the page.</p>
<p>The source code is here:
<a href="http://pastie.org/657045" rel="nofollow">http://pastie.org/657045</a></p>
<p>I'm a jQuery/JS newb and figure this is probably a variable scope issue, but I've tried everything and can't get the elements to operate independently.</p>
| javascript jquery | [3, 5] |
4,407,716 | 4,407,717 | LINQ-to-SQL DataContext is null on certain server | <p>I have a very unusual problem. I have an ASP.NET application that uses LINQ-to-SQL a lot, and works fine on most servers. However the application exists on another server on the same network, and after a recent update, whenever I open a new DataContext like this:</p>
<pre><code>LINQDataContext dc = new LINQDataContext();
</code></pre>
<p>The dc object is null, so I get object reference errors trying to use it. I cannot replicate this on my development machine, or on the other server which the application exists on, so I'm baffled about why this could be. Any ideas?</p>
| c# asp.net | [0, 9] |
3,993,402 | 3,993,403 | Why is object/associative array values not setting when I use $item.data("something").x | <p>Why is it when I do something like </p>
<p><a href="http://jsfiddle.net/sUhn9/" rel="nofollow">http://jsfiddle.net/sUhn9/</a></p>
<p><em>Added relevant HTML</em></p>
<pre><code><div id="container" data-physics='{x: 10, y: 5}'>Hello</div>
</code></pre>
<p>JavaScript:</p>
<pre><code>$(function() {
var obj = $("#container").data("physics");
console.log("b4", obj);
obj.x = -2;
obj.y = -6;
console.log("after", obj);
});
</code></pre>
<p>I get </p>
<pre><code>b4 {x: 10, y: 5}
after {x: 10, y: 5}
</code></pre>
<p>Where x and y are not being set</p>
| javascript jquery | [3, 5] |
309,399 | 309,400 | Alternative for Java Swings in php | <p>Can anyone please help me to write php code using the below java code.</p>
<p>I strucked somewhere and i have so many questions:</p>
<p>how to write java JFrame, BorderLayout, setJMenuBar, setVisible in php.</p>
<pre><code> // init the frame
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setLayout(new BorderLayout());
this.setSize(600, 400);
// set MenuBar
this.setJMenuBar(getApplicationMenuBar());
// set ProgressBar
this.add(getApplicationProgressBar(), BorderLayout.SOUTH);
// set InfoPane
this.add(getInfoPane(), BorderLayout.WEST);
// set frame to visible
this.setVisible(true);
</code></pre>
<p>Please help me on this.</p>
<p>Thanks in advance.</p>
| java php | [1, 2] |
433,234 | 433,235 | Disabling submit button stops form from being submitted PHP / Javascript | <p>I think I got a classic problem but I was not able to find a working solution so far.</p>
<p>I have got a form , the user clicks "Send" and everything works fine using a PRG pattern and doing both client-side and server-side validation.</p>
<p>The problem arises when any user (let's assume he entered valid inputs) clicks more then once quickly before the server script ends its execution...</p>
<p>I do not get any duplicated entry because I took care of that but the browser does not go to my "thanks for submitting page".
Instead it re-submits the same page with the same values and what I get are the custom errors I set to warn the user he is trying to enter details already stored in the database. The details sent in the first place are all in the database but the user has no chance to know that.</p>
<p>I tried to disable the submit button on a submit event using jQuery but in that case the data are not submitted. </p>
<p>HTML</p>
<pre><code> <div id="send-button-container">
<input id="send-emails" type="submit" name="send_emails" value="Send"/>
</div>
</code></pre>
<p>jQuery</p>
<pre><code> $(document).ready(function(){
$('#mail-form').submit(function(){
$('#send-emails').attr('disabled','disabled');
});
});
</code></pre>
<p>I am wondering if I can force a submission using Javascript after disabling the button and also how to deal with UAs with Javascript disabled</p>
<p>Thanks in advance</p>
| php jquery | [2, 5] |
1,279,788 | 1,279,789 | Function to look through folder and use a wildcard | <p>been a lurker on Stack Overflow for a while, love the site.</p>
<p>Now its my turn. From the code below, i am making the background image random each time the page loads.</p>
<p>Would anyone be so kind as to help me make this more efficient so that i don't have to manually enter my filenames ? Im looking for some kind of wildcard function that can look through my given folder and load footer*.png or even *.png as this folder will only contain footer patterns.</p>
<pre><code>var images = ['footer.png', 'footer2.png', 'footer3.png'];
$('#footer').css({'background-image': 'url(images/footers/' + images[Math.floor(Math.random() * images.length)] + ')'});
</code></pre>
| javascript jquery | [3, 5] |
1,798,692 | 1,798,693 | Will aspx not see changes made by javascript? | <p>I am changing the contents of a span with javascript. I can see that it has changed with view source. </p>
<p>When I try to get the contents in a c# function right after, it still has the old value. </p>
<p>My guess is that asp is just seeing the html that it sent the client, and that javascript is changing the client html of which asp cannnot see? </p>
<p>this was my only guess on how to explain it. Would this be correct?</p>
<p>Thanks.</p>
| javascript asp.net | [3, 9] |
3,507,658 | 3,507,659 | convert decimal to string without removing 0 "zero(s)"? | <pre><code>nStr = 12.00;
alert(typeof(nStr));// getting number
x = nStr.split('.');
// Other than string Split function Through an error,
nStr = 12.00;
nStr += '';
alert(typeof(nStr));// getting string
x = nStr.split('.');
x1 = x[0];
x2 = x.length > 1 ? '.' + x[1] : '';
alert(x1+x2);
//Expected Output is 12.00
</code></pre>
<p>I got the temp output coding ( its not optimized coding)</p>
<pre><code>nStr += '';
x = nStr.split('.');
x1 = x[0];
x[1]= (x[1].length == 1) ? '.' + x[1] + '0' : '.' + x[1];
x2 = x.length > 1 ? x[1] : '.00';
alert(x1+x2); // 12.00
</code></pre>
| javascript jquery | [3, 5] |
1,872,130 | 1,872,131 | Gridview editing without postback | <p>I am using Gridview with Edit option. When i click on Edit button row becomes editable with Update & cancel button. But this process causes a postback which degrades performance in my scenario. Is there any other way available to make row editable without causing a postback(maybe using javascript)?</p>
| javascript asp.net | [3, 9] |
2,212,843 | 2,212,844 | Android service - check if variable asynchronously changes over period of time? | <p>Let's say I have a boolean isAction. In my service I want to run some sort of timer mechanism and if this boolean changes state, call some function X, else do nothing. </p>
<p>What would be the best way to do this? I've tried using timers to no avail, and I'm not sure if a handler with postDelayed would be appropriate to do this, since the boolean could change states back-and-forth, which may give me a "false-positive" of isAction never changing. </p>
<p>For more background info, an intent gets fired which starts a service. This service needs to determine if boolean isAction stays the same for about a second or so, and if it does, then take some action, else return and do nothing. </p>
<p>Thanks. </p>
| java android | [1, 4] |
4,894,699 | 4,894,700 | Android: Include External Jar in Build (Without Eclipse) | <p>I'm working with Android at the moment, trying to avoid using Eclipse (for which I have an irrational hatred).</p>
<p>I need to include an external <code>.jar</code> file (used in my <code>Activity</code>)and have no idea how to link it for <code>ant debug</code>...</p>
<p>I've read up on <code>build.xml</code> files but adding <code><code><</code>path id="compiler.classpath"<code>></code>...<code><</code>/...<code>></code></code> or <code><code><</code>classpath<code>></code></code> nodes to the XML doesn't help fix it.</p>
<p>Hope someone can help me out!</p>
| java android | [1, 4] |
4,203,507 | 4,203,508 | jQuery AutoComplete missing? | <p>I was building something using jQuery's AutoComplete plugin last week, but today I found that it's not working.</p>
<p>After some debugging, it seems that the external scripts I've been loading no longer exist:</p>
<p><a href="http://dev.jquery.com/view/trunk/plugins/autocomplete/lib/jquery.bgiframe.min.js" rel="nofollow">http://dev.jquery.com/view/trunk/plugins/autocomplete/lib/jquery.bgiframe.min.js</a></p>
<p><a href="http://dev.jquery.com/view/trunk/plugins/autocomplete/lib/jquery.dimensions.js" rel="nofollow">http://dev.jquery.com/view/trunk/plugins/autocomplete/lib/jquery.dimensions.js</a></p>
<p><a href="http://dev.jquery.com/view/trunk/plugins/autocomplete/jquery.autocomplete.js" rel="nofollow">http://dev.jquery.com/view/trunk/plugins/autocomplete/jquery.autocomplete.js</a></p>
<p>Even the demo on the plugin page no longer works:</p>
<p><a href="http://docs.jquery.com/Plugins/autocomplete" rel="nofollow">http://docs.jquery.com/Plugins/autocomplete</a></p>
<p>Was the plugin deprecated over the weekend and I didn't know it? Or is there some way to let them know that the files aren't showing up?</p>
| c# asp.net jquery | [0, 9, 5] |
86,944 | 86,945 | MasterPage issues with anchor tags and fancyBox | <p>I've got some ASP:Hyperlink controls on the master page for a set of global links. I'm using the 'permissions' property so I'm hoping to keep these.</p>
<p>If I setup the control like this:</p>
<pre><code><asp:HyperLink ID="inlineMileageCalc" runat="server" NavigateUrl="~/#mileageCalc">Mileage Calculator</asp:HyperLink>
</code></pre>
<p>Everything works fine when I'm on the default.aspx page in the root. However, if I go down one more level like <a href="http://www.xxxxx.com/nextlevel/default.aspx" rel="nofollow">http://www.xxxxx.com/nextlevel/default.aspx</a> the fancyBox will not render, just throws a jQuery error.</p>
<p>Is there a way to do this to make the fancyBox show no matter what level I'm on?</p>
<p>Thanks.</p>
| c# asp.net | [0, 9] |
3,201,331 | 3,201,332 | Pass value from parent to iframe dropdown box | <p>I need to pass a value from a parent to an iframe (on a different server, not in my control) and have the value make a selection in a dropdown in the iframe.</p>
<p>Example: mydomain.com/?agent=12345 (target will be the iframe)</p>
<p>In the iframed page, the dropdown has several choices, I need to have the value in the url be the selected the choice corresponding to the selection when the link is clicked and the page is loaded in the iframe.</p>
<p>Is passing in the URL possible or do I use JS, PHP? If JS or PHP, how?</p>
<p>Thanks.</p>
| php javascript | [2, 3] |
2,247,057 | 2,247,058 | jquery with check box in asp.net adding click event | <p>I have textbox and checkbox in asp.net page.
if the check box checked should have an input mask and if its uncheck should have another input mask. my code is always picking up second condition and I've been advised that I should add click event to run the code whenever the checkbox is clicked and because I'm new with jquery i need help to add click event to my script.</p>
<p>please help.</p>
<p>here is my code:</p>
<pre><code> <%@ Page Title="" Language="C#" MasterPageFile="~/Imam.Master" AutoEventWireup="true"
CodeBehind="WebForm4.aspx.cs" Inherits="Imam_Contacts.WebForm4" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<script src="js/jquery-1.4.1.js" type="text/javascript"></script>
<script src="js/jquery.maskedinput-1.2.2.js" type="text/javascript"></script>
<script type="text/javascript">
$(function() {
if ($('#chkhtml:checked').length > 0) {
$("#txthtml").mask("999-99-9999");
} else {
$("#txthtml").mask("99/99/9999");
}
});
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
</code></pre>
<p></p>
<pre><code><input id="chkhtml" type="checkbox" checked="checked" />
</asp:Content>
</code></pre>
| asp.net jquery | [9, 5] |
5,027,229 | 5,027,230 | Timer with multiple things to do | <p>I am making an android app which reminds people via notifications of events they have to do over the course of a day. The way I currently do this is have each event on a seperate timer using the Timer class. However, I don't think this is great way of doing things. Is there any way maybe to have just one timer which will trigger an event at each time interval I pass in? Or is there any other way of scheduling a notification?</p>
| java android | [1, 4] |
64,203 | 64,204 | How to remove a live submit event in jQuery? | <p>I have two forms on our site #footer_leads and #footer_leads2 and i have a live submit event but need to verify a few things before the form gets summitted so i have this code</p>
<pre><code>$('#footer_leads2, #footer_leads').live('submit', function(e){
e.preventDefault();
console.log('again');
var form = $(this); //save reference to form
if(somevalidation){
form.die();
form.submit(); //submit form
}
</code></pre>
<p>I assumed the jQuery <a href="http://api.jquery.com/die/" rel="nofollow">die</a> event would do the trick like in the above example but the page just into an infinite loop and crashes my browser....any ideas on how to do this</p>
| javascript jquery | [3, 5] |
5,636,096 | 5,636,097 | javascript catch comet socket disconnect | <p>So I have implemented comet sockets on my server, and am able to push data to the browser fine. But what I would like to do is catch in javascript/jquery when the comet server drops out. </p>
<p>I have my iframe:</p>
<pre><code><div id="iframeDiv" style="visibility:hidden; height:0px">
<iframe id="comet" src="/messageSocket?-3711886712169888393"></iframe>
</div>
</code></pre>
<p>and i have my javascript to handle the new message:</p>
<pre><code>// Comet Server Processes actions
var messageReceived = function(message) {
var commandType = message[1];
switch (commandType) {
case "1":
processActionData(message);
break;
...
default:
break;
}
}
</code></pre>
<p>but for example lets say the connection drops for whatever reason? How can I bring it back up? For example if the local server hosting the website shuts down and starts back up again I would like on the client to catch a timeout? And then reload the page. How do I do this? Do I need to create a loops that makes an ajax ping requests to determine if the connection is still alive? Is there a better way to just catch when the comet socket dies?</p>
| javascript jquery | [3, 5] |
4,333,040 | 4,333,041 | Passing multiple Eval parameters to a JavaScript function from ASPX | <p>I already know how it works with a single parameter </p>
<pre><code>OnClientClick='<%# String.Format("confirm_ticket({0});return false;",DataBinder.Eval(Container,"DataItem.idAgir"))%> '
</code></pre>
<p>but is it possible to pass 2 parameters?</p>
<p>thanks in advance</p>
| c# javascript asp.net | [0, 3, 9] |
1,282,251 | 1,282,252 | How to open a new tab/window on clicking on ItemTemplate asp:Image Button with Query String? | <p>I have a ImageButton inside the DataList ItemTemplate, I am trying to open a new page (new tab) on clicking on ImageButton, but its opening in same tab. </p>
<pre><code><ItemTemplate>
<asp:ImageButton ID="ibtmImage" runat="server" ImageUrl='<%# Eval("Image") %>'OnCommand="ibtmImage_Command" CommandArgument='<%# Eval("Id").ToString() %>' OnClientClick="aspnetForm.target ='_blank';" />
</ItemTemplate>
protected void ibtmImage_Command(object sender, CommandEventArgs e)
{
Response.Redirect("ItemList.aspx?Id=" + e.CommandArgument.ToString());
}
</code></pre>
<p>How to open a page in new tab/new window.</p>
<p>Some one please help me.</p>
| c# asp.net | [0, 9] |
2,060,527 | 2,060,528 | Form Submission after remote validation | <p>I am trying to use Jquery's validation plugin "remote" method. If I use "async": true with that, the form submits even before the validation succeeds. If I use "async": false, it works fine in Firefox and Chrome, but in IE8 and IE9, it freaks out, by not displaying a "div" that's shown in the validation plugin's "beforeSend" method.</p>
<p>How do I make sure the "remote" method works nicely with async:true?</p>
<p>Thanks,</p>
| javascript jquery | [3, 5] |
3,502,532 | 3,502,533 | Getting stuck on sh-3.2# when issued su command over adb in C++ program | <p>I am trying to perform some operations which require superuser permissions but after issuing su command using adb with c++ program like this
http:/pastebin.com/XaHsbVnw
It gets stuck to sh-3.2# and doesn't proceed to next command that is <a href="http://pastebin.com/4k8AV57L" rel="nofollow">http://pastebin.com/4k8AV57L</a></p>
<p>Here is the complete source code
<a href="http://pastebin.com/K7pdi08J" rel="nofollow">http://pastebin.com/K7pdi08J</a></p>
<p>I am using CodeBlocks with GCC Compiler
Please help me :)
PS: I know cat proc/mtd doesn't require su permissions but I am trying to accomplish something else there</p>
| android c++ | [4, 6] |
5,820,012 | 5,820,013 | jquery load script conflict | <p>I'm using JQuery to append a script tag to a div, ex.:</p>
<pre><code>$("#special_div").append("<script src="http://blablabla.com/id.php?id=0000"></script>");
</code></pre>
<p>and that script returns: </p>
<pre><code>document.write("<object ....></object>");
</code></pre>
<p>but when I append it, all my HTML is gone and only that tag is written..</p>
<p>Can anyone tell me what's wrong?</p>
| javascript jquery | [3, 5] |
4,886,199 | 4,886,200 | Anyone know of javascript for this drop down navigation? | <p>I'm a beginner to web design, does anyone know of a script that has this EXACT drop down navigation style?</p>
<p><a href="http://behance.vo.llnwd.net/profiles4/172375/projects/4109265/b262ce1df694cced3f3fa5fe3cb8dc97.jpg" rel="nofollow">http://behance.vo.llnwd.net/profiles4/172375/projects/4109265/b262ce1df694cced3f3fa5fe3cb8dc97.jpg</a></p>
| javascript jquery | [3, 5] |
5,778,567 | 5,778,568 | What is difference between jquery.js and jquery.lite.js? | <p>When I download JQuery zip file <a href="http://jqueryjs.googlecode.com/files/jquery-1.2.5-release.zip" rel="nofollow">LINK</a>. It gives me 4 different files</p>
<ul>
<li>jquery.js</li>
<li>jquery.lite.js</li>
<li>jquery.min.js</li>
<li>jquery.pack.js</li>
</ul>
<p>pack is the most compressed one of that js file and min is minified one.
So I have two question...</p>
<ol>
<li>What is difference between jquery.js and jquery.lite.js. There looks no difference when I view code.</li>
<li>What is better to use min.js or pack.js on live website?</li>
</ol>
| javascript jquery | [3, 5] |
1,167,853 | 1,167,854 | ImageView Width And Height Programmatically In TableLayout | <p>Actullay all I want is in question title. I want to set fix width and height for ImageView in TableLayout. How can I do it?</p>
<p>This is my code:</p>
<pre><code>public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.buddy_list);
TableLayout buddy_list_layout = (TableLayout)findViewById(R.id.buddy_list_layout);
TableRow tableRow = new TableRow(this);
tableRow.setLayoutParams(new TableLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
ImageView imageView = new ImageView(this);
imageView.setImageResource(R.drawable.troll_logo);
//imageView.setLayoutParams(new TableLayout.LayoutParams(100, 100));
tableRow.addView(imageView);
buddy_list_layout.addView(tableRow);
} // end -> method -> onCreate
</code></pre>
| java android | [1, 4] |
1,862,080 | 1,862,081 | Android List Preferences: have summary as selected value? | <p>I have a Preference activity which uses a List Preferences as defined by my XML file. How would I set the summary of the list activity to the value that is selected?</p>
<p>Thank you!</p>
| java android | [1, 4] |
1,591,844 | 1,591,845 | how to create valued stacked bar chart using javascript or php | <p>How to create <em>valued stacked bar</em> chart using javascript? </p>
<p>I am using the below code but I am not getting the required result</p>
<pre><code><script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("visualization", "1", {packages:["imagebarchart"]});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Test Name', 'Correct', 'Wrong','Unanswered'],
['2004', 1000, 220, 52],
]);
var chart = new google.visualization.ImageBarChart(document.getElementById('chart_div'));
chart.draw(data, {color:'008000,FF0000,FFFF00'}, {width: 400, height: 240, min: 0});
}
</script>
</code></pre>
| php javascript | [2, 3] |
298,643 | 298,644 | Label is missing error eclipse | <pre><code> float f1 = 4.0F;
localPaint.setTextSize(f1);
int j = howManyBreaks(str, localPaint, paramInt1);
int i = 0;
while (true)
{
if ((f1 >= f2) || (j > paramInt2))
break label142; //getting error here
i = 1;
f1 += 0.5F;
if (f1 >= f2)
break;
localPaint.setTextSize(f1);
j = howManyBreaks(str, localPaint, paramInt1);
}
f1 = f2;
if (i != 0)
label142: f1 = f1 - 0.5F - 0.5F; // but i have placed label142 here
paramTextView.setTextSize(0, f1);
</code></pre>
<p>In this above code I get error as: "label142 is missing"
Can anyone please rectify this error, if not possible please tell me an alternative for this.
Thanks in advance</p>
| java android | [1, 4] |
2,864,977 | 2,864,978 | Dynamically create and repeat the set of fields | <p>I have a PHP form which shows one 'User details' block by default. 'User details' section has first name, last name and address etc. I have a requirement to repeat the same block after clicking on the button so the user can enter 'n' number of users into on the form. Also I need to save all the information in MySQL database. What is the best way to achieve this? Please let me know. I appreciate any help.</p>
<p>Thank you.</p>
| php javascript | [2, 3] |
2,317,457 | 2,317,458 | How to pass extra parameter in jquery post request from outside click event? | <p>Hi i have jquery request like below ,</p>
<pre><code>$('#filterForm').submit(function(e){
e.preventDefault();
var dataString = $('#filterForm').serialize();
var class2011 = document.getElementById("2011").className;
//var validate = validateFilter();
alert(dataString);
if(class2011=='yearOn')
{
dataString+='&year=2011';
document.getElementById("2011").className='yearOff';
}
else
{
document.getElementById("2011").className='yearOn';
}
alert (dataString);
$.ajax({
type: "POST",
url: "myServlet",
data: dataString,
success: function(data) {
/*var a = data;
alert(data);*/
}
});
</code></pre>
<p>and my Form is like , </p>
<pre><code><form method="post" name="filterForm" id="filterForm">
<!-- some input elements -->
</form>
</code></pre>
<p>Well, I am triggering jquery submit on submit event of a form ,(it's working fine)
I want pass one extra parameter inside form which is not in above form content but it's outside in page
it's like below</p>
<p>[Check this image link for code preview][1]</p>
<p>So how can i trigger above event , on click of , element with class yearOn ( check above html snippet ) and class yearOff , with additional parameter of year set to either 2011 or 2010</p>
| javascript jquery | [3, 5] |
1,823,585 | 1,823,586 | Jquery changing images on on click | <p>i have a problem with my click changing image, i have database messages , every message has a status 0 or 1 , from my code o have to click on status image and it will change, its changes BUT only for the first Message. When i click to other message status it not changes but changes only for the first status. how can i go this run!!!</p>
<pre><code><script type="text/javascript">
$(function() {
$('.imageCheck').click(function(e){
e.preventDefault();
$("#bg").attr('src',"/application/admin/img/tick.png");
});
});
</script>
</code></pre>
<p>
</p>
<pre><code> <th>Status</th>
</tr>
</thead>
<tbody>
<?php
foreach ($users as $user):
?>
<tr>
<td><?=$user['id']?></td>
<td>
<div class="imageCheck"><img id="bg" src="<?php echo $img_path;?>publish_x.png" name="statusCheck" value="0" />
</div>
</td>
</code></pre>
| php javascript jquery | [2, 3, 5] |
1,730,518 | 1,730,519 | update jquery dialog when listview inside dialog is databinded with new data | <p>I have a Jquery dialog with an ASP listview control inside. Before showing the dialog the listview is already filled on Page_Load, but I want to change this. I want to fill the listview when a dropdownlist is changed in the .aspx page, which triggers a postback to databind the listview.</p>
<p>The problem I'm having now is, when I want the dialog to be shown with the listview inside, the listview is still showing show the data I've binded on Page_Load.</p>
<p>How can I show the up-to-date listview inside my dialog after a postback?</p>
<p>Code to fill listview:</p>
<pre><code> string conString = System.Configuration.ConfigurationManager.ConnectionStrings["SQLCONN"].ToString();
SqlConnection conn = new SqlConnection(conString);
string cmdstr = "querystring";
DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter(cmdstr, conn);
da.Fill(ds, "PlanningWagen");
lvPlanningWagen.DataSource = ds;
lvPlanningWagen.DataBind();
</code></pre>
<p>The querystring is right. Depending on whats selected in the ddl, the right records are always filled in the dataset. I've checked that.</p>
<p>Thx</p>
| c# asp.net jquery | [0, 9, 5] |
5,468,679 | 5,468,680 | Resetting A webform on the ClientSide | <p>I have a webform with 3 textboxes, a checkbox and a Reset button. I need these to be reset to null values when i click the button "Reset" and i need it to be a Client-Side operation. The JS code that i have tried for this is as follows but for some reason it doesnt work. Any Help PLease?</p>
<pre><code><code>
<script type="text/javascript">
function resetForm() {
document.getElemenyById("<%=txtbox1.ClientID%>").value = "";
return false;
}
</script>
<asp:LinkButton ID="wbtnReset" runat="server" Text="RESET PAGE" CssClass="stdHyperlink" Font-Bold="True" OnClientClick="javascript:return resetForm()"/>
</code>
</code></pre>
| javascript asp.net | [3, 9] |
1,217,074 | 1,217,075 | how to turn a function from function(element) syntax to $(element).function() syntax | <p>I have a function that accepts the element it needs to operate on as a parameter <code>element</code></p>
<pre><code>function changeColor(element){
$(element).find('.middleBox').each(function(){
$(this).//do some stuff that does not matter now;
});
}
</code></pre>
<p>and I call it this way </p>
<pre><code>changeColor($(document)); //this applies it to the whole document
changeColor($('#sectionOne')); //this applies it to only part of the document
</code></pre>
<p>I want to change it from the format where it accepts its object as a param to this format. How do I do it</p>
<pre><code>$('#sectionOne').changeColor();
$(document).changeColor();
</code></pre>
| javascript jquery | [3, 5] |
896,798 | 896,799 | submit event not firing after blur event triggers javascript confirmation | <p>I have a simple form, where on blur event of textfield I am showing a confirm message to the user, which simply auto populates another hidden textfield. Which works good so far. The problem happens when the user directly clicks the submit button instead of clicking another field or anywhere else on the form. This should trigger both the blur and submit events, but for some reason the blur triggers, the confirmation comes up, and once the user clicks on the confirmation, submit event isn't triggered. User is forced to click submit again to trigger submit event. Any ideas?</p>
<pre><code>$(function(){
$("#txt_fld1").blur(function(){
if(confirm("Auto calculate charge?"))
{
$("#txt_chrg").val("8.25");
}
});
$("form").submit(function(){
alert("SUBMITTING");
});
})
</code></pre>
| javascript jquery | [3, 5] |
343,092 | 343,093 | unbind and then bind the onclick function(with dynamic param) to the anchor tag in repeater in jquery or javascript | <p>I want to unbind the function(which is with parameters<br>
<%#Eval('')%>) and after thta on button click bind that function in jquery or javascript</p>
<pre><code> <ItemTemplate>
<tr>
<td nowrap="nowrap" align="center">
<%#Eval("Comments")%>&nbsp;
</td>
<td nowrap="nowrap" align="center">
<a id="hlnkEditVoyageAssosiatedCompanyID" onclick="FillVoyageCompanyData(<%#Eval("VoyageAssosiatedCompanyID") %>);"> Edit</a>
</td>
</tr>
</ItemTemplate>
</code></pre>
<p>Here i want to unbind "FillVoyageCompanyData" function.
i am doind it by</p>
<pre><code> $("#hlnkEditVoyageAssosiatedCompanyID").unbind("click");
</code></pre>
<p>and then </p>
<pre><code> $("#hlnkEditVoyageAssosiatedCompanyID").bind("click", FillVoyageCompanyData);
</code></pre>
<p>but it is not working. it does not unbind the function</p>
| javascript jquery | [3, 5] |
1,152,616 | 1,152,617 | javascript written before doctype is working. But it is written after doctype then it is not working | <p>I am writing some js code before doctype and this code generate one array. If i am writing this code inside of doctype or head tag then it is not working.</p>
| php javascript jquery | [2, 3, 5] |
5,604,232 | 5,604,233 | jQuery.each() undefined issue | <p>I have the following code</p>
<pre><code>function myFunction(items) {
// this prints out 11
alert(items.length);
$(items).each(function(i, item) {
// item is undefined for some reason
}
}
</code></pre>
<p>It I alert the length of items, it has elements in it (11 to be exact). so how could 11 items be present, but jQuery still pass undefined?</p>
| javascript jquery | [3, 5] |
3,454,453 | 3,454,454 | c# display doc/docs in exactly format in website | <p>Below is my code to read a doc/docs file. </p>
<p>it can read, but the output format not exactly as in the docs, if that any way to display exactly format in aspx?</p>
<pre><code>protected void Button2_Click(object sender, EventArgs e)
{
var wordApp = new Microsoft.Office.Interop.Word.ApplicationClass();
string strFilePath = @"C:\Users\Roy\Desktop\News.doc";
object objFile = strFilePath;
object objNull = System.Reflection.Missing.Value;
object objReadOnly = true;
//Open Document
Microsoft.Office.Interop.Word.Document Doc
= wordApp.Documents.Open(ref objFile, ref objNull,
ref objReadOnly, ref objNull,
ref objNull, ref objNull, ref objNull,
ref objNull, ref objNull, ref objNull,
ref objNull, ref objNull, ref objNull,
ref objNull, ref objNull, ref objNull);
int i = 1;
foreach (Microsoft.Office.Interop.Word.Paragraph objParagraph
in Doc.Paragraphs)
{
try
{
Label1.Text += Doc.Paragraphs[i].Range.Text;
}
catch (Exception ex)
{
throw ex;
}
i++;
}
wordApp.Quit(ref objNull, ref objNull, ref objNull);
}
</code></pre>
| c# asp.net | [0, 9] |
1,520,096 | 1,520,097 | How do I find a control I placed inside a panel? | <p>I have a button inside a Panel. I'm trying to find the id of the button, but my code doesn't work:</p>
<pre><code>protected void pnl_nocutomer_Load(object sender, EventArgs e)
{
Button btn;
btn = this.FindControl("btn_clear") as Button;
Page.LoadComplete += new EventHandler(Page_LoadComplete);
string LanguageID = Globals.GetSuitableLanguage(Page);
if (LanguageID == "ar")
{
btn.Text = Globals.Translate("Ok", LanguageID);
}
}
</code></pre>
| c# asp.net | [0, 9] |
3,706,852 | 3,706,853 | Datetime format in C# | <p>I have a <code>DateTime</code> saved in <code>dtmNextPayment</code>. I want that to showed in the label in mm/dd/yyyy way. I have tried using</p>
<p><code>lbltakeeffectdate.Text = dtmNextPayment.ToString("mm/dd/yyyy");</code></p>
<p>But month is always shown as 00. I have no idea why? Please let me know what should be the problem..</p>
<p>And also, please tell me what is the best solution.. Thank you so much!!</p>
| c# asp.net | [0, 9] |
3,775,747 | 3,775,748 | How to scroll a div to the bottom after appending something to that div? | <p>So I am currently using <a href="http://stackoverflow.com/questions/270612/scroll-to-bottom-of-div">this solution</a> to scroll a div to the bottom by writing something like</p>
<pre><code>$(document).ready(function() {
$('#comment_list').scrollTop($('#comment_list').scrollHeight)
}
</code></pre>
<p>But I noticed that when I try to <code>.append()</code> something to <code>#comment_list</code> then do the above code. It doesn't actually scroll to the bottom (maybe the <code>.scrollHeight</code> is a static value?).</p>
<p>For example, this won't work</p>
<pre><code>$('#comment_list').append('<div>something</div>').scrollTop($('#comment_list').scrollHeight)
</code></pre>
<p>Neither will this</p>
<pre><code>$('#comment_list').append('<div>something</div>')
$('#comment_list').scrollTop($('#comment_list').scrollHeight)
</code></pre>
<p>Do I need to use some other "trick" or something?</p>
<p>Any tips and suggestions welcomed. Thanks in advance!</p>
| javascript jquery | [3, 5] |
3,213,250 | 3,213,251 | Dynamically generated div isn't attaching my event listener | <p>I made a modal plugin but for some reason one of the divs that I generate isn't getting a click event listener that I am attaching to it.</p>
<p><code><a class="close" id="js-close-modal"></a></code> is what I'm referring to. I'm using jQuery's on, but that doesn't seem to help.</p>
<pre><code> var $caller = $(this);
var $modal = $('.modal');
$caller.on('click', $caller, function(e) {
e.stopPropagation();
$('#js-close-modal').on('click', $('#js-close-modal'), function(e) {
$('.modal_outer').remove();
$('#modal_page_cover').remove();
});
var modal_outer = $('<div />');
modal_outer.addClass('modal_outer');
modal_outer.css({
top: ($(window).scrollTop()) + 'px'
});
var $div = $('<div />');
var modal = $('<div />');
modal.addClass('modal');
var modal_inner = $('<div />');
modal_inner.addClass('modal_inner');
modal.append(modal_inner);
modal_outer.append(modal);
var body = $('body');
body.append(modal_outer).hide().fadeIn(100);
modal_inner.text('yo');
var close = $('<a />');
close.addClass('close').attr('id', 'js-close-modal');
close.insertBefore(modal_inner);
var page_cover = $('<div />');
page_cover.attr('id', 'modal_page_cover');
body.prepend(page_cover);
});
</code></pre>
<p>Demo: <a href="http://jsfiddle.net/someprimetime/P5B4q/19/" rel="nofollow">JSFiddle</a></p>
<p>Any idea why?</p>
| javascript jquery | [3, 5] |
4,623,167 | 4,623,168 | Android: Show Dialog in SearchDialog Activity | <p>Is there a way to show a Dialog or AlertDialog that is launched by the Search Activity that is set as the default search activity?
I have a SearchDialog that is working as intended but i want to show a dialog with extra search option each time a search is executed.
It wont work by simply implementing the dialog in the Search Activity that is called by my view activities...
Does anyone have an idea?</p>
| java android | [1, 4] |
3,389,122 | 3,389,123 | Multiple mobile platform game development (Android/iOS) | <p>I'm currently developing a small indie game for the Android framework, however in order to save my some future work - I was wondering, is there a way to develop a game for the Android and iOS at the same time?</p>
<p>I'm aware of HTML 5 solutions, but I'm unsure if you can use them in order to develop games.
My requirements:
* 2D Graphics with animations
* Play sounds (music/sfx)
* Touch gestures (click, drag, pinch, etc)</p>
<p>Any suggestions?</p>
| android iphone | [4, 8] |
3,920,654 | 3,920,655 | Difference between " and ' characters in JQuery | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/242813/when-to-use-double-or-single-quotes-in-javascript">When to Use Double or Single Quotes in JavaScript</a> </p>
</blockquote>
<p>I think <code>$('#id')</code> and <code>$("#id")</code> both is valid so <code>"</code> and <code>'</code> character is samething and it is just preference to use <code>'</code> instead of <code>"</code> ?</p>
| javascript jquery | [3, 5] |
1,463,591 | 1,463,592 | Jquery and clone html sections? | <p>I have this template <code>div</code></p>
<pre><code><div class="divDetails">
<div class="divRowData" style="display: none ">
<span class="spanColor"></span>
<span class="spanText"></span>
</div>
</div>
</code></pre>
<p>It is hidden.</p>
<p>I have an object array and I need to duplicate <code>divRowData</code> with the injected data from array. ( and make each new section visible ).</p>
<p>But it seems my jquery code is a bit of a mess and I'm looking for a shorter way of doing it.</p>
<p>Currently I do : </p>
<pre><code> for (var i = 0; i < arrData.length; i++)
{
var thediv = $(".divDetails>.divRowData:first").clone().css('display','block');
var g = thediv.find(".spanColor").css('background-color', 'color'+i);
var g = thediv.find(".spanText").text(arrData[i].text);
thediv.appendTo(".divDetails");
}
</code></pre>
<p>How can I shorten this code ? </p>
<p><a href="http://jsbin.com/etudak/1/edit" rel="nofollow">http://jsbin.com/etudak/1/edit</a></p>
<p><sub>I know I can use templates but that's another story.</sub></p>
| javascript jquery | [3, 5] |
4,491,487 | 4,491,488 | Android AsyncTaskLoader doesn't start loadInBackground? | <p>I am trying to implement a loader example on Android but can't get it to start the loader. I am using the following code. It will hit the "Create Loader" but it will never reach the "Loading started" log message. Am I missing a call that I need?</p>
<p>Activity:</p>
<pre><code> public class TestingZoneActivity extends ListActivity implements LoaderCallbacks<ArrayList<Content>>{
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
getLoaderManager().initLoader(0, null, this);
}
@Override
public Loader<ArrayList<Content>> onCreateLoader(int id, Bundle args) {
Log.e("TEST", "Create Loader");
return new ImageLoader(this);
}
@Override
public void onLoadFinished(Loader<ArrayList<Content>> loader, ArrayList<Content> data) {
setListAdapter(new ImageAdapter(this, data));
}
@Override
public void onLoaderReset(Loader<ArrayList<Content>> loader) {
setListAdapter(null);
}
}
</code></pre>
<p>Loader:</p>
<pre><code> public class ImageLoader extends AsyncTaskLoader<ArrayList<Content>> {
public ImageLoader(Context context) {
super(context);
}
@Override
public ArrayList<Content> loadInBackground() {
Log.e("TEST", "Loading started");
}
}
</code></pre>
| java android | [1, 4] |
832,133 | 832,134 | Android Search Dialog soft keyboard stays open for too long | <p>I'm trying to use Android's built-in <a href="http://developer.android.com/guide/topics/search/search-dialog.html" rel="nofollow">Search Dialog</a>, and it's working fine except when I try to use it with a <a href="http://developer.android.com/reference/android/app/ProgressDialog.html" rel="nofollow">ProgressDialog</a>. The basic chain of events it his:</p>
<ol>
<li>User press the search button, enters a query and submits it.</li>
<li>The SearchManager calls the search Activity's onCreate method.</li>
<li>In the onCreate method, I call an AsyncTask that runs a query and shows a ProgressDialog in the onPreExecute method and hides it in the onPostExecute method.</li>
</ol>
<p>This all happens fine except as soon as I submit the query the screen looks like this:</p>
<p><img src="http://i.stack.imgur.com/Qwvkh.png" alt="enter image description here"></p>
<p>... which is pretty ugly. How can I prevent this from happening? </p>
<p><a href="http://code.google.com/p/mediawikiprovider/source/browse/#hg%2Fsrc%2Forg%2Fcdmckay%2Fandroid%2Fprovider%2Fdemo" rel="nofollow">You can find the source code for the project at Google Code.</a></p>
| java android | [1, 4] |
711,077 | 711,078 | get the last value of an object Javascript or jQuery | <p>I have an object which I'm trying to get the last value of every key and put it into another object. </p>
<pre><code>var setA = {
'a':'001, 007, 101',
'b':'052, 004, 006, 005',
'c':'003, 002, 001'
}
</code></pre>
<p>What I'm trying to do is get the last ones like this:</p>
<pre><code>var setB = {
'a':'101',
'b':'005',
'c':'001'
}
</code></pre>
<p>How might I accomplish this?</p>
| javascript jquery | [3, 5] |
5,737,765 | 5,737,766 | iPhone save game state | <p>I'm implementing a save game feature to my game, so I'm looking for the best way to store the saved game.</p>
<p>Since I'm using C++ everywhere it's possible, I can't use NSKeyedArchiver to store the state of the game.
I am thinking in saving the state manually in a file, so I have a questions about that:</p>
<p>In which subfolder of apphome should I save that file? Looking into the <a href="http://developer.apple.com/library/ios/#documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/RuntimeEnvironment/RuntimeEnvironment.html" rel="nofollow">iOS Programming Guide</a> I didn't found a folder that perfeclty fit that need. Should I create a custom subfolder in Library or am I missing something?</p>
<p>Thanks in advance</p>
| iphone c++ | [8, 6] |
4,927,604 | 4,927,605 | Assigning clicked element's ID as classname to another element | <p>I am working on a project but the code that I wrote is really wrong:</p>
<pre><code>$('#lart').click(function(){
$("#form3").addClass("lart");
});
$('#posht').click(function(){
$("#form3").addClass("posht");
});
$('#majt').click(function(){
$("#form3").addClass("majt");
});
$('#djatht').click(function(){
$("#form3").addClass("djatht");
});
</code></pre>
<p>I think about making it with switch statement but I dont know how to make the variable for the cases. The above code doesnt work properly because when I click more options then it adds more classes and I don't want it to add more classes, just one of them (lart,posht,djatht,majt).</p>
<p>what if I want it to have two pairs like just to change the lart with posht and majt with djatht, by the way this is the meaning of the ids: lart=up posht=down majt=left djatht=right so if I click the up button then I click right the class up with stay its just going to add 1 more class called right, or left! or if I click the down button then I will can change the right or left but it will be (down and left/right or up and left/right) is this possible?</p>
| javascript jquery | [3, 5] |
3,951,300 | 3,951,301 | To cache or not to cache $(this) in jQuery | <p>Does creating and reusing a reference increase performance appreciably when the selector is <code>$(this)</code>?</p>
<p>I create references for my jQuery selectors when I use the same selector multiple times in the same scope. The following is more efficient </p>
<pre><code> var jSel = $('div.some_class input.some_other_class');
some_function1(jSel);
some_function2(jSel);
</code></pre>
<p>than this</p>
<pre><code> some_function1($('div.some_class input.some_other_class'));
some_function2($('div.some_class input.some_other_class'));
</code></pre>
<p>But what if the selector is simply <code>$(this)</code> where <code>this</code> is a dom element inside a jQuery method. Should I bother to create a reference to <code>$(this)</code> and reuse the reference or can I create multiple <code>$(this)</code> selectors and expect similar performance?</p>
<p>Is the following </p>
<pre><code> var jSel = $(this);
some_function1(jSel);
some_function2(jSel);
</code></pre>
<p>significantly faster than the following?</p>
<pre><code> some_function1($(this));
some_function2($(this));
</code></pre>
| javascript jquery | [3, 5] |
3,993,269 | 3,993,270 | how to make an checkboxlist select only one item selected | <p>i am using an checkboslist binding to a datatable.
but here i need to make user select only one item selected from checkbox list
is there way we can aachive this</p>
<p>either JQuery, javascript, c#
thank you </p>
| asp.net jquery | [9, 5] |
2,469,101 | 2,469,102 | jQuery select list issue | <p>I have a code something like </p>
<pre><code> if($('#nodeNo').val() == null){
cityChange(1);
$('#nodeNo option[value=<%=request.getAttribute("nodeval")%>]').attr('selected','selected');
}
</code></pre>
<p>There is an Ajax call in cityChange(1) to populate the nodeNo select list and then the next statement sets the selected value. However due to parallel execution the above code doesn't work. The ajax call and setting the value executes together. The other Ajax call takes a bit time and by that time the next statement finishes execution. Hence the list is populated correctly but the selected value can't be set.</p>
<p>Pls Help!!</p>
| javascript jquery | [3, 5] |
479,081 | 479,082 | BIG Resource eater | <p>This script is eating up a lot of resource on my members computers. I have other interval scripts that don't eat up any resource. I've tried extending the time but that slows down the refresh. Any suggestions?</p>
<pre><code><script type="text/javascript">
$('document').ready(function(){
updatestatus();
scrollalert();
});
function updatestatus(){
//Show number of loaded items
var totalItems=$('#scontent p').length;
$('#status').text('Done');
}
function scrollalert(){
var scrolltop=$('#scrollbox').attr('scrollTop');
var scrollheight=$('#scrollbox').attr('scrollHeight');
var windowheight=$('#scrollbox').attr('clientHeight');
var scrolloffset=10;
if(scrolltop>=(scrollheight-(windowheight+scrolloffset)))
{
//fetch new items
$('#status').text('Loading more members...');
$.get('allonline.php', '', function(newitems){
$('#scontent').load('allonline.php');
updatestatus();
});
}
setTimeout('scrollalert();', 60000);
}
</script>
</code></pre>
| php jquery | [2, 5] |
1,006,711 | 1,006,712 | to perform validation for amout(price) in ASP.net | <p>I'm using 'Amount' as a column in my datatable for my application.</p>
<p>I want to perform the following validations w.r.t 'Amount' which is a string variable.</p>
<p>1) i want to check if the amount has more than 2 digits after the decimal point</p>
<p>2) if the amount is positive or negative .. (as in case of negative error message needs to be flashed)</p>
<p>Can u help in this with short and efficient code snippets ???</p>
<p>EDIT:</p>
<p>@Peter:</p>
<p>But checking digits after decimal shows error even for numbers of kind 1986, 200134
which are given as inputs...... what to do ?</p>
| c# asp.net | [0, 9] |
4,438,784 | 4,438,785 | How to active next & prev controls on Android Mediacontroller? | <p>I want to activate next and previous controls on Android Media controller in an android app.
I tried hard but still not achieve. How can i activate that controls? Any help will be appreciated.Code is:
MediaController mc = new MediaController(this);
mc.setPrevNextListeners(null, null);
vv.setMediaController(mc);</p>
<p>Where vv is object created.</p>
| java android | [1, 4] |
4,533,591 | 4,533,592 | delete table row | <p>I have a table like this:</p>
<pre><code><table>
<tr>
<td>foo</td>
<td><button>delete</delete></td>
</tr>
<tr>
<td>foo</td>
<td><button>delete</delete></td>
</tr>
</table>
</code></pre>
<p>I want to use JQuery to install a click handler on the delete buttons such that it deletes the current row when clicked</p>
| javascript jquery | [3, 5] |
5,361,033 | 5,361,034 | Trying to understand this code (pub/sub library) | <p>This is Peter Higgins's pub sub library: <a href="https://github.com/phiggins42/bloody-jquery-plugins/blob/master/pubsub.js" rel="nofollow">https://github.com/phiggins42/bloody-jquery-plugins/blob/master/pubsub.js</a></p>
<pre><code>(function (d) {
var cache = {};
d.publish = function (topic, args) {
cache[topic] && d.each(cache[topic], function () {
this.apply(d, args || []);
});
};
d.subscribe = function (topic, callback) {
if (!cache[topic]) {
cache[topic] = [];
}
cache[topic].push(callback);
return [topic, callback];
};
d.unsubscribe = function (handle) {
var t = handle[0];
cache[t] && d.each(cache[t], function (idx) {
if (this == handle[1]) {
cache[t].splice(idx, 1);
}
});
};
})(jQuery);
</code></pre>
<p>I don't understand the logic and the functionality of <code>publish</code>:</p>
<pre><code>cache[topic] && d.each(cache[topic], function () {
**this.apply(d, args || []);** //what is happening here?
});
</code></pre>
<p>What is the purpose of this part? except the fact that it publishes the event</p>
| javascript jquery | [3, 5] |
3,591,980 | 3,591,981 | insert html content inside a class in jquery | <p>I am using jquery to insert html content like,</p>
<pre><code>$.get("_html/saveme.html", function(data){
$(".saveWin .modalCSS").html(data); //Error here
});
</code></pre>
<p>In Firefox it is giving me error as,</p>
<pre><code>Node cannot be inserted at the specified point in the hierarchy
</code></pre>
<p>In IE it is working fine.
Please suggest me, are there any other ways to call class inside a class and insert html content.</p>
<p>Thanks in advance</p>
| javascript jquery | [3, 5] |
5,159,355 | 5,159,356 | Store queue of strings in javascript/jQuery | <p>I am writing an application using jQuery (with the jPlayer plugin) that needs to store a queue of songs to play. I plan to just simply store the strings of the song names in the queue... is there a really good, simple queue implementation in javascript that anyone would recommend? jQuery's queue doesn't seem to be what I want since it deals with functions, which is way more complicated than I need.</p>
<p>Thanks</p>
| javascript jquery | [3, 5] |
3,032,682 | 3,032,683 | How to determine which enemy is hit and destroy it alone | <p><a href="http://jsfiddle.net/5DB6K/" rel="nofollow">http://jsfiddle.net/5DB6K/</a></p>
<p>I have this game being made where you shoot enemies from the sides of the screen. I've got the bullets moving and being removed when they reach the end of the screen (if they didn't hit any enemy) and removing the enemy when they collide with it. </p>
<pre><code>//------------collision----------------//
if(shot === true){
bulletY = $('.bullet').position().top + 2;
bulletX = $('.bullet').position().left + 2;
$('.enemy').each(function(){
if($('.enemy').hasClass('smallEnemy')){
enemyY = $(this).position().top + 7;
enemyX = $(this).position().left + 7;
if(Math.abs(bulletY - enemyY) <= 9 && Math.abs(bulletX - enemyX) <=9){
$(this).remove();
score = score + 40;
bulletDestroy();
}
}
});
}
</code></pre>
<p>However, the bullet destroys every enemy if the collision check is right which isn't what I want. I want to check if the enemy has the class of either smallEnemy, medEnemy, or lrgEnemy and then do the collision check which is what I thought I had but it doesn't seem to work. </p>
<p>Also, the game starts to lag the more and more time goes on. Would anyone know the reason for that?</p>
| javascript jquery | [3, 5] |
2,386,418 | 2,386,419 | jquery stopPropagation() and sending "event"? | <p><a href="http://jsbin.com/imager/2/edit" rel="nofollow"><strong>(jsbin)</strong></a></p>
<p>I created a table with a button inside.</p>
<p><img src="http://i.stack.imgur.com/x6GEF.jpg" alt="enter image description here"></p>
<p>The Table has <code>onclick</code> event and also the inside Button</p>
<p>But when Im pressing the button ,the event bubbles up to the table. ( and I get 2 alerts)</p>
<p>So I used <code>ev.stopPropagation();</code></p>
<p>And its working. But in order for it to work , I had to do : </p>
<p>in html : </p>
<pre><code><input type='button' onclick='doWork(event);'/>
</code></pre>
<p>in Js :</p>
<pre><code>function doWork(ev)
{
ev.stopPropagation();
alert('button');
}
</code></pre>
<ul>
<li>Is this the correct way ? </li>
<li><strong>Must</strong> I send the event ? I know that different browsers uses differently the <code>event</code> .</li>
</ul>
| javascript jquery | [3, 5] |
2,425,069 | 2,425,070 | How to replace a page by date | <p>There is way to replace page at some date&time ?</p>
<p>example: i want that at friday the default.aspx will down, and other page will turn to default.aspx... and then at sunday the first default.aspx will return.</p>
<p>someone have an idea? maybe will be better to change the display of the default.aspx. i need to replace the screen to "we down for a while" or something like that.</p>
<p>i mean that button will do that... </p>
<p>using c#. asp.net</p>
| c# asp.net | [0, 9] |
2,887,339 | 2,887,340 | Trying to make a div appear in the centre of a scrollable page - bug in my code? | <p>Just as a preface to make sure I am clear, I don't want the div to appear dead centre in the middle of the page, I want it in the middle of the viewable window. So if you imagine a long page and the user has scrolled down to near the bottom and clicks the button the div will appear in the centre of the screen near the bottom of the page.</p>
<p>here is my code, which doesn't work in chrome:</p>
<pre><code> function centerdiv() {
var scrolledX, scrolledY;
scrolledX = document.body.scrollLeft;
scrolledY = document.body.scrolltop;
var centerX, centerY;
centerX = document.body.clientWidth;
centerY = document.body.clientHeight;
var leftoffset = scrolledX + (centerX - 100) / 2;
var topoffset = scrolledY + (centerY - 100) / 2;
$('.current div[name="popup"]').css({'top' : topoffset + 'px', 'left':
leftoffset + 'px'});}
$(function() {
$("html").ajaxStart(function() {
centerdiv();
$(".current div[name=popup]").show();
});
$("html").ajaxComplete(function() {
$(".current div[name=popup]").hide();
});
});
</code></pre>
<p>Note, this is for an iphone mobile website and the ajaxstart function attaching to the html is crucial as it doesn't work on the iphone any other way on my website.</p>
| javascript jquery | [3, 5] |
3,815,644 | 3,815,645 | How to get attributes of container in jquery? | <p>How can I get attributes values from an container using jquery ?</p>
<p>For example:</p>
<p>I have container div as:</p>
<pre><code><div id = "zone-2fPromotion-2f" class = "promotion">
</code></pre>
<p>here how can I get attribute id value using jquery and than how can I trim the value to get component information ?</p>
<p>update : how can i get attribute values ?</p>
<p><strong>UPDATE</strong>: If I have multiple components on page with same div information than how would I know what attribute value is for which component ?</p>
<p>Thanks. </p>
| javascript jquery | [3, 5] |
1,812,951 | 1,812,952 | Passing 'this' as parameter in JavaScript | <p>I have the following code:</p>
<p><strong>HTML:</strong></p>
<pre><code><label id="copyAddress" class="copyAddress" onclick="CopyAddress(this);">
Copy Address
</label>
</code></pre>
<p><strong>JS:</strong></p>
<pre><code>function CopyAddress(copyAddressLink) {
PopulateTarget(copyAddressLink);
}
function PopulateTarget(link) {
var targetGroup = $(link).closest('someClass');
}
</code></pre>
<p>In PopulateTarget function 'link' variable is undefined, while in CopyAddress it has values as is should. </p>
<p>What can cause this problem? Is there some restriction for passing parameters in Java Script? How this should behave? If you need more code to post please tell me.</p>
| javascript jquery | [3, 5] |
1,683,583 | 1,683,584 | What is the Java equivalent for the following C# code? | <p>I have an interesting question. I understand the following C# code enables users to input null values in parameters:</p>
<pre><code>public DateTime? date (DateTime dt) {}
</code></pre>
<p>What is the equivalent when coding in Java?</p>
| c# java | [0, 1] |
1,890,596 | 1,890,597 | refreshing views of Preferences when using PreferenceActivity | <p>I'm trying to force <code>PreferenceActivity</code> to refresh. Does anyone know how to do this?</p>
<p>I have a <code>ResetDefaultsPreference</code> class that subclasses <code>Preference</code> and, when clicked, is supposed to reset to defaults all preferences whose keys start with a certain prefix. It works, but when I hit the reset preference, none of the preferences in that screen update until I back out of the screen and go back in. (That works for some custom color preferences, but even that doesn't work for some <code>ListPreference</code>s - for those I have to leave and re-enter the <code>PreferenceActivity</code> itself for the updated values to be shown.)</p>
<p>I tried to fix this by getting the root view and <code>invalidate()</code>ing it, but that doesn't seem to work. Here's the line to refresh the display. It's in part of a <code>Preference</code> subclass that keeps the <code>Context</code> it was created with in <code>mContext</code>.</p>
<pre><code>((Activity)mContext).findViewById(android.R.id.content).invalidate();
</code></pre>
<p>This happens after the preference values have been changed and committed. (The values change, but the display doesn't.) Does anyone know how I can force PreferenceActivity to refresh itself?</p>
| java android | [1, 4] |
5,036,220 | 5,036,221 | Set Value of a Dynamically Generated DropDown | <p>I have a dropdown menu that gets automatically populated. I need to set its selected value to a certain option whose ID is being passed in. This code seems to work with dropdowns that were created on page load:</p>
<pre><code> $('select[id$=DropDown1] option').each(function (index) {
if ($(this).val() == _PassedInValue) {
$(this).parent().val($(this).val())
}
})
</code></pre>
<p>But, it doesn't seem to work with dynamically generated content. Is there something I am missing or is there another way to approach this?</p>
| javascript jquery | [3, 5] |
1,305,843 | 1,305,844 | any website monitoring library/modules to use in my website? | <p>I'm trying to build a site which user can add their websites which should be monitored and can view a detailed report and statistics of it. And also it should be able to monitor local webservices (mainly), </p>
<p>1) is there any popular java library to use for monitoring a website? (in sense to ping a website and load some content etc., or to show whether site is up or not kinda) </p>
<p>2) Also to validate a flow of website (if possible)?<br>
Example: Go to login page, find fields , fill fields and submit form and validate for successful login or not.</p>
<p>I know this kinda looks big but any small part done can be helpful, I've found several of monitoring projects, but they only do normal websites but not local/other webservices and also they can't validate flow of website.</p>
| java javascript | [1, 3] |
316,730 | 316,731 | Master page - Only one instance of a ScriptManager can be added to the page | <p>I am using ajax toolkit in my project. My project is having a master page and i am inheriting this master page in my web pages.I am using Script manager on every page but now requirement came to display a real time clock also on the master page.I had written the code using Timer to display real time clock on master page but i am getting error "Only one instance of a ScriptManager can be added to the page. ".</p>
<p>How to fix this problem as i don't want to remove script manager from the webpages.</p>
| c# asp.net | [0, 9] |
2,331,276 | 2,331,277 | foreach not initialising the loop variable | <p>I'm using a foreach to loop through an IList of objects in a Partial View in ASP.NET MVC.</p>
<p>Here's the entire code (Message is one of my classes from the Model).</p>
<pre><code><%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<IList<Message>>" %>
<%
if (ViewData.Model.Count > 0)
{
foreach (MvcTest.Models.Message m in ViewData.Model)
{
Response.Write(m.RenderHtml());
}
}
%>
</code></pre>
<p>For some reason, this generates a CS0165 on the ResponseWrite - complaining that m may not be initialised.</p>
<p>I rewrote it like this:</p>
<pre><code><%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<IList<Message>>" %>
<%
//Can't see why I have to declare this as a variable, but I get CS0165 if I use ViewData.Model directly in the foreach
IList<MvcTest.Models.Message> messages = ViewData.Model;
if (messages.Count > 0)
{
foreach (MvcTest.Models.Message m in messages)
{
Response.Write(m.RenderHtml());
}
}
%>
</code></pre>
<p>ie explicitly declaring a variable for the IList rather than just using the (strongly-typed) Model, and it works fine.</p>
<p>Can anyone explain why what I did fixes the problem?</p>
| c# asp.net | [0, 9] |
1,446,652 | 1,446,653 | jQuery index of dom element? | <p>I have...</p>
<pre><code>element = document.elementFromPoint(x, y)
</code></pre>
<p>then I want to do something like...</p>
<pre><code>index = $(element).index()
</code></pre>
<p>The DOM element is a <code>li</code> and I need its position in the list. </p>
<p>Thanks!</p>
<p>EDIT: If what i'm doing is correct then something here is wrong, <a href="http://stackoverflow.com/questions/7814550/touch-events-over-two-divs/7814791">Touch events over two dom elements?</a></p>
<p>Any help is much appreciated.</p>
| javascript jquery | [3, 5] |
4,250,582 | 4,250,583 | Display a string for each day of the year | <p>I want to play around with making an Android app that displays a famous quote of the day. So I will have 365 quotes and each day will display a new one. Any thoughts on how to accomplish this? Do I need 365 @strings in my <code>string.xml</code> file? Is there a way to access an array of strings (or another data structure perhaps) by their index to accomplish this?</p>
| java android | [1, 4] |
3,905,706 | 3,905,707 | How to enable a linkbutton server control using javascript? | <p>I have a linkbutton server control in my page whose Enabled attribute is initially set to "false". When a text box's text changes I would like to enable the linkbutton. I tried the following but it does not work. Could you let me know if i am missing something.</p>
<pre><code>function TextBox_TextChanged()
{
var control = $get("<%= linkButtonSave.ClientID%>");
if(control != null)
control.enabled = true;
}
</code></pre>
<p>Thanks</p>
| asp.net javascript | [9, 3] |
5,489,053 | 5,489,054 | jquery - reveal answer in definition list | <p>I have an FAQ page that looks like the markup shown below</p>
<p>When the page loads I'd like to reveal the answer that corresponds to the bookmark in the URL</p>
<p>The url will be of the form www.mydomain.com/page#q1</p>
<p>I am trying to do it like this but it wont't work - any ideas how to fix it?</p>
<pre><code>console.log($(hash).length)
</code></pre>
<p>does have a length of 1 so it is selecting a dom element</p>
<p>And I have used the same functionality to reveal it on click further down the script - and tht works OK</p>
<pre><code>$(function () {
var hash = window.location.hash;
//hash = hash.replace('#', '');
console.log('hash:' + hash);
console.log($(hash).length);
$(hash)
.parent()
.parent()
.find("dd.answer")
.slideToggle();
$("dd.answer")
.hide();
$("dt.question")
.click(function () {
$(this)
.parent()
.find("dd.answer")
.slideToggle();
});
});
<dl>
<dt class="question">
<a id="q1"></a>
Question 1
<dd class="answer" style="display: none;">
Answer 1
</dd>
</dl>
<dl>
<dt class="question">
<a id="q2"></a>
Question 2
<dd class="answer" style="display: none;">
Answer 2
</dd>
</dl>
<dl>
<dt class="question">
<a id="q3"></a>
Question 3
<dd class="answer" style="display: none;">
Answer 3
</dd>
</dl>
</code></pre>
| javascript jquery | [3, 5] |
3,031,879 | 3,031,880 | save the user name in session from the login page | <p>Can I ask you guys here, how to create session from login page? I want to make an edit page which user can view only their data in the gridview so they need to call the username session in order to retrieve only their records in db. If you guys have any doubts regarding to my question, pls ask me. Thank you.</p>
| c# asp.net | [0, 9] |
2,273,718 | 2,273,719 | Find a string after a special character, move it and wrap a div around it | <p>I have this HTML code, for example:</p>
<pre><code><div class="new">
<div class="in"></div>
<label>some text now watch this | the-thing</label>
</div>
</code></pre>
<p>I want to:</p>
<ol>
<li>find the text thats after the "|" charecter</li>
<li>move it outside the label</li>
<li>wrap a span tag around it</li>
</ol>
<p>i know how to do the 2nd and 3rd part, but i dont understand how to manipulate the string to begin with</p>
<p>thanks in advance</p>
| javascript jquery | [3, 5] |
957,041 | 957,042 | wp_register_script Question | <p>I need to add the following JS to the head, but I don't know how to add the "data-cfasync="false" " by using "wp_register_script" or "wp_enqueue_scripts". Please help!!</p>
<pre><code><script data-cfasync="false" type="text/javascript" src="http://use.typekit.com/YOUR-KIT-ID.js"></script>
<script data-cfasync="false" type="text/javascript">try{Typekit.load();}catch(e){}</script>
</code></pre>
| jquery javascript | [5, 3] |
5,980,267 | 5,980,268 | What is the best gaming framework for android and iphone | <p>What is the best gaming framework that can I use for both android and iPhone ?? </p>
| android iphone | [4, 8] |
5,358,118 | 5,358,119 | Select element(s) without specific element | <p>Hi this is my problem:</p>
<pre><code><ul>
<li><span class="show">*</span>Show</li>
<li><span class="show">*</span>Show</li>
<li><span class="show">*</span>Show</li>
<li><span class="show">*</span>Show</li>
<li>Hide</li>
<li>Hide</li>
</ul>
</code></pre>
<p>So oposite of this <a href="http://jsfiddle.net/ajitam/GqCpW/" rel="nofollow">http://jsfiddle.net/ajitam/GqCpW/</a></p>
<p>How can I select (with jQuery) 'li's without span.show inside.</p>
<p>thank you</p>
| javascript jquery | [3, 5] |
3,834,682 | 3,834,683 | Can anyone tell me what's wrong with this script? | <p>The script is working just fine but IE is giving me the error "Done but with errors on page" and I can't figure out why.</p>
<pre><code>(function($){
$.fn.extend({
tabify: function() {
function getHref(el){
hash = $(el).find('a').attr('href');
if(hash)
return hash.substring(0,hash.length-4);
else
return false;
}
function setActive(el){
$(el).addClass('active');
if(getHref(el))
$(getHref(el)).show();
else
return false;
$(el).siblings('li').each(function(){
$(this).removeClass('active');
$(getHref(this)).hide();
});
}
return this.each(function() {
var self = this;
$(this).find('li>a').each(function(){
$(this).attr('href',$(this).attr('href') + '-tab');
});
function handleHash(){
if(location.hash)
setActive($(self).find('a[href=' + location.hash + ']').parent());
}
if(location.hash)
handleHash();
setInterval(handleHash,100);
$(this).find('li').each(function(){
if($(this).hasClass('active'))
$(getHref(this)).show();
else
$(getHref(this)).hide();
});
});
}
});
})(jQuery);
</code></pre>
| javascript jquery | [3, 5] |
1,122,366 | 1,122,367 | Creating a google plus / digg like social bookmark button | <p>For a client of ours we need to create a share button for his site so that the users of his site can add this button to their blogs / sites and others can click on it and it will just open up a popup asking the user to login (if already logged in, the link bookmark page appears) to the clients site and bookmark it. Can somebody guide me on how to do it with php and javascript?</p>
| php javascript | [2, 3] |
5,562,775 | 5,562,776 | How to clone element with new id? | <p>I have some elements on the page. Here is example of one element:</p>
<pre><code><div id="119" class="message">
<div class="messageAuthor">iggy</div>
<div class="messageBody messageMessage">hello</div>
<div class="messageDate messageCreate_date">12:13</div>
</div>
</code></pre>
<p>I get from server new items and items which were updated in JSON. Here is example of using JSON response:</p>
<pre><code>$.each(ajaxResult.items, function(index) {
for (var key in ajaxResult.items[index]) {
if (ajaxResult.items[index].hasOwnProperty(key)) {
if ($('.'+ajaxResult.controller + self.toUpperFirst(key)).length) {
if ($('#'+ajaxResult.items[index].id).length) {
$('#'+ajaxResult.items[index].id).children('.'+ajaxResult.controller + self.toUpperFirst(key)).text(ajaxResult.items[index][key]);
}
else {
var prevIndex = parseInt(index) - 1;
$('#'+ajaxResult.items[prevIndex].id).after($('#'+ajaxResult.items[prevIndex].id).html());
}
}
}
}
});
</code></pre>
<p>I want to add new elements after existing elements. I don't know what the best way to do it. I need help.</p>
| javascript jquery | [3, 5] |
1,377,343 | 1,377,344 | Displaying number of days in form field depending on month | <p>I want to validate the basic date format in the form. The date has three fields in form, Month, Day and Year. I want to make it so that, if a month January, March, May, July, August, October or December is selected then it should display 31 days in the day field. If february is selected, then it should display 28 days, otherwise 30 days.
Also, If someone selects day before the month and then selects the month, then it should reset the selected day to 1.
Here's my form code. I shall be very thankful for any help.</p>
<pre><code><?php
$monthOptions = '';
$dayOptions = '';
$yearOptions = '';
for($month=1; $month<=12; $month++){
$monthName = date("M", mktime(0, 0, 0, $month));
$monthOptions .= "<option value=\"$month\">$monthName</option>\n";
}
for($day=1; $day<=31; $day++){
$dayOptions .= "<option value=\"$day\">$day</option>\n";
}
for($year=1900; $year<=2010; $year++){
$yearOptions .= "<option value=\"$year\">$year</option>\n";
}
?>
<html>
<body>
Select date:<br />
<select name="month" id="month" >
<?php echo $monthOptions; ?>
</select>
<select name="day" id="day">
<?php echo $dayOptions; ?>
</select>
<select name="year" id="year" >
<?php echo $yearOptions; ?>
</select>
</body>
</html>
</code></pre>
| javascript jquery | [3, 5] |
598,739 | 598,740 | Execute function every nth second | <p>Total JavaScript n00b question right here:</p>
<p>I've made this snippet that clicks a link after 10th second:</p>
<pre><code>function timeout() {
window.setTimeout(function() {
$('img.left').click();
}, 1000);
setTimeout("timeout()", 1000);
}
timeout();
</code></pre>
<p>My question is, how do I execute this function every 10th second, instead of just once?</p>
<p>Is this the best way to do this, or is there some kind of nifty jQuery method that you prefer?</p>
| javascript jquery | [3, 5] |
2,894,533 | 2,894,534 | jQuery: Issue Using Bind & Click Methods | <p>Any idea why this click event isn't working? (I'm sure the answer is obvious - I'm just not seeing it).</p>
<pre><code><html>
<head>
<title></title>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('h1').bind('click', function(){
alert('clicked');
});
)};
</script>
</head>
<body>
<h1>This is a test.</h1>
</body>
</html>
</code></pre>
<p>EDIT: @Stefan: thanks for catching this typo. I need to remember to have firebug open next time. Thanks for suggesting jsfiddle.net. Looks like a cool site.</p>
| javascript jquery | [3, 5] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.