Unnamed: 0
int64 302
6.03M
| Id
int64 303
6.03M
| Title
stringlengths 12
149
| input
stringlengths 25
3.08k
| output
stringclasses 181
values | Tag_Number
stringclasses 181
values |
---|---|---|---|---|---|
3,515,032 | 3,515,033 |
Enabling default behaviour link by link with jquery
|
<p>I am an html css design type who is not that comfortable with jquery. I have inherited a site with the link default behaviours disabled with what I can see is this code:</p>
<pre><code>$('a').click(function(event) {
event.preventDefault();
var locationHref = window.location.href;
var elementClick = $(this).attr("href");
var destination = $(elementClick).offset().top;
$("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination}, 1000, function() {
window.location.hash = elementClick
});
return false;
</code></pre>
<p>I need to add normal links to this one page website without messing with this code (it enables parallax scrolling). Is there any way I can do this link by link?</p>
<p>BTW I have seen solutions on here but I must confess to not quite understanding them. Thanks.</p>
|
javascript jquery
|
[3, 5]
|
325,059 | 325,060 |
clearInterval not working
|
<p>This most likely just a frustration syntax error on my part. But resizeTime just won't clear. The timer just keeps going regardless of using clearInterval on it more than once. Any ideas folks? I have posted my real code:</p>
<pre><code> var resizeTime; // declared outside of wrapper function to INSURE no second declaration will occur
var myTransitionEvent = whichTransitionEvent();
$(window).bind('adapt', function(){
console.log('start', resizeTime);
resizeTime = setInterval(function(){
console.log('go', resizeTime);
methods.relayoutChildren.apply(self);
}, 5);
setTimeout(function(){
console.log('sNend', resizeTime);
clearInterval(resizeTime);
},1000);
});
$('#allies-wrap').bind(myTransitionEvent, function(){
console.log('end', resizeTime);
clearInterval(resizeTime);
methods.relayoutChildren.apply(self);
});
</code></pre>
<p>Here is a sample log from chrome:</p>
<pre><code> start undefined
start 8215
(10) go 8218
start 8218
start 8221
(256) go 8224
(2) sNend 8224
(9) go 8224
sNend 8224
(3) go 8224
sNend 8224
(2596) go 8224
</code></pre>
<p>for those who don't know chrome's log, (2596) means 2596 occurrences of an identical log. </p>
|
javascript jquery
|
[3, 5]
|
1,592,418 | 1,592,419 |
Open Image from assets using external program
|
<p>I've wrote content provider to open a png file in my app package with an external application (standard image viewer of Android). Image is stored in asset folder.</p>
<p>I cannot understand where is a problem, but it doesn't work for me.</p>
<p>openFile of ContentProvider:</p>
<pre><code> @Override
public ParcelFileDescriptor openFile(Uri uri, String mode) throws FileNotFoundException {
URI file_uri = URI.create("file:///data/data/com.package/assets/image.png");
File file = new File(file_uri.getPath());
ParcelFileDescriptor parcel = ParcelFileDescriptor.open(file, ParcelFileDescriptor.MODE_READ_ONLY);
return parcel;
}
</code></pre>
<p>Starting activity:</p>
<pre><code>Uri uri = Uri.parse("file:///android_asset/image.png");
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(uri, "image/*");
startActivity(intent);
</code></pre>
<p>Is this approach correct and where is my mistake? Or am I totally wrong?</p>
|
java android
|
[1, 4]
|
5,085,895 | 5,085,896 |
Why does IE complain about this js line?
|
<p>Why does IE complain about this javacript call?</p>
<pre><code>$.get("profile_completeness.php?id=<?php echo($user_id); ?>", function(data) {
var percentage = data.match(/id="percentage_complete" value="(\d+)"/)[1];
alert(percentage);
})
</code></pre>
<p>This works fine in Chrome, and FF but IE throws an exception.</p>
<p>Here is the error I get:</p>
<pre><code>Unable to get value of the property '1': object is null or undefined.
</code></pre>
<p>If I remove the var percentage line the error is gone.</p>
<p>Any ideas why?</p>
|
javascript jquery
|
[3, 5]
|
4,321,832 | 4,321,833 |
asp:imagebutton, change image from javascript / jquery
|
<p>How can i change the image of an image button clientside, on click.</p>
<p>I have tried this:</p>
<pre><code>function changetoDownload(theId) {
$(theId.id).delay(2000)
.queue(function (next) { $(theId).attr("ImageURL", "Images/Apps/free.png"); next(); });
}
<asp:ImageButton ID="ImageButton1" OnClick="Button7_Click" OnClientClick="changetoDownload(this.id);" ImageUrl="Images/download.gif" runat="server" />
</code></pre>
|
javascript jquery asp.net
|
[3, 5, 9]
|
1,519,550 | 1,519,551 |
How to register Javascript function to find when HiddenField value changed?
|
<p>I have a page that contains a <code>HiddenField</code> control, I register some javascript on page load which contains a function I want to run when the HiddenField value has changed. </p>
<p>Currently, I have the following code which executes the function if an input field's value has changed:</p>
<pre><code>$(':input').change(function(){ pageHasBeenUpdated = true; });
</code></pre>
<p>What javascript would I need to set <code>pageHasBeenUpdated = true</code> if the value of the <code>HiddenField</code> control has been updated?</p>
|
c# javascript jquery asp.net
|
[0, 3, 5, 9]
|
3,071,043 | 3,071,044 |
How to get the icon of other applications (Android)
|
<p>What I'm doing is getting a list of all the current running processes on the phone. Which I have done by, </p>
<pre><code>private List<RunningAppProcessInfo> process;
private ActivityManager activityMan;
...
activityMan = (ActivityManager)getSystemService(Context.ACTIVITY_SERVICE);
process = activityMan.getRunningAppProcesses();
</code></pre>
<p>this works fine. When I call the processName field like</p>
<pre><code>process.get(i).processName;
</code></pre>
<p>I get a name like com.android.mail for example.</p>
<p>what I'm trying to do is use this to get access to that application so I can display its icon to the user, but I cant find anything that lets me do this. Is there something that can help me? </p>
<p>I'm testing this app on my hero so the api level is 3 (android 1.5). </p>
<p>Thanks.</p>
|
java android
|
[1, 4]
|
5,571,368 | 5,571,369 |
StreamWriter truncating text while writing to a text file
|
<p>I have a huge HTML content in a string variable and I want to write that content to a text file using stream writer but the stream writer is truncating the text. It is not wrting the whole content to file. I am using the following code:-</p>
<pre><code>using (StreamWriter sw = new StreamWriter(completeFilePath))
{
sw.Write(Html);
}
</code></pre>
<p>where Html is the string type variable. Please help.</p>
|
c# asp.net
|
[0, 9]
|
882,211 | 882,212 |
How can I keep the focus on an input field if the input is incorrect
|
<p>Given the following code:</p>
<pre><code>sPosSelect="#fpJpos input[name=posnum" + iiPos + "]";
if (fIn>fPosMaxWtUse[iiPos]) {
alert(sprintf('%.0f is %.0f more than the position max of %.0f.',fIn,fIn-fPosMaxWtUse[iiPos],fPosMaxWtUse[iiPos]));
$(sPosSelect).val('');
$(sPosSelect).focus();
return;
}
</code></pre>
<p>It works in that I get the alert, and the field is blanked. However, the focus then moves on to the next field when what I want is for it to stay on the field just blanked so the user can try again.</p>
<p>All suggestions are welcome, including anything I'm doing that could be done in a better way.</p>
<p>Terry </p>
|
javascript jquery
|
[3, 5]
|
3,675,387 | 3,675,388 |
webservice in jQuery returns collection type
|
<p>I have an ASP.NET WebService that returns an object of List</p>
<pre><code>public class Students
{
public string StudentName { get; set; }
public int Age { get; set; }
}
</code></pre>
<p>I am accessing this webservice using this jQuery code</p>
<pre><code>$.ajax({
type: "POST",
url: "/Students.asmx/GetStudents",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(msg) {
$("#myDiv").html(msg.d);
}
});
</code></pre>
<p>But all i get is Object object.</p>
<p>How can I get the data in that object?</p>
|
asp.net jquery
|
[9, 5]
|
5,383,468 | 5,383,469 |
jquery load() after a h4 tag
|
<p>How do I get jqery's load to load sometime after a particular tag? In my case, I'll be loading a form after the h4 tag. That's where it needs to go. My problem is: the H4 tag will disappear. Is there anyway to get the form to load under the H4 tag?</p>
<p>jquery:</p>
<pre><code>$("#loadForm").click(function() {
$("#entry").load("load.forms.php?option=" + $("#loadForm").val());
});
</code></pre>
<p>markup:</p>
<pre><code><div id="post">
<div id="entry">
<h4>My Heading</h4>
//The Form goes here
</div>
</div>
</code></pre>
|
javascript jquery
|
[3, 5]
|
1,951,134 | 1,951,135 |
how to make trial version of win and web application in .Net technology
|
<p>how to develop a trial version of window or web application in dotnet technology. as a result user can use that windows or web apps for certain day and also will not be able to use after resetting his system clock.how could make this type of trial version both in window and web.
please give me the concept in detail.</p>
<p>thanks</p>
|
c# asp.net
|
[0, 9]
|
4,778,198 | 4,778,199 |
Can I record the mouse movements?
|
<p>I would like to record mouse movements and clicks.</p>
<p>Can I do it with JQuery or other JS library?</p>
<p>Thank you</p>
|
javascript jquery
|
[3, 5]
|
150,770 | 150,771 |
Page.User.Identity.Name returns empty string
|
<p>For some Page.User.Identity.Name always returns an empty string. Any ideas. I simply want to print it to the screen. IIS is set for integrated windows security.</p>
<p>Response.Write("Name = " + Page.User.Identity.Name);</p>
<p>Oops just noticed i hadnt set authentication to windows auth. Silly me</p>
|
c# asp.net
|
[0, 9]
|
1,234,634 | 1,234,635 |
How to backpress pass an activity?
|
<p>I have an activity that loads some content using an AsyncTask.</p>
<p>If the content is null then i launch an activty that contains a WebView to load the data.</p>
<p>The only problem is when i launch the activity using regular intents. </p>
<p>When the back button is pressed to return out of the WebView.</p>
<p>It returns to the following activity and the AsyncTask is ran again, and it does the same thing all over again. </p>
<p>I know how to Override the onBackPressed button. But what should i do to override this from happening each time?</p>
|
java android
|
[1, 4]
|
3,848,326 | 3,848,327 |
Pass a JS variable to a PHP variable
|
<p>I have a JavaScript value given by Google maps and I need to save it in a MySQL database.</p>
<p>Actually I have the variable </p>
<pre><code><script>
...
var lugar = results[0].geometry.location;// this gives me a latitud, longitud value, like: -34.397, 150.644
...
</script>
</code></pre>
<p>And I need to pass that variable to the PHP variable lugar</p>
<pre><code><?
$lugar= ?????
?>
</code></pre>
|
php javascript
|
[2, 3]
|
3,179,332 | 3,179,333 |
can't verify password input while using Titanium Mobile?
|
<p>I have a trouble in password validation while using Titanium mobile. Please help me out. This is my code</p>
<pre><code>var re = /(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{6,}/;
if(re.test(newPass))
{
return true;
} else
{
alert("Password must contain at least one number, one lowercase and one uppercase letter");
return false;
}
</code></pre>
<p>It is supposed to go return true if I write the password: Abc123, or Abc1A23. But it keep returning to me false value. Even though I tried this peace of code on the web browser. And it works fine. I don know whether Titanium mobile understands this: <code>var re = /(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{6,}/;</code> or not. Or I need to write it differently. Please help me out.
Thanks a lot.</p>
|
javascript iphone
|
[3, 8]
|
4,166,646 | 4,166,647 |
How to get the URL of the current page in C#
|
<p>Can anyone help out me in getting the URL of the current working page of ASP.NET in C#?</p>
|
c# asp.net
|
[0, 9]
|
5,740,142 | 5,740,143 |
Javascript checkbox crazy if statement
|
<p>I've got a command.cgi that returns a website url, if the checkbox with id="simple" is checked then redirect the user to that page, if not, add the html formatted link to a container.
The problem is that it doesn't redirect the user to a html formatted link when the checkbox is checked and when it does, it redirects the user to a formatted html link, it's crazy.
Any solution? Thanks</p>
<pre><code><script type="text/javascript">
$(document).ready(function() {
$("#sudo").click(function(event){
if ($("#simple").attr('checked')==1){
$.get("/cgi-bin/command.cgi",
{ cmd: $("#cmd").val()},
function(data) {
window.location.href=data;
});
}else{
$.get("/cgi-bin/command.cgi",
{ cmd: $("#cmd").val()},
function(data) {
$('#resultado p').prepend("<a href=\"" + data + "\" target=\"_blank\">" + data + "</a><br><br>");
$("#cmd").val('');
$("#cmd").focus();
});
}
});
$("#cmd").keyup(function(e){
if(e.keyCode == 13){
$("#sudo").click();
}
});
});
</script>
</code></pre>
|
javascript jquery
|
[3, 5]
|
1,430,018 | 1,430,019 |
How to save "title" attribute of "a" with jQuery?
|
<p>How can I save the value of the title for a row? These are the values of the <code>title=%s:</code></p>
<pre><code><a class="false" title=1106 href="/useradminpage?main_id=%s&display=false"><span class="small">(hide)</span></a>
<a class="false" title=1153 href="/useradminpage?main_id=%s&display=false"><span class="small">(hide)</span></a>
<a class="false" title=1175 href="/useradminpage?main_id=%s&display=false"><span class="small">(hide)</span></a>
</code></pre>
<p>...</p>
<p>I've tried countless variations but none of them work. This is what I have now:</p>
<pre><code><script>
$(document).ready(function() {
console.log("ready");
$("a.false").click(function(e) {
$(this).closest("tr.hide").hide("slow");
var main_id = a.title;
var display = "false";
e.preventDefault();
});
$("a.false").click(function() {
$.ajax({
url: "/useradminpage?main_id=%s&display=false",
data: {main_id: "main_id", display: "display"},
success: function(data) {
display_false()
alert("4 - returned");
}
});
});
});
</script>
</code></pre>
<p>This is the third question on this topic. I appreciate any help. Thanks.</p>
|
javascript jquery
|
[3, 5]
|
746,278 | 746,279 |
Add Slide effect to Sliderman.js
|
<p>I'm using the Sliderman.js (http://www.devtrix.net/sliderman/examples.html) but can't seem to figure out how to get a simple effect to work, all the big ones work fine, just want my images to slide in from the right and slide out from the left so basically like a loop, need to modify the code but don't know how, help!</p>
<p>The source code is avaliable here: <a href="http://www.devtrix.net/sliderman/examples.html" rel="nofollow">http://www.devtrix.net/sliderman/examples.html</a></p>
<p>Thanks in advance.</p>
|
javascript jquery
|
[3, 5]
|
1,615,658 | 1,615,659 |
Expandable Listview image changes on click?
|
<p>I have the below code running perfectly. When a user clicks on a group and it expands the image changes due to a change in the state. The xml file is below aswell. The problem I have is when I click on a child element it starts a new activity, but just before you can see that the image changes state to as if the group was closed. When you use the back arrow the image is indeed back to the closed state even though the group is still expanded. Can anyone shed any light on this?</p>
<pre><code>private static final int[] EMPTY_STATE_SET = {};
private static final int[] GROUP_EXPANDED_STATE_SET = {android.R.attr.state_expanded};
private static final int [] [] GROUP_STATE_SETS = {
EMPTY_STATE_SET, //0
GROUP_EXPANDED_STATE_SET //1
};
Cursor groupCursor = checkDB.rawQuery("SELECT * FROM TABLE", null);
mscta = new MySimpleCursorTreeAdapter(
this,
groupCursor,
R.layout.listGroup,
new String[] {"group"},
new int[] {R.id.group},
R.layout.listChildren,
new String[] {"child"},
new int[] {R.id.Child}) {
@Override
public View getGroupView (int groupPosition,
boolean isExpanded,
View convertView,
ViewGroup parent) {
View v = super.getGroupView( groupPosition, isExpanded, convertView, parent);
View ind = v.findViewById(R.id.explist_indicator);
if(ind != null){
ImageView indicator = (ImageView) ind;
indicator.setVisibility( View.VISIBLE );
int stateSetIndex = ( isExpanded ? 1:0);
Drawable drawable = indicator.getDrawable();
drawable.setState(GROUP_STATE_SETS[stateSetIndex]);
}
return v;
}
};
</code></pre>
<p>XML explist_indicator.xml</p>
<pre><code><selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_expanded="true"
android:drawable="@drawable/minus" />
<item
android:drawable="@drawable/plus" />
</selector>
</code></pre>
|
java android
|
[1, 4]
|
3,672,172 | 3,672,173 |
problems with create an object on post back
|
<p>i have an issue with creating an object in ASP.net</p>
<p>My Page Load function is:</p>
<pre><code>public partial class hangMen : System.Web.UI.Page
{
abc ltr;
Words word = null;
static Label [] lbl = null;
static Button[] btn = null;
Game game;
protected void Page_Load(object sender, EventArgs e)
{
if (Page.IsPostBack)
{
show_current_word();
SetBord();
}
else
{
SetBord();
SetWords();
}
}
}
</code></pre>
<p>My issue is:
Iam not sure where should i put the
game = new Game();</p>
<p>if i put it in the else part so i get null reference exception.
and i also dont want to create this oject every post-back.</p>
<p>this object count the player score and the times that click "Hint" and make a wrong </p>
<p>any ideas??</p>
|
c# asp.net
|
[0, 9]
|
1,291,860 | 1,291,861 |
Why my edit button works only once even I use $('[isEditButton="true"]').on()?
|
<p>Here is my code, and I has been really frustrating on identifying the problem.</p>
<p>I tried to use </p>
<pre><code>$('[isEditButton="true"]').on('click', function(){ codes })
or
$('table tr td').on('click', '[isEditButton="true"]' , function(){ codes })
</code></pre>
<p>but both yield unexpected result, the edit button can only be clicked once.</p>
<p>I searched the Jquery doc and used the so-called <a href="http://api.jquery.com/on/" rel="nofollow">Delegated events</a>, however, still did not work, the edit button is clicked once, also the newly injected button cannot be automatically attached the click event.</p>
<p>My online code</p>
<p><a href="http://jsfiddle.net/dennisboys/mAjmU/2/" rel="nofollow">http://jsfiddle.net/dennisboys/mAjmU/2/</a></p>
<p>Anyone can give me some pointers on what is going on. I am really crazy on this problem. Thanks in advance for any kind helpers! Really need you guys!</p>
|
javascript jquery
|
[3, 5]
|
1,200,413 | 1,200,414 |
Activity loading time issue( performance issue while loading Activity)
|
<p>Am moving from one Activity to another activity, in second activity am showing the listview. Am using arraylist's data to fill the listview, so for that i have used "for" condition for looping. so for that looping its taking time to load that page. That page loading time is depending up on the data in the arraylist, if there is more data in the arraylist then looping taking time.
Is there any way to reduce page loading time. </p>
|
java android
|
[1, 4]
|
2,305,954 | 2,305,955 |
Paging on GridView
|
<p>I'm stuck at the moment on how to show my Grid Data in another page.</p>
<p>Basically I have a GridView name "gdvRiders" with Paging Enabled. The problem is when I click on Page 2, I get a blank Page with no Data. Can someone help me? I'm starting to learn c#</p>
<p>Here is my code:</p>
<pre><code>protected void Page_Load(object sender, EventArgs e)
{
DataBase db = new DataBase(true);
string strSQL;
DataTable dt;
if (!IsPostBack)
{
strSQL = "SELECT r.surname, r.firstname, cn.country, r.age, f.flagurl " +
"FROM (Riders r INNER JOIN par_CountryNation cn ON r.countryid = cn.countryid) INNER JOIN par_Flags f ON cn.flagid = f.flagid ";
dt = db.getDataTableAc(strSQL, "list_Riders");
gdvRiders.DataSource = dt;
gdvRiders.DataBind();
}
}
protected void gdvRiders_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
gdvRiders.PageIndex = e.NewPageIndex;
gdvRiders.DataBind();
}
}
</code></pre>
|
c# asp.net
|
[0, 9]
|
3,239,841 | 3,239,842 |
Python-like decorators in Java?
|
<p>I spend most of my time programming in Python, so forgive me if my approach to this problem is short-sited:</p>
<p>I want to have certain methods of a class require login credentials. Simply, each method should check whether the class variable <code>user</code> is set, and if so, continue, but if not, spit out a "you need to login" message.</p>
<p>In Python, I would just write a decorator to do this. How can I accomplish the same thing in java with as little redundant code as possible?</p>
<p>Thanks!</p>
|
java python
|
[1, 7]
|
1,118,660 | 1,118,661 |
IE7 opacity problem by Dropdown menu
|
<p>in the following website we have a dropdown menu with rollover effact.
this function perfactly but in IE7 the opacity is not working correctly.</p>
<p>Any tip?</p>
<p><a href="http://webentwicklungsserver.ch/2011-08-25/index.php" rel="nofollow">http://webentwicklungsserver.ch/2011-08-25/index.php</a></p>
<p>As both white and Gray text will be displayed and is difficult to read.</p>
|
javascript jquery
|
[3, 5]
|
4,066,870 | 4,066,871 |
Is it possible to send an arraylist as a response to jquery?
|
<p>Is it possible to send an arraylist as a response(from action class) to jquery?If so please give sample code</p>
|
java jquery
|
[1, 5]
|
3,224,465 | 3,224,466 |
Using Android libs on a desktop Java VM (like OpenJDK or OracleJDK)
|
<p>I have never tried out the Android SDK and do not own an Android phone. However it seems that certain libraries are excellent, for example the text to speech lib. Is it possible to use this library with a desktop VM and did anybody here try this?</p>
|
java android
|
[1, 4]
|
342,901 | 342,902 |
How to get value of "this"?
|
<p>I have this code:</p>
<p>HTML:</p>
<pre><code><!DOCTYPE html>
<html>
<head>
<title>To Do</title>
<link rel="stylesheet" type="text/css" href="stylesheet.css"/>
<script type="text/javascript" src="script.js"></script>
</head>
<body>
<h2>To Do</h2>
<form name="checkListForm">
<input type="text" name="checkListItem"/>
</form>
<div id="button">Add!</div>
<br/>
<div class="list"></div>
</body>
</html>
</code></pre>
<p>Javascript/Jquery:</p>
<pre><code>$(document).ready(function()
{
$(button).click(function(){
var toAdd = $('input[name=checkListItem]').val();
$('.list').append('<div class="item">' + toAdd + '</div>');
});
$(document).on('click','.item', function(){
$(this).remove();
});
});
</code></pre>
<p>This code grabs a user's input, adds it to a list when you click a button, and removes the input from the list when you click on it within the div class item.</p>
<p>How can I make it so that I can return the value of "this"?</p>
<p>For example, if I add the word "test" to the list, and click on it to remove it.... how can grab the value of test from "this"?</p>
<p>Like.. document.write(this) returns [object HTMLDivElement].</p>
<p>I want document.write to return "test" if I click on it in the div.</p>
<p>I can't do document.write(toAdd) because toAdd doesn't exist in the second jquery ("on") function.
Thanks.</p>
|
javascript jquery
|
[3, 5]
|
4,490,258 | 4,490,259 |
implement specific file to a class in android
|
<p>I have developed an application in android. I have a file 'Constants.java' implemented to an activity. This file contains constant values for application. I need to change this constants file according to device resolution.</p>
<p>Is there a way where I can build a preprocessor, where in I can check the resolution of device, and implementa particular file accordingly,
example:
implement constants.java file for 240x320 and implement constants1.java file for 320x480</p>
<p>I tried fetching the integer values from strings.xml file, but it gives me a null pointer exception at <code>Resources res = getResources()</code>, when getResources() is called outside a method.</p>
<p>please help!!</p>
|
java android
|
[1, 4]
|
1,057,412 | 1,057,413 |
Does jQuery do some magic with the `this` variable?
|
<p>jQuery has gotten us used to the following <code>this</code> pattern:</p>
<pre><code>$(selector).each(function () {
// do something with `this`
// `this` iterates over the DOM elements inside `$(selector)`
});
</code></pre>
<p>According to <a href="http://www.youtube.com/watch?v=ya4UHuXNygM" rel="nofollow">this Crockford talk</a> (about 15 minutes in) the value of <code>this</code> inside a function that is not called with the <code>new</code> operator is the global object, except for ES5 strict mode in which case it is <code>undefined</code>.</p>
<p>Does jQuery do some magic with <code>this</code> to get it to something other than the global object? Please point to specific lines of the source code.</p>
|
javascript jquery
|
[3, 5]
|
2,582,546 | 2,582,547 |
how to make an ajax request after sending data by post?
|
<p>i meet a problem, when try to make an ajax request after sending data by post.</p>
<p>let's assume i have a index.php file. In the form i send data by post to the same file, and after posting i want to make ajax request, but it don't doesn't happen, because it "wants" to ask about resending data, but it doesn't show in popup window.</p>
<p>So, how can i disable the question about resending data, to be possible to make an ajax request?</p>
<p>Thanks</p>
|
php javascript jquery
|
[2, 3, 5]
|
2,839,361 | 2,839,362 |
unterminated string literal Javascript
|
<p>I'm using the following code in php:</p>
<p>PHP:</p>
<pre><code> $suggested_sentence[0] = "Hello, how are you?";
echo $suggested_sentence[0] . ' <input type="image" src="button.png"
onclick = update_textarea('. $textareacount.','. "'".$suggested_sentence[0]."')/>";
</code></pre>
<p>Javascript function:</p>
<pre><code>function update_textarea(count, new_sentence) {
document.getElementById('sentence' + count).value = new_sentence;
}
</code></pre>
<p>But when i press the button i get the error "unterminated string literal but if i change the value of <code>$suggested_sentence[0] = "Hello"</code> it works fine.</p>
<p>What should i do then?</p>
|
php javascript
|
[2, 3]
|
410,296 | 410,297 |
How do I access this variable outside of this jquery loop?
|
<p>I have a simple jquery loop that goes through my form and </p>
<ol>
<li>sees if there is empty fields. </li>
<li>If any are empty, mark them with an 'empty' class and </li>
<li>then create a 'error' variable</li>
</ol>
<p>Basically:</p>
<pre><code>// check all the inputs have a value...
$('input').each(function() {
if($(this).val() == '') {
$(this).addClass('empty');
var error = 1;
}
});
</code></pre>
<p>This works a charm. However, as my code continues, I can't seem to access that 'error' variable... as though it is locked inside the each loop. With the following code being right after the .each() loop, I never get my_error_function() to fire, even though I know that criteria 1 and 2 are working.</p>
<pre><code>if(error == 1) {
my_error_function();
} else {
my_non_error_function();
}
</code></pre>
<p>How do I access this variable so I can use its result elsewhere in the code?</p>
|
javascript jquery
|
[3, 5]
|
1,341,837 | 1,341,838 |
return a single html element with jquery
|
<p>How can I get jQuery to return a html element exactly the way that <code>getElementById</code> does?</p>
<p>if I <code>console.log($('#container'))</code> I will get : </p>
<pre><code>[<div id="container"></div>]
</code></pre>
<p>But the API I am interacting with obviously doesn't want that (an array) - it wants : </p>
<pre><code><div id="container"></div>
</code></pre>
<p>I know I can achieve this with <code>$('#container').get(0)</code> and a few other ways, It just seems overkill - especially as I'm selecting an ID which will always be unique. </p>
<p>What am I missing guys?</p>
<p>Thanks</p>
|
javascript jquery
|
[3, 5]
|
2,768,557 | 2,768,558 |
Can I convert all files with jquery file upload to jpg?
|
<p>I'm using the <a href="http://blueimp.github.com/jQuery-File-Upload/" rel="nofollow">jquery file upload</a> script and it's working really well so far. The last obstacle I have is I only want to use <strong>jpg</strong> images for my website but allow users the option of uploading gif, png, or jpg. </p>
<p>I'm assuming I need to alter or add some additional methods to the upload.class.php file to accomplish this.</p>
<p>Has anyone done this before and if so is this the correct file to modify?</p>
|
php jquery
|
[2, 5]
|
5,324,559 | 5,324,560 |
Question about inline aspx tags
|
<p>I have this div that's got a style attribute..In that I am setting it's background image by calling a function from code behind..</p>
<pre><code><div id="id1" style = "background-image: url(<%=GetImage()%>);"></div>
</code></pre>
<p>now when I add runat="server" attribute in this div..it shows the Image path as method name itself and not <a href="http://localhost/myweb/images/image.jpg" rel="nofollow">http://localhost/myweb/images/image.jpg</a></p>
<p>when I remove runat..image path displays alright..Isn't the runat supposed to be there because it's got inline aspx tag ??? I am confused.</p>
|
c# asp.net
|
[0, 9]
|
4,637,386 | 4,637,387 |
Change server IPAdress and perform a redirection automatically
|
<p>I have created an web based application through which the users can change the server (where the web application is hosted) IPAddress.</p>
<p>The problem is that, once i have changed the IPAddress to a new IPAddress, Response.Redirect("MyHome.aspx") is not working any more. I have also tried to redirect the user to the newly updated address but even it doesn't do the trick. No page found message appears after some time.</p>
<p>For example: The url while the web application runs in IIS is : <a href="http://192.168.0.65/WebDemo/Default.aspx" rel="nofollow">http://192.168.0.65/WebDemo/Default.aspx</a> after changing the IPAddress to 192.168.0.66 and redirecting it with the Response.Redirect() method the <a href="http://192.168.0.65" rel="nofollow">http://192.168.0.65</a> is not accessible.</p>
<p>Any idea of achieving this task of changing IPAddress of the server and doing an automatic redirect to the newly assigned IPAddress, will be highly appreciated!</p>
|
c# asp.net
|
[0, 9]
|
1,928,885 | 1,928,886 |
error paging and editing in gridview
|
<p>I had gridview which retrieve Products from database by sqldatasource1 ,and my manager asked me to filter this gridview by DDL to filter gridview with specfic Model ,I add some function on gridview as edit,paging .I did my code well and gridview filtred by the Model_Id which come from DDL .But when I tried to edit any product or navigate through paging I faced this error (The GridView 'GridView1' fired event PageIndexChanging which wasn't handled. )when paging ,And this for editing (The GridView 'GridView1' fired event RowEditing which wasn't handled.)
So please any one help me.</p>
<p>(CS)</p>
<pre><code> protected void Page_Load(object sender, EventArgs e)
{
BindGridFunction();
}
private void BindGridFunction()
{
if (DDLModel.SelectedIndex < 0)
{
GridView1.DataSource = SDSModel;
GridView1.DataBind();
}
else
{
GridView1.DataSource = SDSModel2;
GridView1.DataBind();
}
}
</code></pre>
|
c# asp.net
|
[0, 9]
|
227,738 | 227,739 |
How to display an alert if none of the case statements match?
|
<p>I have a case statement below where it checks for a file type in a file input which works correctly:</p>
<pre><code>function imageValidation(imageuploadform) {
var val = $(imageuploadform).find(".fileImage").val();
switch(val.substring(val.lastIndexOf('.') + 1).toLowerCase()){
case 'gif':
case 'jpg':
case 'jpeg':
case 'pjpeg':
case 'png':
return true;
default:
$(imageuploadform).find(".fileImage").val();
// error message here
alert("To upload an image, please select an Image File");
return false;
}
return false;
}
</code></pre>
<p>Now what happens is that if it matches one of the case statements then it returns true and by default it returns an alert which I want to use if file input is blank.</p>
<p>But how can I display this alert: </p>
<pre><code>alert("Image File Type is Incorrect. Must be either: \n (jpg, jpeg, pjpeg, gif)")
</code></pre>
<p>If the file input does not match with one of the file type cases above?</p>
|
javascript jquery
|
[3, 5]
|
363,057 | 363,058 |
Jquery on new Window objects?
|
<p>Is it possible to use jQuery on a new Window javascript object?</p>
<p>Example:</p>
<pre><code>win = new Window('mywindow','width= 400', 'height=400');
win.getContent().innerHTML = xmlFindNodeContent(XmlHttp.responseXML, "windowHtml");
jQuery(win).ready(function(){
do jQuery stuff on the new window here??
});
</code></pre>
<p>Is something like this possible?</p>
<p>NB: new Window() function takes some parameters before it works properly. Something like this:</p>
<p>window.open('mywindow','width=400,height=200')</p>
|
javascript jquery
|
[3, 5]
|
4,469,880 | 4,469,881 |
USB Host Development on Android 2.3 Device
|
<p>I just got a development kit that have a physical two USB Host port and the Android specification says it support USB Host, I am curious about this as USB Host is introduced in Android 3.1, where my kit only have Android 2.3</p>
<p>Does this mean that I can use the API as described here:</p>
<p><a href="http://developer.android.com/guide/topics/connectivity/usb/host.html" rel="nofollow">http://developer.android.com/guide/topics/connectivity/usb/host.html</a></p>
|
java android
|
[1, 4]
|
5,325,183 | 5,325,184 |
How to differentiate two links with the same content using jQuery?
|
<p>I have a page that contains two links with the same text "Add new item", but are targeting different URLs. </p>
<p>I created a javascript that uses jQuery library which references the link by its text. The code is: </p>
<pre><code>var anchorElement = $("a:contains('Add new item')");
</code></pre>
<p>This is fine when I want to reference the first link. But, how do I reference the second one, being that they have the same text? Thanks. </p>
|
javascript jquery
|
[3, 5]
|
3,726,759 | 3,726,760 |
How do I make new elements draggable with jquery?
|
<p>I'm loading new elements with a form. After the elements are loaded I need to make each one draggable. According to .on doc <em>"Delegated events have the advantage that they can process events from descendant elements that are added to the document at a later time."</em></p>
<p>I've tried oh-so-many variants of .on, .click, etc but so far no luck. I'm currently working with...</p>
<pre><code> $('#parent').on('change', '.thumb', function(event){
alert('loaded');
$('.thumb').draggable();
});
</code></pre>
<p>...but, it doesn't attach to the new .thumb element. How can I accomplish this?</p>
<p>Edit: Here's the html...</p>
<pre><code> <input type="file" id="parent" name="files[]" multiple />
<output> //these spans are created after files are selected from 'file'
<span><img class=".thumb" src="..."></span>
<span><img class=".thumb" src="..."></span>
</output>
</code></pre>
|
javascript jquery
|
[3, 5]
|
5,276,954 | 5,276,955 |
How do I bind a dynamically created asp textbox to a dataset?
|
<p>I have a textbox generated by parsing an xml file.</p>
<pre><code> TextBox tb = new TextBox;
tb.ID = "MYDATA"
Parent.Controls.Add(tb);
</code></pre>
<p>I then read another Xml file for the data to populate the created TextBox. I have been trying all sorts of databinging and setting the text property to a dataset, but cannot figure it out. If I set the text property at creation to say:</p>
<pre><code>MyDataSet.Tables[0].rows[0].["MYDATA"].ToString();
</code></pre>
<p>I get an error because the dataset hasn't been created and wont be until the form has been created. Am I going about this wrong? Can't I someway specify that the data to fill the textbox is coming from the dataset without already creating it?</p>
|
c# asp.net
|
[0, 9]
|
2,995,069 | 2,995,070 |
My site works fine in FF, but IE7 gives me error
|
<p>Here is my site:
<a href="http://www.sumsy.com/temp/templatesys/config.php?template=1" rel="nofollow">http://www.sumsy.com/temp/templatesys/config.php?template=1</a></p>
<p>IE6, 7 give me errors.</p>
<p>Line 9
Char 3
Expected identifier, string or number
Code 0
URL: config.php?template=1</p>
<p>so for situation like this, how do you guys debug it?
I dont even know the error is coming from JS code or Php code.
IE doesnt say which file.</p>
<p>Thanks</p>
|
php jquery
|
[2, 5]
|
752,136 | 752,137 |
Show hidden download box after user shares a link
|
<p>I am trying to make a hidden download box div appear after a visitor shares a link.I've tried here something <a href="http://jsfiddle.net/trefu/qNDJB/4/" rel="nofollow">http://jsfiddle.net/trefu/qNDJB/4/</a> but is not working. I don't know how to define FB so it can be called. Can someone help me?</p>
<pre><code> <div id='fb-root'></div>
<div id="download_box" style="display: none;">
Download Box (whatever that means) goes here
</div>
FB.init({appId: "437410746335629", status: true, cookie: true});
function postToFeed() {
// calling the API ...
var obj = {
method: 'feed',
link: 'https://developers.facebook.com/docs/reference/dialogs/',
picture: 'http://fbrell.com/f8.jpg',
name: 'Facebook Dialogs',
caption: 'Reference Documentation',
description: 'Using Dialogs to interact with users.'
};
function callback(response) {
if (response && response.post_id) {
document.getElementById('download_box').style.display = 'block';
} else {
alert('You must share your post before you can download.');
}
}
FB.ui(obj, callback);
}
</code></pre>
|
javascript jquery
|
[3, 5]
|
5,915,589 | 5,915,590 |
How to create a .sln file in Visual Studio 2010
|
<p>I have all the folders for a solution file for ASP.NET but I want to create a <code>.sln</code> file including those folders. How to create a .sln file? Please help me.</p>
<p>Example I have downloaded all the folders which are running in server. But I can't create a <code>.sln</code> file file for running that project in local PC.</p>
<p>Guide me How.??</p>
|
c# asp.net
|
[0, 9]
|
799,423 | 799,424 |
Getting inner html tag's text
|
<p>How can I get text stored inner <code><td></code> html tag? I've used <code>var v = $('td[class=someCls]').html()</code> but when I try to output it using <code>cosole.log(v)</code> it outputs unexpected string. how can i fix it?
<a href="https://docs.google.com/document/d/1ed0sDo98ST87gIURI7XO63drdv3dXqa_rSK_pZaiQ-0/edit" rel="nofollow">html</a>
<a href="https://docs.google.com/document/d/1DTOmxtWptxA1JGJpzuwOw54aFXgm8yrQlQmaUwgdwYY/edit" rel="nofollow">jquery</a></p>
|
javascript jquery
|
[3, 5]
|
4,422,807 | 4,422,808 |
How to get a value from a JSON hash
|
<p>In a jquery ajax call I get sent back some JSON from the server and want to use some of it in the success callback. I pass in the data, but how do I get at a specific value (say "id")?</p>
<p>I tried this but I get undefined:</p>
<pre><code> success : function(data) {
alert(data["id"]);
},
</code></pre>
|
javascript jquery
|
[3, 5]
|
488,839 | 488,840 |
deleting parent which deleting child jquery
|
<p>I want to delete only the parent div and keep their children as it is :</p>
<pre><code> <div id="main">
<div id="1"></div>
<div id="2"></div>
</div>
</code></pre>
<p>How we can delete only the <code>#main div</code> without deleting its <code>children div #1 & #2</code>?. I tried <code>detach()</code> but it didn't work.</p>
|
javascript jquery
|
[3, 5]
|
3,736,100 | 3,736,101 |
How to find the Iframe content scrollheight and scroll width?
|
<p>I'm new to this Jquery and i have a trouble to find the iframe scrollheight and scrollwidth when the iframe hosting the external webpage.
i tried following code but its doesn't work and i searched a lot.</p>
<pre><code>$.fn.hasVerticalScrollbar = function () {
// This will return true, when the div has vertical scrollbar
return $frame[0].document.documentElement.offsetHeight() > this.height();
}
$.fn.hasHorizontalScrollbar = function () {
// This will return true, when the div has horizontal scrollbar
return $frame[0].document.documentElement.offsetWidth() > this.width();
}
</code></pre>
<p>help please.</p>
|
javascript jquery
|
[3, 5]
|
4,842,122 | 4,842,123 |
function is setting all instead of each
|
<p>I have a simple function that sets the width of a bar based on an argument.</p>
<p>And I call the function on .each with jQuery.</p>
<p>The console logs the statement correctly, showing me it seems to work. However, the style seems to be overridden by the last value found.</p>
<p>Here is the function:</p>
<pre><code>function barGraph(innerWidth, barWidth) {
innerWidth = parseInt(innerWidth) * .01 || .50;
barWidth = parseInt(barWidth) || 267;
// find percentage of total width
var innerWidth = Math.floor(innerWidth * barWidth);
var $innerBar = $('.slider-box div');
$innerBar.css('width', innerWidth + 'px');
console.log("Width should be: " + innerWidth + 'px');
}
</code></pre>
<p>then i call the function on each with jQuery:</p>
<pre><code>$(document).ready(function() {
var $innerBar = $('.slider-box div');
$innerBar.each(function(index) {
var newWidth = $(this).attr("data-bar-width");
barGraph(newWidth, 267);
});
});
</code></pre>
<p>the console log shows 10 times, with all appropriate widths. However, the style for all is the same as the last width.</p>
<p>Can someone help explain how I get the function to set the width of the currently selected div?</p>
<p>Thanks so much in advance,</p>
<p>Adam.</p>
|
javascript jquery
|
[3, 5]
|
5,485,786 | 5,485,787 |
On 'include' pages, where to call global scripts?
|
<p>I am brand new to PHP and just starting out, so apologies if this is a really dumb question! </p>
<p>I have an index.php page with the following code:</p>
<pre><code><?php include 'includes/header.php'; ?>
<?php include 'includes/repeated-content.php'; ?>
<?php include 'includes/footer.php'; ?>
</code></pre>
<p>I've using the repeated-content.php file as a template, which uses the Supersized plugin for full screen backgrounds... and wish to use this feature elsewhere on the site. What I'm confused about (as I usually use HTML and am only just delving into PHP)... is whether to place all the global JS in index.php (Such as jQuery), and only the Supersized plugin & relevant JS in repeat-content.php or should each PHP page have all the required JS scripts to run such as the jQuery library?</p>
<p>I know it'll work if I do put jQuery on every page (have tested it), but it seems wrong to repeat the HTTP request to reload a library on every include page.</p>
|
php javascript jquery
|
[2, 3, 5]
|
1,141,655 | 1,141,656 |
jQuery recognise click from user, not trigger
|
<p>So I have the code: </p>
<pre><code>function randomClick(interval){
$(".thumbnail_holder .nav li:not(.empty):eq("+select+") a").trigger("click");
window.randomTimer = setTimeout("randomClick("+interval+")", interval);
}
</code></pre>
<p>I need it so when a user click's <code>".thumbnail_holder .nav li a</code>, it clears the interval so for example</p>
<pre><code>$(".thumbnail_holder .nav li a").on("click", function(e){
e.preventDefault();
clearTimeout(window.randomTimer);
});
</code></pre>
<p>However the above code also happens on the <code>.trigger("click");</code>.</p>
<p>Is there any way the <code>.on</code> function can differentiate between the two?</p>
|
javascript jquery
|
[3, 5]
|
5,816,137 | 5,816,138 |
What is the best way to programmatically run javascript when an ASP.net page loads?
|
<p>In my <code>global.asax</code> file for my ASP.net project, I am checking for certain conditions. When those conditions are met, I want to automatically execute javascript code when the page runs.</p>
<p>This is my code:</p>
<blockquote>
<p>if condition Then<br>
Response.Write(" < script type=""text/javascript"" > ")<br>
Response.Write(" // Javascript code to do stuff ")<br>
Response.Write(" < /script > ")<br>
End If</p>
</blockquote>
<p>While this appears to work to execute the Javascript code, I don't think it's a best practice because this code will preceed <em>all</em> of the HTML of the page that gets loaded.</p>
<p>What is the best way of programmatically tacking on some extra Javascript code to be run when my page loads?</p>
<p><b>Update</b> Thanks for the answer. Too bad this solution doesn't work from within <code>global.asax</code>. Is there no way to make this happen site-wide? It seems like <code>global.asax</code> would be the logical place to put code that runs with every page... <code>Response.Write</code> works fine in <code>global.asax</code>.</p>
|
asp.net javascript
|
[9, 3]
|
6,005,341 | 6,005,342 |
bind and unbind function with a name
|
<p>I need to bind and unbind a function on click.
The problem is that I need the click event (also 'this' as the clicked element would be fine)</p>
<pre><code> function clickElement(e) {
[...]
//here I need event or this clicked element
}
</code></pre>
<p>this would works, but doesn't have the event parameter</p>
<pre><code>$('.clickme').on('click', clickElement)
</code></pre>
<p>this would works but I can't unbind the specific function</p>
<pre><code> $('.clickme').on('click', function(e){clickElement(e)})
</code></pre>
<p>this doesn't work:</p>
<pre><code> $('.clickme').on('click', clickElement(e))
</code></pre>
<p>why?</p>
<p>I need to use .on instead of .click because later I need to unbind clickElement and only clickElement like this:</p>
<pre><code> $('.clickme').off('click', clickElement);
</code></pre>
|
javascript jquery
|
[3, 5]
|
4,841,690 | 4,841,691 |
Using JQuery to set 'dirty' elements back to original values
|
<p>I have a Javascript object that basically represents a Row in an .NET GridView.
When a user clicks on any row in the grid, all the input elements in that row are 'enabled'.(ie 'Edit' mode). </p>
<p>I run this code depending on which row is selected</p>
<pre><code>$(":input", this._row).attr('disabled', true);
or
$(":input", this._row).removeAttr('disabled');
</code></pre>
<p>So far so good. Now, I want to keep track of the values in that row before a user enters the 'Edit Mode', so i can restore the original values if they decide to click out of that row without saving any changes that they made.</p>
<p>So i capture the original values in an array by doing this:</p>
<pre><code>var $inputs = $(":input", this._row);
var values = {};
$inputs.each(function(i, el) { values[el.name] = $(el).val(); });
</code></pre>
<p>the 'values' array now looks like this:</p>
<pre><code>ctl00$ContentPlaceHolder1$resultsGrid$ctl04$COMPONENT1 "56"
ctl00$ContentPlaceHolder1$resultsGrid$ctl04$COMPONENT2 "98"
ctl00$ContentPlaceHolder1$resultsGrid$ctl04$COMPONENT3 "08"
ctl00$ContentPlaceHolder1$resultsGrid$ctl04$COMPONENT4 "200"
</code></pre>
<p>Great so far. The user may then modify these values, but decide not to save the changes.
So i need to restore this row back to it's orignal values from the 'values' array.
Can someone tell me the best way to do this? Im hoping it's something simple, but i'm no jquery expert, yet..</p>
<p>thanks</p>
|
asp.net jquery
|
[9, 5]
|
3,959,509 | 3,959,510 |
in asp.net server side code?
|
<p>I have this code : </p>
<pre><code>string s = "royi";
string val = "5";
</code></pre>
<p>I also have a <code>label</code> <code><asp:Label ..../></code></p>
<p>I want to create <code>s+" "+val</code></p>
<p>but I want That the <code>" "</code> will be <code>&nbsp;</code></p>
<p>How can I do it in <em>server</em> side ? </p>
<p>Doing this is showing me the <code>&nbsp</code> as text. ( ofcourse since we're dealing with myLabel.<em>Text</em> which holds a text) </p>
<p>I've also tried : </p>
<pre><code>HttpUtility.HtmlEncode(s + "&nbsp;" + val);
</code></pre>
<p>any help ? </p>
|
c# asp.net
|
[0, 9]
|
3,415,664 | 3,415,665 |
How does caching work when a javascript file is loaded?
|
<p>I have some tabs that are ajax powered. So everytime a tab is clicked all data is loaded including javascripts. So if they click on say Tab A then click on Tab B and finally Tab A. All Tab A scripts will be loaded twice.</p>
<p>Now I am wondering how does the caching work. On the second time they click on Tab A how much faster will these scripts download? Or will it be as slow as the first time?</p>
<p>Thanks</p>
|
javascript jquery
|
[3, 5]
|
3,800,035 | 3,800,036 |
jQuery - prevent default, then continue default
|
<p>I have a form that, when submitted, I need to do some additional processing before it should submit the form. I can prevent default form submission behavior, then do my additional processing (it's basically calling Google Maps API and adding a few hidden fields to the form) -- and then I need the form to submit.</p>
<p>Is there a way to "prevent default", then some point later "continue default?"</p>
|
javascript jquery
|
[3, 5]
|
1,813,862 | 1,813,863 |
can't get string result of replaceWith
|
<p>this is what I'm trying to do:</p>
<pre><code>var x = $("<div><div class='aaa' /></div>").find('.aaa').replaceWith("hi");
alert(x);
</code></pre>
<p>the result of the alert is <code>object</code> I need <code><div>hi</div></code></p>
|
javascript jquery
|
[3, 5]
|
2,701,952 | 2,701,953 |
Checking username and password in Android
|
<p>I have a username and password field and now i need to check and redirect him to the next page in Android. </p>
<pre><code> public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
final EditText loginText = (EditText) findViewById(R.id.widget44);
final EditText loginPassword = (EditText) findViewById(R.id.widget47);
final Button button = (Button) findViewById(R.id.widget48);
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
Intent myIntent = null;
if(loginText.getText().equals("admin") &&
loginPassword.getText().equals("admin")) {
System.out.println("Entering");
myIntent = new Intent(view.getContext(), Page1.class);
} else {
}
startActivity(myIntent);
}
});
}
</code></pre>
<p>Temp now i am checking by hardcoding the values, but this too does not work for me. Why? I usually check in <strong>Java</strong> like this, why does it not accept me the same way in Android</p>
|
java android
|
[1, 4]
|
1,691,712 | 1,691,713 |
Having trouble to run report from server from web applicaton
|
<p>I am using ASP.NET 2005, C# and Crystal Reports 8.5 for development. It's running fine on my development computer, but when I try to to run from the server it is giving me an error.</p>
<blockquote>
<p><strong>Could not load file or assembly 'CrystalDecisions.ReportAppServer.CommLayer,
Version=10.2.3600.0, Culture=neutral,
PublicKeyToken=692fbea5521e1304' or
one of its dependencies. The system
cannot find the file specified.</strong></p>
</blockquote>
<p>I have these Crystal Reports dlls referenced in my bin folder:</p>
<ul>
<li>CrystalDecisions.CrystalReports.Engine.dll</li>
<li>CrystalDecisions.ReportSource.dll</li>
<li>CrystalDecisions.Shared.dll</li>
<li>CrystalDecisions.Web.dll</li>
<li>CrystalDecisions.Windows.Forms.dll</li>
</ul>
|
c# asp.net
|
[0, 9]
|
1,324,783 | 1,324,784 |
java method explanation
|
<p>This is probably really simple but i am having difficulty understanding it.</p>
<pre><code> @Override
// says override this method so it can inherit from the super-class,is this true?
public void onCreate(Bundle savedInstanceState) {
// its a public method, that returns
// no value, with the params Bundle savedInstanceState, is this correct?
super.onCreate(savedInstanceState); // what does this do?
mGestureDetector = new GestureDetector(this, new LearnGestureListener());// and this
</code></pre>
|
java android
|
[1, 4]
|
1,609,518 | 1,609,519 |
How do get change value of <input> element?
|
<p>I have a input in datalist</p>
<pre><code><input type="text" value="1" id="txtcount">
</code></pre>
<p>I want get new value of it when text change.</p>
<p>I use this code but don't work for me .</p>
<pre><code><script>
//look no global needed:)
$(document).ready(function(){
// Get the initial value
var $el = $('#txtcount');
$el.data('oldVal', $el.val() );
$el.change(function(){
//store new value
var $this = $(this);
var newValue = $this.data('newVal', $this.val());
})
.focus(function(){
// Get the value when input gains focus
var oldValue = $(this).data('oldVal');
});
});
</code></pre>
<p></p>
|
javascript asp.net
|
[3, 9]
|
671,739 | 671,740 |
How can I get the same fly-in and bounce affect that apple uses for their nav bar in the store?
|
<p>Go to store.apple.com and watch the to nav bar. It flies in, and does a little bounce.</p>
|
javascript jquery
|
[3, 5]
|
3,289,920 | 3,289,921 |
Passing URL parameter with JavaScript
|
<p>I have some JavaScript that creates Forward and Back buttons. However, I need to pass a parameter in the URL (<code>?id=$idd</code>):</p>
<pre><code><a href="javascript:submitForm('mainForm','back');" title="Go back to the kit home page" style="float: left;"><img src="images/back.gif" alt="Go back to the kit home page" border="0" /></a>
<a href="javascript:submitForm('mainForm','proceed');" title="Submit the order details" style="float: right;"><img src="images/proceed.gif" alt="Proceed to the next page" border="0" /></a>
</code></pre>
<p>The JavaScript is below:</p>
<pre><code>// Used in all pages to submit a form and optionally set a hidden
// form varaible called 'navigate' to direct navgiation
function submitForm(formName, navigateValue) {
if (navigateValue != null && navigateValue != "") {
document.forms[formName].navigate.value = navigateValue;
}
document.forms[formName].submit();
}
</code></pre>
<p>Thanks.</p>
|
php javascript
|
[2, 3]
|
4,240,694 | 4,240,695 |
Moving the page
|
<p>I need to move the page from top to bottom, just like it happens in the best site of the world( <a href="http://stackoverflow.com/">stackoverflow</a>), when we change the type of sorting of our questions, it moves the page.</p>
<p>How can I get such an effect?
I even don't know how to search for information about it, because don't know the <em>keywords</em>, so I decided to ask here :/</p>
<p>Thanks</p>
|
javascript jquery
|
[3, 5]
|
5,477,068 | 5,477,069 |
Declaring arrays
|
<blockquote>
<p><strong>Possible Duplicates:</strong><br>
<a href="http://stackoverflow.com/questions/587584/what-is-the-preferred-way-to-declare-a-java-array">What is the preferred way to declare a Java array?</a><br>
<a href="http://stackoverflow.com/questions/129178/difference-between-int-array-and-int-array">Difference between int[] array and int array[]</a> </p>
</blockquote>
<p>Hi!</p>
<p>Been learning Java for Android by reading some tutorials. And in lots of the tutorials there are used two different ways of declaring arrays - even in the same project:</p>
<pre><code>public int integers[] = { ... };
public int[] integers = { ... };
</code></pre>
<p>Does it matter or are these two basically the same?</p>
|
java android
|
[1, 4]
|
1,375,408 | 1,375,409 |
Loop Through jQuery Function Inifitly
|
<p>I have a jQuery Animation which I want to loop infinitely, I have the current code but it just returns nothing.</p>
<pre><code>$(document).ready(function() {
var i = 0;
document.write(i);
function runTest(){
$('#page_effect').fadeIn(1500).delay(3500).fadeOut(1500);
$('#page_effect2').delay(7000).fadeIn(1500).delay(3500).fadeOut(1500);
$('#page_effect3').delay(13900).fadeIn(1500).delay(3500).fadeOut(1500);
$('#page_effect4').delay(21000).fadeIn(1500).delay(3500).fadeOut(1500);
i++;
runTest();
}
if(i === 0){
runTest();
}
});
</code></pre>
<p>Many Thanks! :)</p>
|
javascript jquery
|
[3, 5]
|
523,807 | 523,808 |
How do I find the current window offset using javascript?
|
<p>When I open a page, the window offset would be 0 but when i scroll through the page, the offset of the window would increase correspondingly? How can I find the window's offset at any particular point of my web page?</p>
|
javascript jquery
|
[3, 5]
|
2,644,139 | 2,644,140 |
How to customize the dbo.aspnet_Users table of asp.net membership?
|
<p>I am using ASP.net membership, but I want to store additional information for client while registration instead of default columns as membership provider does, so how can I customize the <code>dbo.aspnet_Users</code> table and change the code so that it doesn't affect the other functionality and works fine?</p>
<p>Could somebody suggest me on it how can I achieve this?</p>
|
c# asp.net
|
[0, 9]
|
2,636,124 | 2,636,125 |
How to read an object from internal storage?
|
<p>I've saved objects into myfile.txt. I'm confused about how to read an object from internal storage. Can anybody help me? I'd like to use part of that object in an app similar to the memo app.</p>
|
java android
|
[1, 4]
|
5,987,148 | 5,987,149 |
Efficiently read binary data into int[]
|
<p>I have binary data in a file (a list of 32-bit integer values) that I need to get into an int array efficiently. I can't see any way to do this other than loading the data into a byte[] and then converting it into an int[] one element at a time. This is too slow for the amount of data I need to load. It takes about 3 seconds to do the conversion on an actual phone. Reading the data from the file in the byte[] is pretty much instantaneous.</p>
<p>Are there any libraries that use native methods for reading an int[] from a file, or for converting a byte[] to int[]?</p>
|
java android
|
[1, 4]
|
2,863,673 | 2,863,674 |
How to get the previous month date in asp.net
|
<p>I need to get the previous months date in asp.net which means that if the current date is 5/2/2013 then I want to display the previous date as 5/1/2013. How to solve this?</p>
|
c# asp.net
|
[0, 9]
|
1,499,017 | 1,499,018 |
Print contents of a list box as comma-separated values using JQuery
|
<p>I have a select box defined as shown below. I want to print out the name and email address of each item in the select box as comma seperated values, like</p>
<pre><code>Tom Wayne,[email protected]
Joe Parker,[email protected]
Peter Simons,[email protected]
</code></pre>
<p>Any way to accomplish that using JQuery?</p>
<pre><code><select multiple="multiple" name="search_results">
<option value="[email protected]">Tom Wane</option>
<option value="[email protected]">Joe Parker</option>
<option value="[email protected]">Peter Simons</option>
</select>
</code></pre>
<p>Thank You</p>
|
javascript jquery
|
[3, 5]
|
5,082,301 | 5,082,302 |
How to pick color that will not be same next to each other
|
<p>I'm adding a random background color with this code</p>
<pre><code>var hue = ['#2dafe9','#5feec3','#fdaf17','#999999','#2b2b2b','#454323','#ab34ef', '#e324e2','#874edf','#18edf4'];
function getHue(){
return hue[Math.floor(Math.random() * hue.length)];
}
function rainbow(){
$("header[role='postHeader']").each(function(){
$(this).css('background-color',getHue());
});
}
rainbow();
</code></pre>
<p>My question is, how to select a color in order of the array without having to same color next to each other in the result, so the color would follow the array order instead and then if its get to the last array loop back to the first one.</p>
|
javascript jquery
|
[3, 5]
|
188,610 | 188,611 |
Calculate File Size using Javascript
|
<p>I need to calculate file size using javascript before the file starts to upload in server size. I need do the file size operation in client size itself.</p>
<p>Pls help me guys.,</p>
<p>Thanks.. </p>
|
javascript asp.net
|
[3, 9]
|
3,539,237 | 3,539,238 |
Sending emails through SMTP client using current logged in user
|
<p>I have web site set up that has some forms authentication through LDAP. I'm sending an email when the currently logged in user clicks a button, however the email is being sent from my address, and not the user. This creates a bit of confusion.</p>
<p>What I want to do is send emails using the logged users account without having them enter their user information again.</p>
<p>I basically want to do this:</p>
<pre><code> MailMessage message = new MailMessage();
message.From = new MailAddress(User.GetIdentity);
message.Subject = Subject;
message.Body = body;
message.IsBodyHtml = true;
SmtpClient client = new SmtpClient("address.qweqwe", 25);
client.Credentials = new System.Net.NetworkCredential(User.Identity);
client.Send(message);
</code></pre>
<p>Getting the users email isn't a big deal, I've already got methods for that, but I'm not sure how I should go about getting their credentials. They've already logged on to access the page, and I know they have an LDAP email.</p>
<p>Is there any way to do this without forcing the user to log in again just to send the email?</p>
|
c# asp.net
|
[0, 9]
|
2,881,866 | 2,881,867 |
jQuery - does the submit event hold the query string or data of the submitted form?
|
<p>I have this code</p>
<pre><code>$("#dummy_div").on('submit', "form", function(event){
console.log(event);
event.preventDefault();
});
</code></pre>
<p>Does the event object contain hold the query string or data of the submitted form? If not, is there a way to get them short of iterating over the form fields?</p>
|
javascript jquery
|
[3, 5]
|
4,373,811 | 4,373,812 |
CMS uses jquery 1.7, theme uses jQuery 1.6 == conflict
|
<p>I've been given a theme to implement into a cms.</p>
<p>The theme uses jQuery 1.6 and has no javascript errors.</p>
<p>The CMS (concrete5) uses jQuery 1.7.1 and has no javascript errors.</p>
<p>When I merge the theme into the CMS, I drop the include to jQuery (since I was to avoid including jQuery twice) and now I am getting the following errors:</p>
<pre><code>Uncaught TypeError: Property '$' of object [object DOMWindow] is not a function (ccm.app.js line 1 --> ccm.app.js is part of the CMS javascript).
Uncaught TypeError: Property '$' of object [object DOMWindow] is not a function (page controls menu.js).
</code></pre>
<p>The script src references are in this order:</p>
<pre><code>- jQuery
- ccm.app.js (CMS)
- page controls menu.js (CMS)
- custom.js (my theme)
</code></pre>
<p>I realize that this isn't a lot of code to look at and troubleshoot, but does anyone know the differences between jQuery 1.6 and jQuery 1.7 that <strong>might</strong> be causing this kind of error?</p>
|
javascript jquery
|
[3, 5]
|
2,853,296 | 2,853,297 |
Getting an element's `id` attribute
|
<p>Can you get the <code>id</code> attribute of a html tag using jQuery or without?</p>
<p>For example:</p>
<pre><code><ul id="todo" />
</code></pre>
<p>How can I get the <code>id</code>, without using <code>jQuery("#todo")</code>?</p>
<p>Is there a way for that? Will <code>attr()</code> work?</p>
|
javascript jquery
|
[3, 5]
|
361,392 | 361,393 |
removeClass() works outside the if statement but not within
|
<p>I have the following HTML:</p>
<pre><code><div id="wrapper">
<div class="p1">
<a href="#" class="quickFlipCta"><img src="Test Pictures/QuestionMark.gif" /></a>
</div>
<div class="p2">
<a href="#" class="quickFlipCta"><img src="Test Pictures/flower.gif" /></a>
</div>
</div>
</code></pre>
<p>Along with some other things, I want the class "quickFlipCta" to be removed after a certain condition. Here is a snippet of my code:</p>
<pre><code>if ( $(this).attr('id') != last.attr('id') ) {
var that = this;
var that2 = last;
setTimeout(function(){
$(that).parent().parent().quickFlipper({refresh :1});
$(that2).parent().parent().quickFlipper({refresh :1});
}, 1500);
$('a').removeClass('quickFlipCta');
}
</code></pre>
<p>The first statements work perfectly: </p>
<pre><code> setTimeout(function(){
$(that).parent().parent().quickFlipper({refresh :1});
$(that2).parent().parent().quickFlipper({refresh :1});
}, 1500);
</code></pre>
<p>However <code>$('a').removeClass('quickFlipCta');</code> does not work.
I figured there was something wrong with it but I tried it outside of the if statement and it worked. Any idea of what could be causing this? Thanks in advance.</p>
|
javascript jquery
|
[3, 5]
|
841,743 | 841,744 |
Skip some code if the computer is slow
|
<p>Is there any way to detect if a computer is slow and not run some code (by either turning jQuery animations off or just running a function if it <em>is</em> fast)?</p>
<p>I know this question is probably really trivial, but I noticed that on some slower computers even the simplest margin animation to move something is done in flashes that doesn't look very nice.</p>
<p>Update:<br />
The code I'm trying to run is simply a bunch of animations; they all take the same amount of time but on slower browsers the animation is segmented like what you see when you watch a video that is buffering.</p>
|
javascript jquery
|
[3, 5]
|
982,747 | 982,748 |
c# - Specified cast is not valid
|
<p>I'm trying to code for a project, but the non-valid specific cast error keeps coming out. Can anyone help me as I am stumped. Thanks in advance.</p>
<pre><code>Server Error in '/c#project' Application.
Specified cast is not valid.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidCastException: Specified cast is not valid.
Source Error:
Line 39: cmd.Parameters.Add("@ProductId", OleDbType.Char).Value = strProductId;
Line 40: object oQty = cmd.ExecuteScalar();
Line 41: int intQuantityOnHand = (int)oQty;
Line 42: mDB.Close();
Line 43: int intBuyQuantity = int.Parse(ddlQty.Items[ddlQty.SelectedIndex].ToString());
Source File: c:\Users\jacob\Desktop\c#project\ProductDetails.aspx.cs Line: 41
Stack Trace:
[InvalidCastException: Specified cast is not valid.]
ProductDetails.btnBuy_Click(Object sender, EventArgs e) in c:\Users\jacob\Desktop\c#project\ProductDetails.aspx.cs:41
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +118
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +112
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5563
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272
</code></pre>
|
c# asp.net
|
[0, 9]
|
1,443,654 | 1,443,655 |
Automate slider with jquery?
|
<p>I have a slider that slides images across on the click of a button using the following function</p>
<pre><code>$(document).ready(function (){
$('#button a').click(function(){
var integer = $(this).attr('rel');
$('#myslide .cover').animate({left:-720*(parseInt(integer)-1)})
$('#button a').each(function(){
$(this).removeClass('active');
if($(this).hasClass('button'+integer)){
$(this).addClass('active')}
});
});
});
</code></pre>
<p>Is it possible to automate this using jquery? </p>
<hr>
<p>Just found this oly unsure how I would go about implementing it....</p>
<pre><code>setInterval(function() {
// Do something every 2 seconds
}, 2000);
</code></pre>
|
javascript jquery
|
[3, 5]
|
519,349 | 519,350 |
trace an asp.net website in production
|
<p>Is there a way that I can trace every method, basically a line trace, in an asp.net web site in production environment?</p>
<p>I don't want to go about creating db logging for every line - i see an intermittent error and would like to see every line called and performed by the website per user.</p>
|
c# asp.net
|
[0, 9]
|
1,163,936 | 1,163,937 |
Cannot parse HTML with jQuery
|
<p>I want to parse home HTML like the following using jQuery. When I'm using <strong>document</strong> it is working. But not working when using string.</p>
<p><strong>Output:</strong> <em>null</em></p>
<pre><code>var str = "<html><title>This is Title</title><body><p>This is a content</p><p class='test'>Test content</p></body></html>";
$str = $(document); // working
$str = $(str); // not working
alert($str.find(".test").html());
</code></pre>
<p>Another method (also fails):</p>
<p><strong>Output:</strong> <em>null</em></p>
<pre><code>var str = "<html><title>This is Title</title><body><p>This is a content</p><p class='test'>Test content</p></body></html>";
alert($('.test',str).html());
</code></pre>
<hr>
<p>The string I'm getting also cannot be parsed as XML as it is not a valid XHTML.</p>
|
javascript jquery
|
[3, 5]
|
5,266,741 | 5,266,742 |
Validate the string entered is of mm/dd/yyyy format
|
<p>I have a datepicker control for the users to pick the date, however, they also need to enter the date manually. As such, I need to validate the date entered by the user in the textbox.</p>
<p>Below is the code that I am using to validate </p>
<pre><code> DateTime Test;
if ((!string.IsNullOrEmpty(strtdate)))
{
bool valid = DateTime.TryParseExact(strtdate, "MM/dd/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out Test);
}
</code></pre>
<p>The date entered by the user is 6/29/2011, however it gives the bool valid value as false though it is correct.</p>
<p>What am I missing here? Please let me know, its urgent.</p>
<p>Thanks.</p>
|
c# asp.net
|
[0, 9]
|
265,494 | 265,495 |
define include page in colorbox iframe
|
<p>i put in top of my include / external page any line for prevent Remote File Inclusion. this checked include file / extrenal load only in my index page . now when i load this (external page) in colorbox lightbox with iframe method this not work and i see blank page. if i remove this line worked ! how to fix this problem ? any way ?</p>
<p>top php page : </p>
<pre><code>if (!defined('INDEX_ROOT') || (defined('INDEX_ROOT') && INDEX_ROOT != 'true')) die();
</code></pre>
<p>html & colorbox :</p>
<pre><code><script>$(document).ready(function(){ $(".iframe").colorbox({ iframe:true,scrolling:false,width:665,height:600});});</script>
<a class="iframe" href="test.php">load frame</a>
</code></pre>
<p>thanks</p>
|
php jquery
|
[2, 5]
|
4,350,946 | 4,350,947 |
fadeout and fadein between two different pages in jquery
|
<p>Apologies if this may sounds simple, all im trying to do is fadeout the current page and fadein another page. However I'm having difficulties. I know how to do it between divs, the following fades out the leftcolumn div and inputs this in together with the myform on the stage3.php page. My question is how do i fadeout stage2.php and fadein stage3.php?</p>
<pre><code>$("#leftcolumng").fadeOut(500, function(){
$("#leftcolumng").load('stage3.php #myform', function () {
$(this).fadeIn(50);
</code></pre>
<p>});</p>
|
javascript jquery
|
[3, 5]
|
4,323,426 | 4,323,427 |
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]
|
5,175,031 | 5,175,032 |
null pointer exception in GeoPoint on android
|
<p>in my app i am storing latitude and longitude in a List as GeoPoint as follows:</p>
<p><code>List<GeoPoint>geo;</code></p>
<p>here i convert latitude and longitude into GeoPoint and store in list. </p>
<pre><code>GeoPoint tmp;
new GeoPoint((int) ( 9.909228086471558 * 1E6), (int) ( 78.10081958770752 * 1E6));
geo.add(tmp); // i get null pointer exception . Line no:42
</code></pre>
<p>Logcat</p>
<pre><code> 05-30 18:33:25.203: ERROR/AndroidRuntime(6363): Caused by: java.lang.NullPointerException
05-30 18:33:25.203: ERROR/AndroidRuntime(6363): at net.learn2develop.GoogleMaps.main.onCreate(main.java:42)
05-30 18:33:25.203: ERROR/AndroidRuntime(6363): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1132)
05-30 18:33:25.203: ERROR/AndroidRuntime(6363): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2231)
</code></pre>
<p>how to clear the null pointer exception. please help me.</p>
|
java android
|
[1, 4]
|
1,523,162 | 1,523,163 |
Trigger an event on click within body area
|
<p>I need to trigger the click, on click on my webpage. I tried the below and it triggers the click onload and not on click.</p>
<pre><code>$(function() {
$("body").click(function(e) {
alert("code");
})
$('#container').trigger('click');
});
</code></pre>
<p>Basically I need to show a popup on click of P keyword from keyboard. While I started I got stuck during the initial stages. Not sure how to achieve this.</p>
|
javascript jquery
|
[3, 5]
|
2,082,418 | 2,082,419 |
Why are all the iterations run at the same time?
|
<p>Here's the <a href="http://jsfiddle.net/JaQmd/">jsfiddle</a> simulating my problem relating to this code:</p>
<pre><code>$('#button').click(function(){
var i;
for (i = 1; i < 4; ++i) {
$('#img' + i).fadeIn("slow").delay(1000);
$('#img' + i).fadeOut("slow");
}
});
</code></pre>
<p>I was expecting the <code>#img1</code> element to fade in and then for the execution to stop for 1 second and then fade out, then start over for the <code>#img2</code> element etc.</p>
|
javascript jquery
|
[3, 5]
|
2,976,715 | 2,976,716 |
How do you pass a Container.DataItem as a parameter?
|
<p>I'm using a repeater control and I'm trying to pass a parameter as such:</p>
<pre><code><%# SomeFunction( DataBinder.Eval(Container.DataItem, "Id") ) %>
</code></pre>
<p>It's basically calling:</p>
<pre><code>public string SomeFunction(long id) {
return "Hello";
}
</code></pre>
<p>I'm not able to achieve this as I get an error:</p>
<p>error CS1502: The best overloaded method match ... SomeFunction(long id) ... has some invalid arguments.</p>
<p>Any ideas?</p>
|
c# asp.net
|
[0, 9]
|
3,657,677 | 3,657,678 |
Better way to structure/new keyword
|
<p>Some time ago I came across the following construct which I have rarely seen since, though I use it relatively frequently. I use it typically when checking on a whole list of conditions are true and it prevents large levels of indentation. Essentially it uses a for loop to provide a kind of structured goto. My question is firstly whether there is better way to structure this, secondly whether people like it and thirdly whether a new keyword in java/c++ etc. such as unit { } which would only cause breaks to exit to the end of the unit would be useful and clearer. </p>
<p>ps I realise that it is on slip away from an infinite loop, but I think my paranoia about that has meant its never happened.</p>
<p>Edit: I have added some setup code for the further conditions to try to illuminate problems with chained if then elses</p>
<pre><code>boolean valid = false;
// this loop never loops
for (;;)
{
if (!condition1)
break;
condition2.setup();
if (!condition2)
break;
condition3.setup();
if (!condition3)
break;
valid = true;
break;
}
if (valid) dosomething();
</code></pre>
<p>EDIT:</p>
<p>I have just discovered that in fact there is a way to structure this in java without misusing loops etc. and wondered whether this would similarily be frowned on, though I guess I have missed the boat on this one.</p>
<p>The restructured code looks like this.</p>
<pre><code>boolean valid = false;
breakout:
{
if (!condition1)
break breakout;
condition2.setup();
if (!condition2)
break breakout;
condition3.setup();
if (!condition3)
break breakout;
valid = true;
}
if (valid) dosomething();
</code></pre>
<p>Now that removes the misuse of the for loop which caused a lot of the complaints, and is actually a solution I think is quite neat and is what I was looking to find originally.
I am guessing that this structure is probably not well known since no one mentioned it, people object to this as strongly?</p>
|
java c++
|
[1, 6]
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.