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
4,869,180
4,869,181
How can I set up a $.fn. function so it gets executed when called?
<p>I have the following code:</p> <pre><code> function init() { var $contentButtonPanel: JQuery = $('#content-button-panel') $contentButtonPanel .find('.arbo .toggle, .collapsible-list li:has(ul) &gt; :first-child, .collapsible-list li:has(ul) &gt; :first-child + span') .click(function (event) { $(this).toggleBranchOpen(); }); } $.fn.toggleBranchOpen = function () { this.each(function () { $(this).closest('li').toggleClass('closed'); }); return this; }; </code></pre> <p>When I debug I can see that the $(this).toggleBranchOpen(); line is reached. However the code does not go inside that function. </p> <p>Is this a problem with the way that toggleBranchOpen is declared? Note that the only time toggleBranchOpen is used is inside of the init function click event. Is it possible for me to move that code into the init and simplify things?</p>
javascript jquery
[3, 5]
5,661,616
5,661,617
jquery to color code text
<p>I give php code examples on my site and was wondering if their was a way I could colour code them so that it is easier to read like an IDE would do. I always display the code in a div with a class of code and then in pre tags. See my example below.</p> <pre><code>&lt;div class="code"&gt; &lt;pre&gt; &lt;?php echo 'hello world'; ?&gt; &lt;/pre&gt; &lt;/div&gt; </code></pre> <p>I was wondering if there was a way to do it with jQuery like in a sort of string match way. So give jquery an array of strings that should be blue for example, and then jQuery would look through the code blocks and any words that match it adds a class of blue to them or something? Anyone know of how I would achieve this? Maybe there is a much simpler way already? </p> <p>Thanks</p>
php jquery
[2, 5]
3,126,436
3,126,437
ASP.NET - Are there any advantages or differences in using (Type)Container.DataItem and Eval() within Server tags?
<p>Are there any advantages or differences between using the following?</p> <pre><code>&lt;%# Eval("Item.Details")%&gt; </code></pre> <p>and <code>&lt;%# ((ItemDetails)Container.DataItem).Item.Details%&gt;</code></p>
c# asp.net
[0, 9]
3,069,874
3,069,875
Client side & server side at the same event (onselectedindexchanged)
<p>I have this drop down list. is it possible to call a javascript function and the server side function at the same time from the onselectedindexchanged event?</p> <pre><code>&lt;asp:DropDownList ID="drpPartGroup" runat="server" Height="19px" Width="169px" AutoPostBack="True" onselectedindexchanged="drpPartGroup_SelectedIndexChanged"&gt; &lt;/asp:DropDownList&gt; </code></pre> <p>Thanks.</p>
javascript asp.net
[3, 9]
1,201,576
1,201,577
Generate Dynamic Pages With ASP.Net
<p>I am currently programming classic asp and have my own CMS and it's a good one but I'd like to move it to c#.net meanwhile. (customers don't like this old language anymore) on my current CMS I generate Pages physically with ASP FSO(filesystem object). so my question is should i use this method at asp.net too? I reviewed some .NET cms and realized that they don't build pages physically.</p> <p>For example after working with a CMS noticed that When I type <a href="http://localhost/PageName.aspx" rel="nofollow">http://localhost/PageName.aspx</a> in address bar actually it's still in default.aspx but it regenerated page with contents that belong to PageName.aspx's PageID at database.</p>
c# asp.net
[0, 9]
1,567,219
1,567,220
jQuery trim and remove on parent break child events
<p>Note: I have a workaround to this problem, but I'd prefer to comma-separate the values as I describe below rather than separating them with spaces (which is what my workaround does).</p> <p>I have an ASP.NET website that allows instructors to choose from a DropDownList of preset comments and apply these comments to students in their classes. I display the students and comments inside a GridView, and use a Label to display any comments that already exist in the database (removing them from the DropDownList in the process). When an instructor selects one of these comments and clicks a button, my jQuery function:</p> <ol> <li>Pulls the selected value and text out of the option (provided it isn't the default option).</li> <li>Checks Label.children().length, and appends a ", " to the text if it's greater than zero.</li> <li>Creates a <code>&lt;span&gt;</code> tag with a hidden field containing the value and text.</li> <li>Appends the text inside the span.</li> <li>Closes the span.</li> <li>Attaches an onclick event to the span.</li> <li>Removes the original option from the DropDownList.</li> </ol> <p>The span tag's onclick event does the reverse of what I describe above -- it pulls the value and text out and re-creates the option inside the drop-down menu. Additionally, it replaces strings like ", , " with ", " in the parent Label. I've found that when I replace these strings (which lie outside the spans I've attached the onclick events to) that the onclick events go away.</p> <p>I'm familiar with .live(), but because each row in this GridView contains a unique reference to the particular student and class currently in use, I can't know the values that each row needs to pass into the funciton ahead of time. Is there any solution to this problem other than my described workaround or re-attaching the onclick event?</p>
javascript jquery
[3, 5]
1,208,244
1,208,245
Problems with ImageHandler
<p>I have problem with calling ImageHandler..in asp i add imageurl like this:</p> <pre> ImageUrl= "~/DesktopModules/Philip.E1013542_skupine/Handler.ashx?id=62" </pre> <p>This shows picture in asp:image control. But i would like to retrieve id integer from query string like this:</p> <p>.../Default.aspx?id=62</p> <p>I tryed like this <code>'&lt;% "~/DesktopModules/Philip.E1013542_skupine/Handler.ashx?id=" &amp; Eval("id") %&gt;'</code></p> <p>but this doesn't calls handler at all..tryed with breakpoints and nothing.</p> <p>What am i doing wrong?</p>
c# asp.net
[0, 9]
5,896,643
5,896,644
Small riddle: Why this isn't working on Chrome?
<p>Any ideas on why the following code perfectly 'posts' when using FF (I can see the DB updated) but fails on Chrome?</p> <pre><code> $("a").click(function() { $.post("ajax/update_count.php", {site: 'http://mysite.com'}); }); </code></pre> <p>Tip: jQuery version is <code>jquery-1.4.3.min.js</code></p> <p><em><strong>Update</em></strong></p> <p>The issue seems to be that when the link is clicked, a new page is loaded, which seems to be stopping the post in Chrome... Is that a possible explanation? If so, what can I do?</p>
javascript jquery
[3, 5]
3,372,099
3,372,100
Fight theft of plugin by sending parameters with AJAX callback
<p>I have built a new jQuery plugin and I want to be able to demo this to the user before they can purchase this. But I also don't want anybody to be able to simple copy the code without paying for it. </p> <p>For that reason I have encoded the plugin using <a href="http://www.vincentcheung.ca/jsencryption/" rel="nofollow">http://www.vincentcheung.ca/jsencryption/</a></p> <p>I thought of 2 ideas to further protect/make it harder to copy:</p> <ul> <li>Hard code the domain name check against <code>window.location.hostname</code></li> <li>Using AJAX send as much information about the website back to a PHP script on my server. </li> </ul> <p>What extra information can be fetch using Javascript apart from the domain name. E.g. PHP you have the $_SERVER[]. </p> <p>Do you have any ideas to protecting it further?</p> <p>Ok I just have just wrote this myself and this, seems to work on two different domains. </p> <pre><code>$.ajax({ url: 'http://example.co.uk/record.php', type: 'post', data: 'href='+document.location.href + '&amp;referrer='+document.referrer }); </code></pre> <p>Record.php</p> <pre><code>mysql_query("INSERT INTO `demo` (`id` ,`datetime` ,`href` ,`referrer`)VALUES (NULL ,CURRENT_TIMESTAMP , '".$_POST['href']."', '".$_POST['referrer']."')"); </code></pre>
javascript jquery
[3, 5]
1,320,343
1,320,344
Jquery methods?
<p>I keep seeing codes like this:</p> <pre><code> $(document.documentElement).keyup( function(event) { var slides = $('#slides .pagination li'), current = slides.filter('.current'); switch( event.keyCode ) { case 37: // Left arrow if ( slides.filter(':first').is( current ) ) { slides.filter(':last').find('a').click(); } else { slides.eq( slides.index(current) - 1 ).find('a').click(); } break; case 39: // Right arrow if ( slides.filter(':last').is( current ) ) { slides.filter(':first').find('a').click(); } else { current.find('+ li').filter(':first').find('a').click(); } break; } }); </code></pre> <p>For a line like this: <code>current = slides.filter('.current');</code>, <code>.filter()</code> is a jquery method, right? Then shouldn't it be <code>current = $(slides).filter('.current');</code>. </p> <p>Does it work the way it is done in the code? Why?</p>
javascript jquery
[3, 5]
5,961,719
5,961,720
loop in object array element jquery
<p>Hello i'm using map() jquery to create a new object array <a href="http://jsfiddle.net/minagabriel/BKDLt/" rel="nofollow">DEMO</a> but this code is not working </p> <p>i need to have a new object array with the same name for all objects but with different number so how can we point over each element in the old array and change its value , i used <code>value[0].number</code> but it didn't do the trick </p> <p><strong>CODE</strong> </p> <pre><code> var x =[ {name : 'mark' , number : '10'}, {name : 'mina' , number : '15' } , ]; var newObject = $.map(x,function(value,index){ value.name = 'mon'; value[0].number = 12 ; value[1].number = 11 ; return value ; }); console.log(newObject) ; </code></pre> <p>​ <strong>Question</strong> is how can i point to each number in the old object array and change it </p>
javascript jquery
[3, 5]
1,216,033
1,216,034
What does "a." mean in this snippet of Javascript?
<p>In the Javascript below, what does the <code>a.</code> before the <code>cell1</code> signify?</p> <pre><code>&lt;script type='text/javascript'&gt; $(function(){ $("a.cell1").click(function(){ </code></pre> <hr> <p>EDIT: Thanks for the answers. Would it work if I did this to the Facebook Like button:</p> <pre><code>&lt;fb:like href="" class="cell1" send="true" layout="button_count" width="450" show_faces="false" font="arial"&gt;&lt;/fb:like&gt; </code></pre>
javascript jquery
[3, 5]
31,950
31,951
Best way to fill textbox with list of values by double click using java script or jquery?
<p>I need to fill a textbox with list of values just by double click on it using java script or j query?</p> <p>Eg:- I have a list of 10 users and i want to fill a textbox control like a dropdownlist just by clicking on it using java script or j query.</p> <p>Is it possible than how?</p>
javascript jquery
[3, 5]
1,373,347
1,373,348
Jquery watch certain fields for certain values
<p>I have some test code here</p> <pre><code>&lt;input type="radio" name="group1"&gt;1 &lt;input type="radio" name="group1"&gt;2 &lt;input type="radio" name="group1"&gt;3 &lt;br&gt; &lt;input type="text" name="text1"&gt; &lt;br&gt; &lt;input type="radio" name="group2"&gt;1 &lt;input type="radio" name="group2"&gt;2 &lt;input type="radio" name="group2"&gt;3 &lt;br&gt; &lt;input disabled type="submit"&gt; </code></pre> <p>Please can you tell me if there is a way to watch multiple fields so that if their values changes i can enable a button..</p> <p>So in short instead of having 3 .change rules watching each other... can't i do one piece of code that watches all 3 and if the values equals a particular something it enables the submit button ?</p> <p>Thanks</p> <p>Lee</p>
javascript jquery
[3, 5]
5,115,323
5,115,324
javascript parseFloat can't determine if the input is float or not
<p>I am new to javascript and php and programming so pls bear with me.</p> <p>I am trying to create javascript function to check if the user enters a float value or not. The event is keypressed so it will check every character.</p> <p>What happens is that if the first character is a float it say its float for the rest of the input even if the following characters are already non numeric. Also if the first character is non numeric it will say not float even if the there are some non numeric characters. It seems to me that it only checks the first character. Pls help...</p> <p><b><code>index.php</code></b></p> <pre><code>&lt;script type="text/javascript" src="javascript.js"&gt; &lt;/script&gt; &lt;form action="index.php" method="get"&gt; Integer 1: &lt;input type="text" id="num1" name="num1" onkeypress="checkInput(this);" /&gt; &lt;br /&gt; Integer 2: &lt;input type="text" id="num2" name="num2" onkeypress="checkInput(this);" /&gt; &lt;br /&gt; &lt;input type="submit" value="Compute" /&gt; &lt;/form&gt; </code></pre> <p><br /></p> <p><b><code>javascript.js</code></b></p> <pre><code>function checkInput(obj) { if(!parseFloat(obj.value)) { alert("Not Float"); } else { alert("Float"); } } </code></pre>
php javascript
[2, 3]
1,558,026
1,558,027
ASP.NET how to check type of the file type irrespective of extension
<p>If somebody renames the extension of any file (other than excel) to xls and xlsx (please dont ask me why :-( ), I need to check for its validity (if that is still a valid excel file). I am using mime type and Its not working. Am I missing anything?</p> <pre><code>const string excel2007MimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; const string excel2003MimeType = "application/vnd.ms-excel"; string excelExtention = string.Empty; excelExtention = System.IO.Path.GetExtension(myFilePath.PostedFile.FileName).ToLower(); string mimeType = myFilePath.PostedFile.ContentType; Response.Write("mime type" + mimeType + Environment.NewLine); if( ( !(excelExtention == ".xls" &amp;&amp; mimeType == excel2003MimeType) || !(excelExtention == ".xlsx" &amp;&amp; mimeType == excel2007MimeType) ) ) { Response.Write ("only excel file is permitted"); } </code></pre> <p>I rename a jpg file to xlsx file and upload. If I print out variable mimetype, Its value is "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet". I am not sure why because the content is not an excel file. Its an image.</p>
c# asp.net
[0, 9]
3,624,173
3,624,174
How to place Checkboxes with ListView (Android)
<p>I was following the ListView official tutorial - [url]http://developer.android.com/resources/tutorials/views/hello-listview.html[/url], because I get the entries dinamically through a webservice.</p> <p>Problem is, I want to place checkboxes at it. I have this</p> <p>(aux (String [] aux) is previously and correctly fullfilled before this)</p> <pre><code>//setListAdapter(new ArrayAdapter&lt;String&gt;(this, R.layout.lista, aux)); setListAdapter(new ArrayAdapter&lt;CheckBox&gt;(this,R.layout.row, convertToListItem(aux))); //ListView lv = getListView(); //lv.setTextFilterEnabled(true); </code></pre> <p>And I think the problem is on my row.xml</p> <pre><code>&lt;CheckBox xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="14sp" android:typeface="normal" android:textStyle="normal" android:layout_weight="0" android:layout_gravity="left" /&gt; </code></pre> <p>or in this function</p> <pre><code>private List&lt;CheckBox&gt; convertToListItem(String[] aux2){ List&lt;CheckBox&gt; result = new ArrayList&lt;CheckBox&gt;(); ArrayList&lt;CheckBox&gt; boxes = new ArrayList&lt;CheckBox&gt;(); for (String text : aux2){ CheckBox temp = new CheckBox(this); temp.append(text); temp.setText(text,BufferType.NORMAL); result.add(temp); boxes.add(temp); } return result; </code></pre> <p>What happens is: it appears the checkbox, but in front instead the right text it appears "android.widget.Checkbox@...."</p> <p>What am I doing wrong ?</p>
java android
[1, 4]
5,888,730
5,888,731
Stop next mouseover event from firing until inner function has finished
<p>I am implementing a simple image swapping feature with a fade in jquery.</p> <pre><code>$('#thumbs img').mouseover(function(){ // code to swap images here }); </code></pre> <p>If I move the mouse really quickly the mouseover keeps firing and the code to swap the images cant keep up. How do I stop the mouseover event on $('#thumbs img') from firing until the inner code has executed ?</p>
javascript jquery
[3, 5]
2,311,894
2,311,895
How to make a list of recent/running apps
<p>When holding the home button on your phone a pop up comes up showing recent applications. Does anyone know how to do this same action through code? I need to be able to choose one in a listview.</p>
java android
[1, 4]
4,480,405
4,480,406
Generate my links automatically
<p>I would like to generate my links automatically via a static class in each of my aspx pages (or in a common BasePage).</p> <p>Currently I use this:</p> <pre><code>private const string TEMPLATE = "~/One.aspx"; public static string Link () ( string link = String.Format(TEMPLATE); return link; ) </code></pre> <p>But the name of my page, One.aspx is hardcoded. Is it possible to generate the path instead of this hardcoded constant TEMPLATE. You should know that I do not instantiate the class before creating the link.</p> <p>The idea is to never hardcode a link but use a variable in my Redirect()</p> <pre><code>HttpContext.Current.Response.Redirect(PageOne.Link); </code></pre>
c# asp.net
[0, 9]
5,134,591
5,134,592
execute a fuction on the first element matching selection using Jquery
<p>I know <code>$('.test').each(testFuntion);</code> invokes the <code>testFunction</code> for all matching <code>.test</code> elements on the page. How do I tell it to do just the first matching one.</p> <p>I tried <code>$('.test:first').each(testFuntion);</code> and it still seems to run for all of them.</p>
jquery asp.net
[5, 9]
4,684,792
4,684,793
Issues with json_encode array
<p>I am having issues with my JSON_encode and jQuery, I am getting it to post the full array with the following code, but I can't get it to echo just the one array I need.</p> <pre><code>$.get("/indexget.php", { page: "goals" },function(data) { $('#bodyContentStuff').text(data); </code></pre> <p>Full jQuery code</p> <pre><code>$("#navLinkGoals").click(function () { $("#bodyTitleBar").text("Goals"); $.get("/indexget.php", { page: "goals" },function(data) { $('#bodyContentStuff').text(data); } ); </code></pre> <p>Full PHP code</p> <pre><code>if($_REQUEST['page'] = 'goals'){ $result = mysql_query("SELECT * FROM content WHERE page='indexGoals'") or die(mysql_error()); $row = mysql_fetch_array( $result ); $message = $row['message']; } echo json_encode(array("content"=&gt;"$message")); </code></pre> <p>I am sort of a noob with programming, but the site is <a href="http://www.gronge.com" rel="nofollow">http://www.gronge.com</a> if you'd like to see what it is doing, just click the goals link.</p> <p>Edit: Oh, I have also tried</p> <pre><code>$('#bodyContentStuff').text(data['content']); </code></pre> <p>But it didn't work.</p>
php javascript jquery
[2, 3, 5]
4,386,801
4,386,802
jQuery Split where numeric number occur
<p>I have a string like </p> <p>this-is-my-0-string. this-is-my-new-1-string-occur.</p> <p>i want to break string where number occurs</p> <p>like </p> <p>this-is-my , 0 , string </p> <p>and this-is-my-new,1, string-occur</p> <p>in common words i need to break my string where numbers occur. number is any from 0, 99999 is it possible to do in javascript or jquery ? How to do this </p> <p>Thanks in advance</p>
javascript jquery
[3, 5]
2,127,514
2,127,515
filling javascript object "on the fly"
<p>HI, i have an object: var myobject = new Object; and i want to dynamically fill it with properties while looping through jquery input collection in that manner:</p> <pre><code>$('.test').each(function(){ myobject.$(this).attr('name') = $(this).val(); }); </code></pre> <p>what i'm doing wrong here? thanks in advance</p>
javascript jquery
[3, 5]
5,344,856
5,344,857
Selecting a random image from a flickr set and appending it to a div
<p>I've run into a bit of a problem and was hoping to get a little help. I am trying to select a random image from a flickr set and append it to a div to use as a background image. Here is the function:</p> <pre><code>$.getJSON("http://***", function (data){ var htmlString = ""; $.each(data.photoset.photo, function(i, item){ var bkg = data.photoset.photo[i]; var randomBkg = Math.floor(Math.random() * bkg.length); htmlString += '&lt;img src='+ randomBkg.url_o +' /&gt;'; return i &lt; 0; }); $('#bg').append(htmlString); }); </code></pre> <p>If i replace randomBkg.url_o with bkg.url_o it just returns the first image in the set. using it as i have above appends an image tag with "undefined" as the img src. Any help about where i am misguided would be super appreciated. </p>
javascript jquery
[3, 5]
1,253,837
1,253,838
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,174,606
1,174,607
jquery change event without postback
<p>I have a listbox and on a particular selected value i want to display a dropdown and on selection of a value from the dropdown i want to display another dropdown.</p> <p>I have achieved this using jquery but the dropdowns are displayed only after postback. How to avoid the postbacks ?</p> <p>This is my jquery code</p> <pre><code>&lt;script type="text/javascript"&gt; $(document).ready(function () { if ($('#&lt;%=under_list1.ClientID %&gt; option:selected').val() == 0) { $("#ddl_nature1").show(); $("#ddl_gross1").hide(); if ($('#&lt;%=ddl_nature.ClientID %&gt; option:selected').val() == 'I', $('#&lt;%=ddl_nature.ClientID %&gt; option:selected').val() == 'E') { $("#ddl_gross1").show(); } else { $("#ddl_gross1").hide(); } } else { $("#ddl_nature1").hide(); $("#ddl_gross1").hide(); } }); </code></pre> <p></p> <p>under_list1 is my listbox id, ddl_nature1 is my first dropdown and ddl_gross1 is my second dropdown.</p>
jquery asp.net
[5, 9]
1,846,306
1,846,307
Dynamically Loading a UserControl with LoadControl Method (Type, object[])
<p>I'm trying to return the html representation of a user/server control through a page method. It works when I call the overload which takes the virtual path to the user control, but not when I try to call the overload which takes a type. The sample code is below. Any suggestions?</p> <pre><code>[WebMethod] public static string LoadAlternates(string productId, string pnlId) { object[] parameters = new object[] { pnlId, productId }; return ControlAsString(typeof(PopupControl), parameters); } private static string ControlAsString(Type controlType, object[] parameters) { Page page = new Page(); UserControl controlToLoad; /* *calling load control with the type results in the *stringwriter returning an empty string */ controlToLoad = page.LoadControl(controlType, parameters) as UserControl; /* *However, calling LoadControl with the following overload *gives the correct result, ie the string rep. of the control. */ controlToLoad = page.LoadControl(@"~/RepeaterSamples/PopupControl.ascx") as UserControl; //some more code, then this... page.Controls.Add(controlToLoad); StringWriter sw = new StringWriter(); HttpContext.Current.Server.Execute(page, sw, false); return sw.ToString(); } </code></pre> <p>Any ideas why this StringWriter would return an empty string? I should point out that all the "page" lifecycle execute correctly irrespective of the method chosen to call LoadControl.</p> <p>Wanted to add - I <em>have</em> to use the <code>LoadControl(Type, object[])</code> overload. :-(</p>
c# asp.net
[0, 9]
340,104
340,105
Javascript boolean if statement not working
<p>I'm trying to animate a panel to come in and out from the top of the page. Unfortunately my if statement is not working. Here's my code:</p> <pre><code>var panelShown = false; $(document).ready(function(){ $('#nav_arrow').click(function(){ panelShown = true; $('#nav_panel').animate({top: '0px'}, 1000, function(){}); $('#nav_bar'); }); if(panelShown == true){//originally written as if(panelShown){ $(document).click(function(){ panelShown = false; $('#nav_panel').animate({top: '-200px'}, 1000, function(){}); }); } }); </code></pre> <p>The first part works fine, the panel animates down. But I can never get into the if statement. Any help would be greatly appreciated.</p>
javascript jquery
[3, 5]
4,541,062
4,541,063
last day of the month
<p>How can obtain the last day of the month with the timestamp being 11:59:59 PM?</p> <p>Thanks, rodchar</p>
javascript jquery
[3, 5]
3,882,174
3,882,175
Lanch simpledialog manually
<p>How can I throw a simpledialog manually from a js function? </p> <pre><code>&lt;div id="loading_dialog_div"&gt;&lt;img src="img/indicator.gif" alt="" /&gt;&lt;/div&gt; &lt;a href="#" onclick="return addCustomer()" class="button pill simpledialog" rel="loading_dialog_div"&gt;Add customer&lt;/a&gt; </code></pre> <p>Since I need to perform an ajax request an I'd like to show the progress bar with the simpledialog once it starts, I need to launch manually with the beforeSend parameter. Any idea? Is it possible? </p>
javascript jquery
[3, 5]
702,219
702,220
Scroll textarea upwards/downwards on clicking prev and next hyperlinks in web page
<p>I want to show a hyperlinks "prev" "next". Clicking on "next hyperlink should scroll textarea to next location. Clicking on "prev" hyperlink should scroll textarea to previous location.</p> <p>The locations to jump in textarea are known e.g. line: 10, then line 40 , 50 , 70 , 101 , .... textarea has a fixed height.</p>
javascript jquery
[3, 5]
5,133,027
5,133,028
How to use my PHP function in JavaScript code
<p>I'm trying to use my PHP function in JavaScript like this:</p> <p>PHP code:</p> <pre><code>function checkevents($date){ $ev = new CalendarModelEventss(); $wh = "`event_date` = '".$date."'"; $all = $ev-&gt;getAllEvents('event_date', $wh); if($all == $date){ //echo 'event is available'.$all; return true; } else { return false; //echo 'event is NOT available' .'--'. $all; } } </code></pre> <p>and JavaScript code:</p> <pre><code>var yyyy = date.getLocalFullYear(true, this.dateType); var mm = date.getLocalMonth(true,this.dateType); var dd = iday; var ddddd = yyyy+'/'+mm+'/'+dd; if(&lt;?php checkevents( ?&gt;ddddd&lt;?php ) ?&gt;){ cell.className += " eventsss "; } </code></pre> <p>but it doesn't work, and I have PHP error (<code>syntax error, unexpected ';', expecting ')' in ...</code>).</p>
php javascript
[2, 3]
528,836
528,837
show arrow only when tab is active
<p>jsfiddle: <a href="http://jsfiddle.net/PBvk9/" rel="nofollow">http://jsfiddle.net/PBvk9/</a></p> <p>I want the arrow for its respective tab to show up only when the tab is active. Can someone help me out?</p>
javascript jquery
[3, 5]
1,992,518
1,992,519
JavaScript catch event
<p>I have a problem. I have too many events in my DOM. The upper layer is catching the deeper event.</p> <p>Easy Example:</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"&gt;&lt;/script&gt; &lt;script&gt; $(document).ready(function(){ $("p").click(function(){ $(this).hide(); }) $("#second").click(function(){ alert("second."); }); $("#first").click(function(){ alert("first."); }); }); &lt;/script&gt; &lt;style type="text/css"&gt; #first{ width: 200px; height: 200px; background-color: red; } #second{ width: 100px; height: 100px; background-color: green; } &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="first"&gt; &lt;div id="second"&gt; &lt;/div&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>If someone clicks on the second div, which is enclosed by the first div, both of the divs catch the event. In this situation, how can I catch just the second div's click event, and leave the first div. </p> <p>I learnt about the event bubbling, and tunnelling in C# is that the problem. How is this problem called? How can I solve the problem using JavaScript and jQuery. Is the solution the same?</p>
javascript jquery
[3, 5]
1,409,629
1,409,630
jquery accessing php jason_encoded array
<p>in test.php:</p> <pre><code>&lt;?php array_push($stack, "BLABLA"); array_push($stack, "BLABLA2"); echo json_encode($stack); ?&gt; </code></pre> <p>in test.html:</p> <pre><code>&lt;script type="text/javascript"&gt; $(document).ready(function(){ $.post( 'test.php', // location of your php script {}, // any data you want to send to the script function( data ){ // a function to deal with the returned information $('#mydiv').html(data[0]).show(); }, "json"); }); &lt;/script&gt; &lt;div id="mydiv"&gt;&lt;/div&gt; </code></pre> <p>I have done some sanity checks and it seems that data[0] isn't the correct way to access the first element I pushed in php. So how can I do this?</p>
php jquery
[2, 5]
1,920,207
1,920,208
How I can sort images by dimension in javascript or jquery
<p>How I can sort images by dimension in JavaScript or jQuery. My code is following:</p> <pre><code>var imgsrc = ''; if (document.images.length &lt; 1) { alert('No images to open'); return; } for (var i = 0; i &lt; window.parent.document.images.length; i++) { imgsrc + = '\n'; } if (imgsrc != '') { var newwin = window.open('', ''); newwin.document.open(); newwin.document.write('\n' + imgsrc + ''); newwin.document.close(); } else { alert('No images!') }​ </code></pre> <p>Please help me out. Thank you in advance.</p>
javascript jquery
[3, 5]
4,954,687
4,954,688
ASP.NET Jquery check is checked not working
<p>I have an onChange event for a checkbox which fires a function that toggles the Visibility of some TRs. My problem is this code only works in firefox. I want it to work for ie8.</p> <pre><code>function toggleVisibility() { if ($("#ctl00_PageContent_chkVisibility").is(':checked')) { $('#ctl00_PageContent_freight_rate_column_chaair tr').each(function(i, val) { // Loop through rows in grid if (i &gt; 9 &amp; i &lt; 28) { $('#ctl00_PageContent_freight_rate_column_chaair_r' + i).hide(); }; }); } else { $('#ctl00_PageContent_freight_rate_column_chaair tr').each(function(i, val) { // Loop through rows in grid if (i &gt; 9 &amp; i &lt; 28) { $('#ctl00_PageContent_freight_rate_column_chaair_r' + i).show(); }; }); }; }; </code></pre> <p>Does anyone know a better way of doing this?</p> <p>Thanks</p>
jquery asp.net
[5, 9]
805,518
805,519
jquery image gallery slide animation
<p>I am trying to make a simple image gallery like this. <a href="http://dimsemenov.com/plugins/royal-slider/#image-gallery" rel="nofollow">http://dimsemenov.com/plugins/royal-slider/#image-gallery</a> When I click a thumbnail image, image element will create and loading image will appear a little time and created element will slide in the visible area.At last old image elment will remove.</p> <pre><code>&lt;div id="imageGallery" style="overflow:visible;display:block;"&gt; &lt;div class="preview"&gt; &lt;div id="content" style="width:640px;height:420px;"&gt; &lt;img id="main-Image" alt="" src="../../baContent/image1.jpg" style="display:inline; top:0;left:0;" /&gt; &lt;/div&gt; &lt;/div&gt; &lt;div id="thumbnails"&gt; &lt;a class="thumbnail" href="../../baContent/image1.jpg"&gt;&lt;img alt="Image 1" src="../../baContent/image1-thumb.jpg"&gt;&lt;/a&gt; &lt;a class="thumbnail" href="../../baContent/image2.jpg"&gt;&lt;img alt="Image 2" src="../../baContent/image2-thumb.jpg"&gt;&lt;/a&gt; &lt;/div&gt; </code></pre> <p></p> <pre><code>$(document).ready(function () { $(".thumbnail").click(function () { $("#mainImage").animate({ "left": "-640px" }, "fast"); $('#preview').css('background-image', "url('../../baContent/spinner.gif')"); var img = $("&lt;img style='left:640px;display:none;' /&gt;").attr('src', this.href).load(function () { $('#mainImage').attr('src', img.attr('src')); $('#preview').css('background-image', 'none'); $(this).parent().prevAll().remove(); $("#mainImage").animate({ "left": "-640px" }, "fast"); }); }); }); </code></pre> <p>I wrote a few code but had no success. Any ideas or tutorials?</p>
javascript jquery
[3, 5]
3,411,152
3,411,153
How can i send io stream to specific USB?
<p>I need to send some io stream ( the io information can be text or video stream ) to some of the existing USB connectors. </p> <p>I don't know how can i send this stream directly to this port - and if this actually possible.</p> <p>Someone can help me ? </p> <p>Thanks</p>
c# c++
[0, 6]
3,740,996
3,740,997
jquery .show not running
<p>The following code doesn't seem to execute properly for me, and I'm puzzled as to why. <code>NonITView</code> and <code>ITView</code> are both divs in my ASP page. <code>txtIsIT</code> is an <code>asp:textbox</code> on the page that gets either "yes" or "no" on page load.</p> <pre><code> if (document.getElementById("&lt;%= txtIsIT.ClientID %&gt;").value = "yes") { $("#NonITView").hide("slow"); $("#ITView").show("slow"); } else if (document.getElementById("&lt;%= txtIsIT.ClientID %&gt;").value = "no") { $("#ITView").hide("slow"); $("#NonITView").show("slow"); } else { alert("Error"); } </code></pre> <p>The <code>if</code> is evaluating properly. In firefox's web console, by entering the jquery .show/.hide functions, the divs are properly shown/hidden, which is part of what's confusing me. Anything sticking out to you that should be fixed?</p>
javascript jquery asp.net
[3, 5, 9]
3,006,688
3,006,689
JavaScript in Android
<p>Is it possible to use JavaScript in Android?? if so, how? Please provide some examples.</p> <p>Thanks.</p>
java javascript android
[1, 3, 4]
5,691,860
5,691,861
timer schedule method exceeds the time
<p>I use the timer schedule method to send location information to the db every 5 min.</p> <p>Here is the code:</p> <pre><code>public void onStart(Intent intent, int startId) { this.timer.schedule(new Send(), new Date(), TEN_SECONDS*6*5); //ten_seconds = 10000 } class Send extends TimerTask { public void run() { String address = LocationService.this.address; new SendLocation(LocationService.this.id,address); // a thread that sends the info to the db LocationService.this.gpsLocation = null; LocationService.this.networkLocation = null; } } </code></pre> <p>But how come that my db has locations with 7/6 minute diffrence? The sendLocation checks if the location that i'm going to send to the db is the same as the last one, if true ignore the location else send it.</p> <p>Which means that the diffrence between each location in my db should be in jump of 5 minute.</p>
java android
[1, 4]
5,813,648
5,813,649
hosting a webserver inside iphone and android phones
<p>i am planning to do some servlet for my app to work offline on both android and iphone devices. for this i need to have the stubbed responses on a server.i saw there is one such server for android (<a href="http://code.google.com/p/i-jetty/" rel="nofollow">http://code.google.com/p/i-jetty/</a>). is there is similar server for iPhone ? so that i can develop a single solution to solve both the platforms.</p> <p>or else you can also get me an alternate idea of using a php kind of server which could work on iPhone and android. </p>
php android iphone
[2, 4, 8]
2,900,717
2,900,718
jQuery Dropdown Check List: jQuery click() anomaly
<p>I have a page with several dropdownchecklists, all with checkboxes (multiple selects possible). Inside document ready, I have this simple code:</p> <pre><code>$(":checkbox").click(alert('TEST')); </code></pre> <p>The problem is that when the page first loads, the alert fires. What I want to do is only fire the alert when one of the dropdownchecklist boxes is clicked. I know I am being dull of wit here. Can someone enlighten me?</p> <p>Another way to state the problem is simply "How can I activate a function when a dropdownchecklist checkbox is clicked?"</p> <p>Thanks in advance.</p>
javascript jquery
[3, 5]
1,977,291
1,977,292
Javascript - arrays sorting
<p>I have two arrays:</p> <pre><code>keys_array = [2,4,5,8,9] values_array = ['two','four','five','eight','nine'] </code></pre> <p>I need to get:</p> <pre><code>#transitional result #values sorted alphabetically sorted_by_value_name_array = [ ['8','eight'], ['5','five'], ['4','four'], ['9','nine'], ['2','two'] ] #final result sorted_keys_array = [8,5,4,9,2] </code></pre> <p>How can i achieve this with javascript or jQuery?</p>
javascript jquery
[3, 5]
2,002,247
2,002,248
Android: Prompt user to save changes when Back button is pressed
<p>I have an activity that contains several user editable items (an EditText field, RatingBar, etc). I'd like to prompt the user if the back/home button is pressed and changes have been made that have not yet been saved. After reading through the android documentation, it seems like this piece of code should go in the onPause method. I've tried putting an AlertDialog in the onPause however the dialog gets shown and then immediately tears down because nothing is there to block the pause from completing. </p> <p>This is what I've come up with so far: </p> <pre><code>@Override protected void onPause() { super.onPause(); AlertDialog ad = new AlertDialog.Builder(this).setMessage( R.string.rating_exit_message).setTitle( R.string.rating_exit_title).setCancelable(false) .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // User selects OK, save changes to db } }).setNeutralButton(android.R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // User selects Cancel, discard all changes } }).show(); } </code></pre> <p>Am I on the right track or is there another way to accomplish what I'm trying to do here? Any help would be great! </p>
java android
[1, 4]
1,454,961
1,454,962
Adding Views to another View
<p>Is there a possibility to add a view or derivative (button, textview, imageview etc...) to another view without having to go through layouts?</p> <p>I have a class called ScreenView, it derives from View (e.g. public class ScreenView extends View). I wanted to display text into it, labels, images etc..</p> <p>On an iPhone it's trivial, simply create my objects and use addSubview method ; you can embed any UI objects into another. Most UI toolkits work that way too.</p> <p>Problem with layouts is that I haven't found an easy way to properly position a subview (say a text view) in a given location of the enclosing View. I want one to contain the other...</p> <p>I was hoping I had missed something in the documentation (which is far from being intuitive that's for sure) and I could do something like myView.addView(subview). But it ain't so :)</p> <p>As a side question, what is the closest to iPhone's UILabel in the Android world? A UILabel can contain a text or a graphic. Right now I've been using TextView and ImageView but they aren't anywhere as flexible when it comes to layout as a UILabel</p> <p>Edit: Making my View inherit from ViewGoup instead, let me add subview.. However, I want to draw in my view. I found that when ScreenView extends ViewGroup, the onDraw function is never called then.</p> <p>Something like:</p> <pre><code> @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); Paint paint = new Paint(); paint.setStyle(Paint.Style.FILL); // make the entire canvas yellow paint.setColor(Color.YELLOW); canvas.drawPaint(paint); } </code></pre> <p>Would paint in yellow my view if ScreenView extends View ; but not if it extends ViewGroup.</p> <p>How do you draw directly in the view then?</p> <p>Thanks JY</p>
java android
[1, 4]
2,691,577
2,691,578
Android: Scan music files from specific directories?
<p>I want to my application to scan for music files only in those folders which I have specified in preferences. So that other music files like audio books do not get included.</p> <p>Currently, I've written this code, that scans all music files:</p> <pre><code>private String[] getTrackList() { String[] result = null; String[] projection = { MediaStore.Audio.Media._ID, MediaStore.Audio.Media.DISPLAY_NAME, MediaStore.Audio.Media.DATA, MediaStore.Audio.Media.TITLE }; String selection = MediaStore.Audio.Media.IS_MUSIC + "!=" + 0; cursor = managedQuery(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, projection, selection, null, MediaStore.Audio.Media.TITLE + " ASC"); result = new String[cursor.getCount()]; int position = 0; for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) { columnIndex = cursor .getColumnIndexOrThrow(MediaStore.Audio.Media.TITLE); result[position] = cursor.getString(columnIndex); position++; } return result; } </code></pre>
java android
[1, 4]
948,030
948,031
Why is array[0] returning a different object than array.first using jQuery and why can't I use .val( )?
<p>I'm selecting an array of input objects using jQuery and I'm running into an interesting problem when I try to chain together multiple methods after selecting one of the array elements. Can anyone explain to me why I get this behavior?</p> <pre><code>jQuery('.custom-size').first().find('input:hidden') returns =&gt; [&lt;input id=​"custom_order_custom_sizes_attributes_0_size_id" name=​"custom_order[custom_sizes_attributes]​[0]​[size_id]​" type=​"hidden" value=​"138"&gt;​ , &lt;input name=​"custom_order[custom_sizes_attributes]​[0]​[_destroy]​" type=​"hidden" value=​"0"&gt;​ ] </code></pre> <p>If I select one of the elements using jQuery <code>.first()</code> or <code>.last()</code> and then call <code>.val()</code>, I get the expected value of <code>"138"</code>. </p> <p>When I try to use a location in the array, I can return the element of the array: </p> <pre><code>var input = jQuery('.custom-size').first().find('input:hidden')[1] returns =&gt; &lt;input name=​"custom_order[custom_sizes_attributes]​[0]​[_destroy]​" type=​"hidden" value=​"0"&gt; </code></pre> <p>I can't call <code>.val()</code> on this object however. Instead I get this error message:</p> <pre><code>TypeError: Object #&lt;HTMLInputElement&gt; has no method 'val' </code></pre> <p>I can use <code>.slice(x,y)</code> to return the single element, but this seems rather silly. What am I missing here.</p>
javascript jquery
[3, 5]
1,542,516
1,542,517
jQuery/javascript optimization
<pre><code>$("#mySelect").change(function() { var myVar = $('#MyDiv'); for (var i=0;i&lt;this.value;i++) { myVar.clone().appendTo('#formContainer'); } }); </code></pre> <p>Any improvements to readability or performance welcome</p>
javascript jquery
[3, 5]
5,110,070
5,110,071
Change value of Onclick function vars
<p>I have the onClick function attached to a button. I want to be able to change the function var from 'create' to 'update' on the page load and through other functions. I have tried the code below but no luck.</p> <pre><code>&lt;input type="button" name="save_customer" id="save_customer" value="Save" onClick="customer_crud('create')" /&gt; var js = "customer_crud('read')"; // create a function from the "js" string var newclick = new Function(js); // clears onclick then sets click using jQuery $("#save_customer").attr('onClick', '').click(newclick) </code></pre> <p>Any ideas.</p> <p><strong>UPDATED</strong></p> <p>Ok in a nutshell i want to change the attr onClick like you would change the attr name &amp; type.</p> <pre><code>&lt;input type="button" name="save_customer" id="save_customer" value="Save" onClick="customer_crud('create')" /&gt; </code></pre> <p>to</p> <pre><code>&lt;input type="button" name="save_customer" id="save_customer" value="Save" onClick="customer_crud('update')" /&gt; </code></pre> <p>Thanks</p>
javascript jquery
[3, 5]
4,734,964
4,734,965
Auto Submit Form after 10 characters
<p>I want my form to be autosubmitted when user enters the tenth character in an input field.</p> <p>Here is my code:</p> <pre><code>&lt;form id="Form" action="action.php" method="post"&gt; &lt;input name="htno" type="text" value="" /&gt;&amp;nbsp; &lt;input type="submit" value="Submit" /&gt; &lt;/form&gt; </code></pre> <p>I don't know how to use jQuery or ajax.</p>
javascript jquery
[3, 5]
3,366,999
3,367,000
JQuery - loading multiple pages in one newly opened window
<p>I'm total beginner in js and JQuery and have to complete such task:</p> <p>I have to open new window with some document print preview. It is not a problem for single document, but there's a need to print more than one document. I was trying to do this like that:</p> <pre><code>var win = window.open("", "test", "width=700,height=600"); $(win.document).ready(function(){ $(win.document).contents().load("here_my_action_with_changing_id"); }) }); </code></pre> <p>but it only loads first document and I don't have any idea how to load one after another. Also, it seems not to work on IE properly.</p>
javascript jquery
[3, 5]
899,511
899,512
Programming a multiplayer game with a PhP/MySQL server, and JavaScript/jQuery clients
<p>Here is the situation. I would like to develop a game based on content delivered by MediaWiki. MediaWiki is PhP based and has MySQL as database. So far, I did the client side animations using JavaScript and jQuery.</p> <p>The game doesn't have to be strictly real-time. I simply want to be notified when the person I am playing against makes a move, within a second or two.</p> <p>Do you have suggestions about suitable approaches I might want to consider?</p>
php jquery
[2, 5]
335,421
335,422
Try - Catch return strategy
<p>When using <code>try-catch</code> in methods, if you want you application to continue even if errors come along, is it okay to return the default value as return through the catch block, and log the error for later review?</p> <p>For Example:</p> <pre><code>public static string GetNameById(int id) { string name; try { //Connect to Db and get name - some error occured } catch(Exception ex) { Log(ex); name = String.Empty; } return name; } </code></pre> <p>Example 2:</p> <pre><code>public static string GetIdByName(string name) { int id; try { //Connect to Db and get id- some error occured } catch(Exception ex) { Log(ex); id = 0; } return id; } </code></pre> <p>Is it okay to return any default value (depending on the return type of the method ...???) so that the application logic that required the result from this method do not crash and keeps going ....</p> <p>Thanks in advance...</p> <p>Regards.</p>
c# asp.net
[0, 9]
1,085,735
1,085,736
Pass 2 arguments to check box
<p>In <a href="http://www.cleancode.co.nz/blog/279/checkbox-repeater-event-handling-argument" rel="nofollow">this</a> example they are passing only 1 argument. Wat if I wanna pass two ?</p> <p>When I was using Link Button I was using the two Command arguments like <a href="http://stackoverflow.com/questions/4263489/need-help-with-repeater">this</a></p> <p>Plz check the ItemCommand event in the code above</p> <p>Now I am clueless how pass 2 args to CheckBox in the repeater! HElp!</p>
c# asp.net
[0, 9]
1,569,911
1,569,912
how to open jquery popup window through header redirect using php?
<p>I'm using jquery for popup window. This pop-up window will contain 2 file uploading and other text input tag and finally Submit button.Now If user upload a file from the 1st file upload the action is send to upload.php file then redirects to this page, but the pop is closed.So i want the pop-window to be open after the uploaded file is redirected to this page.So that 2nd file upload is done and so on till the final Submit button is pressed.</p> <p>I want the popup-window to be open when file is redirected to that page.</p> <p>Regards Sid</p>
php jquery
[2, 5]
5,307,184
5,307,185
Seeing if a checkbox is checked by default
<p>I have a javascript function that sets a variable everytime a checkbox is clicked:</p> <pre><code> function handleClick(cb) { alert('entered function'); setTimeout(function () { if (cb.checked ) { $("#IsChecked").val('true'); } else $("#IsChecked").val('false'); alert('now my value is: '+ $("#IsChecked").val()); }, 0); } </code></pre> <p>Heres my checkbox:</p> <pre><code> &lt;input id="MyCheckBox" type="checkbox" value="true" onclick="handleClick(this);" name="MyCheckBox" checked="checked"&gt; </code></pre> <p>This works great everytime the checkbox is checked. But now i need to know if the checkbox is checked when the user clicks a button and has never touched the checkbox before. So i do this:</p> <pre><code> $(document).ready(function () { $("#IsChecked").val('default'); $('#btnCheck').click(function (e) { var isComplete = $("#IsChecked").val(); if (isComplete == 'default') { var cb = $('#MyCheckBox'); handleClick(cb); alert('after handleClick ischecked is: ' + $("#IsChecked").val()); } }); </code></pre> <p>});</p> <p>When i click my button and the checkbox is checked by default, i get these alerts in this order:</p> <pre><code> entered function after handleClick ischecked is: default now my value is: false </code></pre> <p>If i check the checkbox to toggle it, i get these alerts as expected:</p> <pre><code> entered function now my value is: false </code></pre> <p>In my handleClick event, the setTimeout is there because of IE so i cant get rid of it. How can i check to see if a checkbox is checked without having to click the checkbox itself? Thanks</p>
javascript jquery
[3, 5]
1,614,123
1,614,124
access one web user control datalist Template Item to some othere web user and check validation
<p>I have a web user control suppose a.ascx there is a datalist template item linkbtn lnktbnA</p> <p>i am adding the data in that and binding it.</p> <p>I have a web user control suppose b.ascx there is a btn BB</p> <p>now i want to check IF there is any item named as Final Page then page redirect to some other page else it show some msg that final page is not available you can't go to next page</p> <p>I want to check this validation on btn click bb which is in web user control b.ascx</p>
c# asp.net
[0, 9]
654,635
654,636
Simplest way to communicate data between php and android
<p>I am trying to build an android application based on hotel management. The app simply provides the list of deals to the user. The website stores the data regarding the user and deals in sql tables in database.</p> <p>Is there any simple way to communicate data such as deal details and user details like user name, hotel name, etc. from website to android app and viceversa. </p> <p>I know this is possible using json. But I am finding it difficult to implement.</p>
php android
[2, 4]
3,511,384
3,511,385
call a function with a specific index value of nodelist
<p>Is it possible to call a function on specific index value of nodelist which is storing div like following :</p> <pre><code>var txtElem = txtdiv.getElementsByTagName("div"); </code></pre> <p>the thing i want is that i am storing list of divisions in txtElem nodelist now i want to call a function on click event of the 3rd div stored in nodelist. The divisions are created dynamically and they don't have any id so they are not accessible by id.</p>
javascript jquery
[3, 5]
1,324,115
1,324,116
Function Not Defined OEmbed Vimeo API
<p>Started messing around with Vimeo API in an attempt to create a clickable gallery like this (http://www.aideffectiveness.org/busanhlf4/vimeo/php-example.php). However, when I moved some of the code into a "script.js" file as a way to organize my code from the other parts of the site, the json callback keeps saying that the 'embedVideo' function is not defined. Any ideas?</p> <p>The "script.js" file is placed at the bottom of the page and has the following:</p> <pre><code>var NS = NS || NS; NS = { videoInit: function() { var oEmbedUrl = 'http://vimeo.com/api/oembed.json'; var oEmbedCallback = 'embedVideo'; var videoid = ""; if(videoid == '' ){ videoid = '23515961'; } function embedVideo( video ) { var videoEmbedCode = video.html; document.getElementById('embed').innerHTML = unescape(videoEmbedCode); } function init() { loadScript(oEmbedUrl + '?url=http://vimeo.com/' + videoid + '&amp;height=380&amp;width=700&amp;callback=' + oEmbedCallback); } function loadScript( url ) { var js = document.createElement('script'); js.setAttribute('src', url); document.getElementsByTagName('head').item(0).appendChild(js); } init(); } } $(function() { NS.videoInit(); }); </code></pre> <p>The HTML:</p> <pre><code>&lt;div id="wrapper"&gt; &lt;div id="embed"&gt;&lt;/div&gt; &lt;/div&gt; </code></pre>
javascript jquery
[3, 5]
1,163,637
1,163,638
What exactly is this structure
<p>Is this an object that contains objects or an array of objects? </p> <pre><code>var rgb = { ball: { Red: 232, Green: 23, Blue: 23}, square: { Red: 42, Green: 83, Blue: 32}, }; </code></pre> <p>I need to generate it with php and then declare it in my script, so want to know what I should be building in php</p>
php javascript jquery
[2, 3, 5]
1,347,734
1,347,735
Check if/time Image loads ASP.net Web Application
<p>Ive looked around and havent seen anything on what I can do for my problem, so maybe someone here can help me. Basically I have an image (http://mysite.com/Sites/P/PA/25?encoding=UTF-8&amp;b=100 note there is no file extension as this served through a script) and I want to check to see if this image returns an Image, or an error code like 404 or 403. I also want to record the response time of that. I am trying to make a web application that will monitor this software that displays the image, if it returns 404 error I know its down, if the load time is greater than 10 seconds I also know it may be down or some other action needs to be performed.</p> <p>I thought about using <code>WebRequest.Create</code> but this wont return the time it took.</p> <p>Any have any ideas on how I could implement this?</p>
c# asp.net
[0, 9]
4,226,811
4,226,812
Programmatically View image hash values
<p>How to Programmatically View image hashes in C# or PHP ?</p>
c# php
[0, 2]
545,609
545,610
Read file.inputstream twice
<p>I need to read csv file twice. but after first reading:</p> <pre><code>using (var csvReader = new StreamReader(file.InputStream)) { fileFullText += csvReader.ReadToEnd(); file.InputStream.Seek(0, SeekOrigin.Begin); csvReader.Close(); } </code></pre> <p>using file in enother function:</p> <pre><code>public static List&lt;string&gt; ParceCsv(HttpPostedFileBase file) { //file.InputStream.Seek(0, SeekOrigin.Begin); using (var csvReader = new StreamReader(file.InputStream)) { // csvReader.DiscardBufferedData(); // csvReader.BaseStream.Seek(0, SeekOrigin.Begin); string inputLine = ""; var values = new List&lt;string&gt;(); while ((inputLine = csvReader.ReadLine()) != null) { values.Add(inputLine.Trim().Replace(",", "").Replace(" ", "")); } csvReader.Close(); return values; } } </code></pre> <p>The file.Length is 0. Can anybody help?</p>
c# asp.net
[0, 9]
265,604
265,605
How do you put jsfiddle on your html
<p>This may be the thickest question ever! But how do I get this to work on my html?</p> <p>HTML</p> <pre class="lang-html prettyprint-override"><code>&lt;div class="test2"&gt;&lt;/div&gt; &lt;div class="test"&gt;&lt;/div&gt; &lt;div class="test3"&gt;&lt;/div&gt; </code></pre> <p>CSS</p> <pre class="lang-css prettyprint-override"><code>.test2 {margin-top: 250px; position:absolute; left: -100px; width:100px; height:100px; background: aqua; } .test {margin-top: 500px; position:absolute; right: -100px; width:100px; height:100px; background: aqua; } .test3 {margin-top: 1000px; position:absolute; right: 100px; width:100px; height:100px; background: aqua; } ​​ </code></pre> <p>JS</p> <pre class="lang-js prettyprint-override"><code>var $test2 = $(".test2"); $(window).scroll(function() { if ($(this).scrollTop() &gt; 20) { $test2.stop().animate({ left: "200px" }, 200); } }); var $test = $(".test"); $(window).scroll(function() { if ($(this).scrollTop() &gt; 100) { $test.stop().animate({ right: "200px" }, 400); } });​ </code></pre> <p><a href="http://jsfiddle.net/maxmitch/UgEu6/" rel="nofollow">http://jsfiddle.net/maxmitch/UgEu6/</a> (complete sample)</p>
javascript jquery
[3, 5]
838,222
838,223
JQuery - Javascript
<p>The following is my code for one form of a two form aspx page. Would this code work? Or any help to make it work is much appreciated.</p> <pre><code>&lt;form action=" $(document).ready(function(){ DoSearchSubmit('Search.aspx','Results.aspx') });" method="POST" id="SearchForm" &gt; &lt;input type="text" size="13" id="txtQuickSearch" name="txtQuickSearch" /&gt; &lt;input type="submit" class="searchButton" value="Search" id="btnSearchSubmit" /&gt; &lt;/form&gt; </code></pre> <p>Thanks</p>
javascript jquery
[3, 5]
2,806,338
2,806,339
Receiving JQuery $.post data and returning specific results with PHP
<p>I'm trying to make a dynamic website on a single webpage and I'm almost there. All that's left is to do some php coding. </p> <p>Here is a few lines of code from my "index.php"</p> <pre><code>$('.open').click(function(){ current = $(this).html(); $.post("source.php", {name: current}, function(src){ $('#codeBox').html(src); }); }); </code></pre> <p>How do I check the value of "current" in my php file and return data specific to the link I click on?</p>
php javascript jquery
[2, 3, 5]
477,753
477,754
How to show the progress bar to diffrent clients.?
<p>User1 open the website did something the progress bar starts. User2 open the same website that progress bar needs to display here.Please tell me.</p>
c# asp.net
[0, 9]
5,115,671
5,115,672
Colums name of SMS Cursor?
<p>I have 2 lines code:</p> <pre><code>private static final Uri SMS_INBOX = Uri.parse("content://sms/inbox"); Cursor c = getContentResolver().query(SMS_INBOX, null, null, null, null); </code></pre> <p>Anybody know where to find column list of this cursor?</p>
java android
[1, 4]
1,975,474
1,975,475
Is there any alternate to TextView?
<p>I m new to android application development. I made a project on getting feeds of sites. I displayed the title and description of feeds in textview which is not looking very presentable. Is there any alternate to it? I just need my application to look a bit presentable. </p>
java android
[1, 4]
5,391,952
5,391,953
TimeZone.getAvailableIDs in Android and Java
<p>I am TimeZone.getAvailableIDs for List of TimeZone in android.It is behaving differently in android as compared to Java.</p> <pre><code> String[] tzone = TimeZone.getAvailableIDs(-3 * 3600 * 1000);; for (String string : tzone) { do something } </code></pre> <p>It skiping all those TimeZone which don't include "/" character in android.Can anybody tell me what is the problem when we are using TimeZone in android.</p>
java android
[1, 4]
167,486
167,487
phpmyadmin html connect
<p>i am currently creating a web application. the problem here it is coded purely in HTML and JScript. Is it possible to use a php script as well to connect to PHPmyadmin? i have been encountering the same problem where the script is being displayed as text file</p>
php javascript
[2, 3]
1,139,469
1,139,470
Static Methods in ASP.NET
<p>i am a little confused about static methods within asp.net-pages. E.g. what if i create a static Database-Method to get Userdata out of the database (something like UserDBHandler.getUser()) - is it safe to call that method from within web-pages? Isnt a new thread created for every page-call? And does HttpContext.Current always return the current-users context, so is it safe to call that from static methods to get the current-users session??</p> <p>thanks</p>
c# asp.net
[0, 9]
4,488,327
4,488,328
GridView trouble in .Net
<p>i think this maybe an easy one...<br> I have a Gridview, bound to a dataSource with this query:<br> select userid, name, phone from users<br> I need to change the content of the Name cell to a link, like so:<br> <code>&lt;a href="http://www.domain.com/page.aspx?userid=12345"&gt;User's Name&lt;/a&gt;</code><br> so OnRowDataBound i'm doing this: </p> <pre><code>e.Row.Cells[1].Text = "&lt;a href=\"http://www.domain.com/page.aspx?userid=\" + e.Row.Cell[0].Text + "\"&gt;" + e.Row.Cells[1].Text + "&lt;/a&gt;"; </code></pre> <p>It all works fine this way. My problem is that i don't want to display the UserId column in the Gridview, but when i attribute it (asp attribute or server-side) <code>Visible="false"</code> to the BoundField UserId, i can't capture it's value to build the Name Cell.</p> <p>Thanx for your help</p>
c# asp.net
[0, 9]
465,224
465,225
Clear dropdownlist with JQuery
<p>I wrote this little function to fill a drop down list with data from the server.</p> <pre><code>function fillDropDown(url, dropdown) { $.ajax({ url: url, dataType: "json" }).done(function (data) { // Clear drop down list $(dropdown).find("option").remove(); &lt;&lt;&lt;&lt;&lt;&lt; Issue here // Fill drop down list with new data $(data).each(function () { // Create option var $option = $("&lt;option /&gt;"); // Add value and text to option $option.attr("value", this.value).text(this.text); // Add option to drop down list $(dropdown).append($option); }); }); } </code></pre> <p>I can then call the function in this way:</p> <pre><code>fillDropDown("/someurl/getdata", $("#dropdownbox1")) </code></pre> <p>Everything is working perfectly, except for the one line where I'm clearing old data from the drop down list. What am I doing wrong?</p> <p>Any tips that might help to improve this code are also highly appreciated.</p>
javascript jquery
[3, 5]
3,328,196
3,328,197
WVGA800 (480x800) & Density ANDROID
<p>Table 3 on this page: <a href="http://developer.android.com/guide/practices/screens_support.html" rel="nofollow">http://developer.android.com/guide/practices/screens_support.html</a></p> <p>shows that WVGA800 (480x800) is available with 3 Densities. Does this mean that for each density the game will be loaded with different DPI assets if available ?</p> <p>But how come same resolution will have different assets or layouts?</p>
java android
[1, 4]
4,628,055
4,628,056
Problems with a method imported from a SDK library
<p>I am new to C# and ASP.NET and I have a problem with a library that I am importing. I have a small application that is going to convert a sound file in a format that is proprietaty to the vendor and they have an SDK that provides a method to make the conversion from their extension to .WAV format.</p> <p>The issue I have is after importing the SDK library into VS2008, and putting the using statement on my code behind, I am getting an error when I try to use the method I need in order to make the conversion. My code is below and the error says:</p> <blockquote> <p>Name space ALTIHELPERLib</p> <p>Error 'ALTIHELPERLib.IAHelper.ADPCM2Wav(wavFilePath, filePath)'. Not all code paths return a value return </p> </blockquote> <p>I have tried to look around for a solution but so far nothing has worked. Any help will be appreciate it. Here is my code:</p> <pre><code>string wavFilePath = @"\mylocation\"; //destination of file once onverted string filePath = "\source\"; //location of source file public string ALTIHELPERLib.IAHelper.ADPCM2Wav(wavFilePath, filePath){ } </code></pre>
c# asp.net
[0, 9]
3,989,001
3,989,002
How can I add dashes (custom formatting) inside a string of numbers?
<p>I have a site where users enter a numeric code of 10 numbers:</p> <pre><code>xxxxxxxxxx </code></pre> <p>When displaying this value (read from the database), I want it to display in this format:</p> <pre><code>xxxx-xxxx-xx </code></pre> <p>How can I do this with PHP or jQuery?</p>
php jquery
[2, 5]
1,529,752
1,529,753
ASP.NET RegisterClientScriptBlock, RegsiterStartupScript issues
<p>I am working on a set of ASP.NET applications using a master page. When I try to register a clientscript - an alert box for instance, in the Page_Load it works fine. However if I try to do the same from any method or event handler of the same class it doesn't. Also, it doesn't seem to matter which Register method you use, both work only in the Page_Load (for me).</p> <p>I could not find another way so far to alert the user about exceptions and such from within the code (other than building a user control) and I figure in a similar situation other JavaScript codes won't execute either...for example one that would refresh an iframe content.</p> <p>I'm wondering if there is a best practice to achieve a little more dinamic interaction between JavaScript and code behind?</p> <p>What I mean is something that:</p> <ul> <li>can be called from anywhere in the codebehind</li> <li>UpdatePanels and MasterPages don't make it unreliable</li> </ul>
javascript asp.net
[3, 9]
39,084
39,085
add second onclick to Listview
<p>I want to add a second <code>on click</code> to a ListViewItem. I already created the View (ImageView) and i set the on Click. The function gets called. But: How can i get the Informations of this ListViewItem? It would be enough to get the Position in the ListView?</p> <p>The ImageView:</p> <pre><code>&lt;ImageView android:id="@+id/imageView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="right|center_vertical" android:layout_marginLeft="10dp" android:layout_marginRight="10dp" android:onClick="favorite" android:src="@drawable/star" /&gt; </code></pre> <p>The code for my on click function:</p> <pre><code>public void favorite(View view){ ImageView iView = (ImageView) view; iView.setImageResource(R.drawable.star_checked); ViewParent v = iView.getParent(); } </code></pre>
java android
[1, 4]
719,730
719,731
how to add a hyper link in a gridview
<p>I have a gridview control and I would like the field Title to be a hyperlink and execute a stored procedure when clicked. Can anyone assist me in this?</p> <p>Does this code look right?</p> <pre><code>&lt;Columns&gt; &lt;asp:TemplateField&gt; &lt;ItemTemplate&gt; &lt;asp:HyperLink ID="hpTitle" runat="server" Text='&lt;%# Bind("Title") %&gt;' NavigateUrl='&lt;%# Bind("SelectBook") %&gt;'&gt;&lt;/asp:HyperLink&gt; &lt;/ItemTemplate&gt; &lt;/asp:TemplateField&gt; &lt;asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False" ReadOnly="True" SortExpression="ID" /&gt; &lt;asp:BoundField DataField="Publisher" HeaderText="Publisher" SortExpression="Publisher" /&gt; &lt;asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" /&gt; &lt;/Columns&gt; </code></pre>
c# asp.net
[0, 9]
5,901,786
5,901,787
Support move to SD in Android when the project is 2.1
<p>I have an application, its a 2.1 project. I'd like to add "Move to sd" option to my application. How should I do it? I must create a new project for android 2.2? If yes how can I make for keep the whole app maintainable and don't have two sepparated projects?</p> <p>Thanks in advance</p>
java android
[1, 4]
1,686,729
1,686,730
CSV file export
<p>I have some data with in different datatables. Each datatable is not assured of having the same no of records. Using all these datatables i need to put those data into a comma delimeted CSV file. But I found examples only for exporting using a single dataset. Can any one suggest a way to do this? And if I insert recod into the CSV file from one dataset how will I insert data from the others at specific headers in the CSV file?</p>
c# asp.net
[0, 9]
840,513
840,514
jquery horizontal news ticker using google jsapi
<p>I need to make some changes to this news ticker which is based on goldyberg's jquery horizontal newsticker using Google JSAPI:</p> <p><a href="http://inetwebdesign.com/jQueryTools/tickers/horizontal-news-ticker2/horizontal-news-ticker3.html" rel="nofollow">http://inetwebdesign.com/jQueryTools/tickers/horizontal-news-ticker2/horizontal-news-ticker3.html</a></p> <p>I have two questions:</p> <ol> <li><p>How do you limit the number of words that are being pulled into the div? Right now it is too long and it wraps.</p></li> <li><p>How do you add the date from the rss feed to the string that is displayed?</p></li> </ol> <p>Here is the code I believe is relevant:</p> <pre><code> parse: function(entries) { var feedMarkup = ''; feedMarkup += '&lt;ul&gt;'; for (var i = 0; i &lt; entries.length; i++) { feedMarkup += '&lt;li&gt;&lt;a target="_blank" href="'+entries[i].link+'"&gt;'+entries[i].title+'&lt;/a&gt;&lt;/li&gt;'; } feedMarkup += '&lt;/ul&gt;'; $("#ticker-content").empty().append(feedMarkup).fadeIn(400); $('#ticker ul li:eq(0)').show(); current = $('#ticker ul li:eq(0)').index(); first = 0; last = $('#ticker ul li').length; </code></pre> <p>Thanks in advance for your help.</p> <p>Regards, umbre</p>
javascript jquery
[3, 5]
3,326,721
3,326,722
Can i use resolveurl in javascript
<pre><code> &lt;script language="javascript" type="text/javascript"&gt; banner2.add("FLASH", "../Banners/1.swf", 10, 60, 468,"http://www.techpint.com","_blank"); banner2.add("FLASH", "../Banners/2.swf", 10, 60, 468,"http://www.tapasya.co.in","_blank"); &lt;/script&gt; </code></pre> <p>now here i want to get the base url of the site so that i can give path to my flash file in all pages. this script is a part of my master page. can i run " &lt;%= ResolveUrl("~/Banners/1.swf") %> " in javascript.</p> <pre><code>banner2.add("FLASH"," &lt;%= ResolveUrl("~/Banners/1.swf") %&gt; ", 10, 60, 468,"http://www.techpint.com","_blank"); </code></pre>
c# asp.net javascript
[0, 9, 3]
4,700,065
4,700,066
Highlight the text using jquery
<p>I have one textbox, button and and list box with some text.</p> <p>When I click on button what ever the text I enter in text if it matches the text in the list box I am trying to highlight that text using jquery I used this code.</p> <p>Jquery Code</p> <pre><code>$("#btnhighlight").click(function () { alert("yes"); var htext = $("#txthighlighttext").val(); alert(htext); $("#lstCodelist").highlight('MD'); }); </code></pre> <p>Style sheet I used to hightlight and i downloaded the highlight plug in added to the project</p> <pre><code>&lt;style type="text/css"&gt; .highlight { background-color: yellow } &lt;/style&gt; </code></pre> <p>Please can any one help me out how to do this. or if I am doing wrong? Can an</p>
javascript jquery
[3, 5]
325,704
325,705
Convert input field to text with jquery?
<p>I need to convert <code>&lt;input type="text" value="1" class="simpleCart_input"&gt;</code> to plain text. Is it possible?</p> <p>Like I need it to be</p> <pre><code>&lt;span class="simpleCart_input"&gt;1&lt;/span&gt; </code></pre> <p>But how?</p>
javascript jquery
[3, 5]
5,518,640
5,518,641
Not violating "compareTo" contract in a changing list
<p>This is kind of a general java question and doesn't relate too much to Android.</p> <p>In my application I have a list of some objects of a medium complex class which implements <code>Comparable</code>. The <code>compareTo()</code> method's result depends on some of the fields. The method is consistent and doesn't violate the comparison contract, when the elements aren't modified during the comparison.</p> <p>Now to the problem. The list must be sorted once in a while. But simultaneously, some items may be updated by a background task, which means that the result of <code>compareTo()</code> changes. That's where the contract may be violated.</p> <p>I understand, that the easiest answer would be, not to update the list during the sorting at all. But it's a mobile application. It has to be responsive and the user may refresh the list whenever he wants.</p> <p>What would be an elegant approach to this problem? Using synchronizing or some kind of lock?</p> <p>Thanks in advance.</p>
java android
[1, 4]
3,966,702
3,966,703
How to add a class to empty h1 with jQuery?
<p>I'd like to add a class 'hideme' to a empty div.</p> <pre><code>&lt;div id="infocontent" class="grid_15 prefix_1"&gt; &lt;h1 id="mainhead" class="grid_15 alpha omega" &gt;&lt;/h1&gt; &lt;div id="infoinner" class="grid_13 prefix_1 suffix_1 alpha omega"&gt; &lt;FORM ACTION="command.asp" METHOD="get" NAME="artForm"&gt; .... ..... </code></pre> <p>I made this but something wrong.</p> <pre><code>$function(){ var contentid = $('#mainhead'); var content = contentid.html(); if (content===''){ contentid.addClass('hideme'); } }) </code></pre> <p>I appreciate you help.</p> <p>Thanks in advance.</p> <p>Update: Sorry it was empty h1.</p>
javascript jquery
[3, 5]
3,200,059
3,200,060
How to display timepicker dialog when radiobutton is clicked?
<p>I'm trying to display time picker dialog by using <code>showDialog(1);</code> when radio button is clicked. But i cannot display if i write onclick event for radio button. How to solv this problem? Any help is appreciated and thanks in advance...</p>
java android
[1, 4]
4,567,109
4,567,110
Using jquery, how do you reorder rows in a table based on a TR attribute?
<p>I have a table with rows similar to the following. These rows get updated from time to time via jquery calls. Using jquery, how would I construct a function that reorders these table rows based on the myAttribute value putting the highest myAttribute value rows at the top and the lowest myAttribute value rows at the bottom? There could be up to 100 rows in the table. </p> <pre><code>&lt;tr id='1' class='playerRow' myAttribute=5&gt; &lt;td&gt; One&lt;/td&gt; &lt;td&gt; Two&lt;/td&gt; &lt;/tr&gt; &lt;tr id='2' class='playerRow' myAttribute=6&gt; &lt;td&gt; One&lt;/td&gt; &lt;td&gt; Two&lt;/td&gt; &lt;/tr&gt; </code></pre>
javascript jquery
[3, 5]
5,569,022
5,569,023
Library file for c# dot net
<p>I'm a relatively new c#.net programmer and need some advice on adding a Library file to a c# project.</p> <p>This project is not done in proper C# fashion and I realize that, but am not looking to solve that today.</p> <p>I have 3 .aspx pages and each has a corresponding .cs file set up as a code behind. That all works fine.</p> <p>Each of the .cs files has several functions that identical. I'd like to move those common functions into a common .cs file that is used by all of the .aspx pages (or the .cs files if that is how to do it) while keeping the unique code behind files for functions unique to that aspx/cs pair.</p> <p>Once the common file is created (it already is), How do I reference that file this as simply as possible?</p>
c# asp.net
[0, 9]
4,830,556
4,830,557
.before to insert multiple elements
<p>I have an element <code>var destination</code> which I'm trying to insert multiple elements before it. I use <code>.before</code> but I use it multiple times because I'm moving multiple elements. </p> <p>Is there a way to improve this code, and move all the elements at once? I'm moving an element <code>moveElement</code>, the element before it, and a number of other elements that have the class <code>myClass</code> using <code>each()</code>. Any way to reduce the number of <code>destination.before()</code></p> <pre><code>destination.before(moveElement.prev()); destination.before(moveElement); $('div.myClass').each(function(){ destination.before($(this)); }); </code></pre>
javascript jquery
[3, 5]
2,290,008
2,290,009
How can i define my own event in jQuery?
<p>How can i define my own event in jQuery?</p>
javascript jquery
[3, 5]
5,368,348
5,368,349
Click on an object, get another object?
<p>On click I get an objects id.</p> <p>The id will be something like 'about-me'.</p> <p>Now in the on click function I want to target the object that's called 'content-about-me'.</p> <p>How can I do this? Ive tried this with no luck:</p> <pre><code>$('.sub-nav').on('click', function(){ $('#content-'$(this).attr('id')); }); </code></pre>
javascript jquery
[3, 5]
4,112,545
4,112,546
Resizing image size using javascript
<p>I am trying to resize the image using javascript, but I am getting errors </p> <pre><code> var y; var y = new Image(); y.src = s; var wd = y.width/600; var ht = y.height/600; if(ht&gt;wd){ var rw=round(wd * (1/ht)); var hw1 = ht * (1/ht); var hw=round(hw1); } else { var rw1 = (wd) * (1/wd); rw=round(rw1); hw=round(ht * (1/wd)); } </code></pre> <p>I am getting errors saying</p> <p>Message: Object expected Line: 27 Char: 2 Code: 0</p> <p>Where line 27 is <code>rw=round(rw1);</code></p> <p>Thanks Jean</p>
javascript jquery
[3, 5]
5,288,754
5,288,755
Get last line from a textarea on keypress
<p>I have a textarea field and on every keypress, I would like to push the last line in the textarea to an array.</p> <p>Currently, I am constructing the array on every keypress to get the last line in the textarea. Is there a way to optimize this? Meaning, get last line in the textarea without having to construct an array.</p> <pre><code>jQuery('#mytextarea').keypress(function() { lines = jQuery('#mytextarea').text().split("\n"); lastLine = lines[lines.length - 1]; </code></pre> <p>});</p> <pre><code>if(.. some condition ..) { myArray.push(lastLine); </code></pre>
javascript jquery
[3, 5]