onclick

javascript include file at onclick

好久不见. 提交于 2019-12-23 06:00:01
问题 Is there a way to include some php file at javascript onClick ? like, if(isset(something)) ? include "file.php"; Please help! 回答1: No. That's PHP syntax. PHP executes completely on the server and the result is sent back to the client. Clicks are on the client side. Javascript handles those. Your can't mix the two. You can use AJAX to make a request to the server for a file and display its contents using JS, though. jQuery has a simple method called .ajax() for this $.ajax({ url: 'file.php',

Android: onListItemClick not getting called in ListActivity

筅森魡賤 提交于 2019-12-23 05:36:14
问题 I'm having problems with my first Android app. I have subclassed ListActivity, and I'm having no luck getting the overridden onListItemClick() to respond to click events. I've read focus can be a problem, but changing focus in the XML files does not seem to work. Here's the relevant bits of code. Anyone see what's I've buggered up? public class Notepadv1 extends ListActivity { private int mNoteNumber = 1; private NotesDbAdapter mDbHelper; @Override public void onCreate(Bundle

Chess - GridView , How to move chess piece by two clicks?

一笑奈何 提交于 2019-12-23 05:29:14
问题 I am working with a chess app which loads chess position from FEN Notations Basic information about what I did.. I used Gridview of 64 Imageviews and set chessboard image as a background image of Gridview.I able to load the chess position in Gridview.But I dont know how to move the chess piece from current location (first click) to new location (second click). but I have the two positions from onclick of my CustomAdapter. I am new to android and gridview 回答1: I have stored the position of two

Change to a option on click image with jQuery

烂漫一生 提交于 2019-12-23 04:49:23
问题 I would like to change option into select if I click on some image. Value of option is a unique ID of parameter. I would like to use jQuery but I'm beginner and I don't know how. Now I have this: $(document).ready(function () { $('img').click(function(){ $("option:selected").removeAttr("selected"); $('option[value="' + $(this).attr("alt") + '"]').attr('selected', true); }); }); But it doesn't work. All source are here http://jsfiddle.net/EKaKw/2/. Answer into jsfiddle would be best. Thanks

HTML5 Canvas Mouse coordinates [duplicate]

青春壹個敷衍的年華 提交于 2019-12-23 04:36:11
问题 This question already has answers here : How do I get the coordinates of a mouse click on a canvas element? (22 answers) Closed 7 months ago . I have an HTML file with a <canvas> element and I am trying to get the mouse coordinates in the click event. I am using this code: secondCanvas.addEventListener('click', function(e) { console.log(e.pageX) }, false); When I click on the top left point I get in console 500~ number, not zero... what do I need to do to get the coordinates of the mouse on

Pass value outside of public void onClick

☆樱花仙子☆ 提交于 2019-12-23 04:27:06
问题 So im sure this is probably a fairly easy question but I am stumped because I am a beginner. I am looking to pass a value from one class to another, and I have my helper function down and working just fine. If i create an integer outside of my onClick I can pass it no problem. If I create it inside the onClick though it doesn't seem to make it out. package com.movi.easypar; //import java.util.logging.Handler; import android.app.Activity; import android.app.AlertDialog; import android.content

start Fragment from RecycleView Adapter Onclick

安稳与你 提交于 2019-12-23 04:26:49
问题 Hi I have A RecycleView Adapter and A button. I want that button to start a Fragment. I can start an activity but not a fragment. I have tried this Onclick method for my Button @Override public void onClick(View v) { Bundle bundle = new Bundle(); bundle.putParcelable("event", events.get(getLayoutPosition())); Fragment fragment = new EditEventDetailFragment(); fragment.setArguments(bundle); fragment.getFragmentManager().beginTransaction().replace(R.id.contentMainDrawer,fragment).commit(); }

How to test AsyncTask triggered by a click?

徘徊边缘 提交于 2019-12-23 03:44:11
问题 If the AsyncTask is triggered by a click event on a button, how can I test it - how can I wait until the AsyncTask completes? Note I can always execute the AsyncTask directly in my test method, I know how to test such scenario. However, if I insist on on using simulating the onClick event using performClick() can I still test my registration process? MainActivityFunctionalTest public class MainActivityFunctionalTest extends ActivityInstrumentationTestCase2<MainActivity> { // ... public void

onclick event is executed immediately without clicking

时光总嘲笑我的痴心妄想 提交于 2019-12-23 03:27:15
问题 I'm working on some code that contains a click event for a span element (This piece of code is part of the function that creates the span): $("span[class=addnewsqlwherevalue][id='" + opts.counters[3] + "']").click( function(e) { ...}); It is executed immediately after it is defined there and also when I click the specified span element although I only want it to be executed when I click on the element. I also tried: function clickSpan(e) {...} $("span[class=addnewsqlwherevalue][id='" + opts

jQuery Adding a css class to a link when clicked

雨燕双飞 提交于 2019-12-23 01:57:16
问题 I have the current code: <script type="text/javascript"> $('ul.products-slideshow-thumbs li a').bind("mousedown", function(){ $(this).toggleClass("current"); }); </script> <ul class="products-slideshow-thumbs"> <li><a href="#"><img src="product-slides/thumbs/1.jpg" /></a></li> <li><a href="#"><img src="product-slides/thumbs/2.jpg" /></a></li> <li><a href="#"><img src="product-slides/thumbs/3.jpg" /></a></li> </ul> But it's not working properly (basically, nothing happens). Any suggestions? (I