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
5,843,681
5,843,682
Block characters from input text field, mirror input into span or div
<p>I have some html</p> <pre><code>&lt;input type="text" name="name" value="" id="name"&gt; &lt;div id="preview"&gt;&lt;/div&gt; </code></pre> <p>The rules for entry into the field:</p> <ul> <li>Letters A-Z a-z 0-9 space and dash, no other characters allowed<br /></li> <li>Entry of forbidden characters should do nothing<br /></li> </ul> <p>The rules for the div:</p> <ul> <li>Show each characters as it is entered into the input field<br /></li> <li>Do not show characters that are forbidden<br /></li> <li>When a space is encountered, show it as a dash<br /></li> </ul> <p>I have had various potions working, not working, or misbehaving. This version seems to work in all cases I can test other than backspace/delete is non functional. Only tested in Safari so far.</p> <p>There are other "gotcha" areas, like entering in text in-between already entered text, select all, using the arrow keys, all these play a role in this problem. </p> <pre><code> $(document).ready(function(){ $('#name').keypress(function(e) { // get key pressed var c = String.fromCharCode(e.which); // var d = e.keyCode? e.keyCode : e.charCode; // this seems to catch arrow and delete better than jQuery's way (e.which) // match against allowed set and fail if no match var allowed = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890- '; if (e.which != 8 &amp;&amp; allowed.indexOf(c) &lt; 0) return false; // d !== 37 &amp;&amp; d != 39 &amp;&amp; d != 46 &amp;&amp; // just replace spaces in the preview window.setTimeout(function() {$('#preview').text($('#name').val().replace(/ /g, '-'));}, 1); }); }); </code></pre> <p>If there is a way to put a monetary bounty on this post, let me know. Yes, that is where I am at with this one :)</p>
javascript jquery
[3, 5]
3,322,049
3,322,050
send data from Android app to local server
<p>i want to send data from android application to local server (PHP) but it doesn't work this is my code (it is work with remote server ):</p> <p>String path ="http://localhost/sd.php"; HttpClient client = new DefaultHttpClient(); HttpConnectionParams.setConnectionTimeout(client.getParams(), 100000);</p> <p>HttpResponse response;</p> <pre><code> JSONObject json = new JSONObject(); try { HttpPost post = new HttpPost(path); json.put("im", 999); json.put("cTime", 12); Log.i("jason Object", json.toString()); post.setHeader("json", json.toString()); StringEntity se = new StringEntity(json.toString()); se.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE,"application/json")); post.setEntity(se); response = client.execute(post); } catch (Exception e) { Object n=e.getStackTrace(); Toast.makeText( getApplicationContext(),n.toString(),Toast.LENGTH_SHORT).show(); } </code></pre> <p>i thing the wrong in the address <a href="http://localhost/sd.php" rel="nofollow">http://localhost/sd.php</a> pleas help me to find a solution to this problem </p>
php android
[2, 4]
1,857,014
1,857,015
show only Error message of asp validators by javascript
<p>i trying to pop up only error message's for validation's control not text. The code which i tried is showing null for error message's. </p> <pre><code>function fnOnUpdateValidators() { for (var i = 0; i &lt; Page_Validators.length; i++) { var val = Page_Validators[i]; var ctrl = document.getElementById(val.controltovalidate); if (ctrl != null &amp;&amp; ctrl.style != null) { if (!val.isvalid) { ctrl.style.background = '#FFD6AD'; var errMsg = document.getElementById(val.id).getAttribute('ErrorMessage'); alert(errMsg); } else ctrl.style.backgroundColor = ''; } } } </code></pre>
javascript asp.net
[3, 9]
1,663,583
1,663,584
Javascript running improperly?
<p>I have a Javascript function that is called from the onchange method in a DropDownList. However I'm getting the error "Cannot have multiple items selected in a DropDownList." on line 14. This happens when the page is reloaded for other purposes. Why is it getting hung here when the method shouldn't even be getting called?</p> <pre><code>Line 12: { Line 13: var hfSelected = document.getElementById("&lt;%=hfSelectedValue.ClientID%&gt;"); Line 14: var ddlExposure = document.getElementById("&lt;%=ddlExposure.ClientID%&gt;"); Line 15: hfSelected.value = ddlExposure.options[ddlExposure.selectedIndex].text + "|" + ddlExposure.options[ddlExposure.selectedIndex].value; Line 16: } </code></pre>
asp.net javascript
[9, 3]
4,810,831
4,810,832
How do I take string values from a list of objects and add them to a drop down list?
<p>I want to take a list of employees with 3 parts, employee id, last name and first name and add them to a drop down list showing last name, first name. </p> <p>What I have so far is that I created a class for the employees:</p> <pre><code> public class Employee { public int emp_Id; public string lastName; public string firstName; public Employee(int id, string last, string first) { this.emp_Id = id; this.lastName = last; this.firstName = first; } } </code></pre> <p>and created a list to populate:</p> <pre><code>private List&lt;Employee&gt; employeeList = new List&lt;Employee&gt;(); </code></pre> <p>this list is populated from a sql query and then sorted by last name.</p> <pre><code>foreach (DataRow row in ds.Tables["EMPLOYEE_TABLE"].Rows) { employeeList.Add(new Employee(int.Parse(row["EMP_ID"].ToString()), row["LAST_NAME"].ToString(), row["FIRST_NAME"].ToString())); } employeeList.Sort(delegate(Employee E1, Employee E2) { return E1.lastName.CompareTo(E2.lastName); }); </code></pre> <p>and everything up to that point worked exactly as I wanted it to but I cannot figure out how I populate a dropdownlist with the last name and first name values contained in the list.</p> <p><em>code has been edited for readability</em></p>
c# asp.net
[0, 9]
5,702,057
5,702,058
jquery selection for starting with something and ending with something
<p>I need to select the elements with id which starts with 'start-' and ends with 'end-' string. How to get this done using jquery selector? One line selector please?</p>
javascript jquery
[3, 5]
4,447,285
4,447,286
href inside loop javascript jquery
<p>i want to loop trough all my delicious.com bookmarks and wrap a link arround them...</p> <p>here's my testsite: <a href="http://dev.thomasveit.com/json.html" rel="nofollow">http://dev.thomasveit.com/json.html</a></p> <pre><code>$(document).ready(function(){ $.ajax({ url: "http://feeds.delicious.com/v2/json/tommyholiday", dataType: "jsonp", success: function(data){ var bookmarks = $.map(data, function(bookmark){ return { title: bookmark.d, link: bookmark.u } }); var html = "&lt;ul&gt;", m; for (i=0; i&lt;bookmarks.length; i++){ m = bookmarks[i]; html += "&lt;li&gt;&lt;a href="+m.link+"&gt;"+m.title+"&lt;/a&gt;&lt;/li&gt;"; } html += "&lt;/ul&gt;"; $("#delicious").html(html); } }); }); </code></pre> <p>funnily enough only the third link is getting wrapped by a link... the others not.</p> <p>what am i doing wrong?</p>
javascript jquery
[3, 5]
2,523,131
2,523,132
Toast Notification From FileObserver Class
<p>I have an issue similar to <a href="http://stackoverflow.com/questions/5963438/toast-from-fileobserver">Toast from FileObserver</a>. However, I do not understand how to properly implement the Handler.</p> <p>Currently, I have a <code>FileObserver</code>-class and I am passing it context and a handler (context comes from <code>getApplicationContext()</code> from the service I call the <code>FileObserver</code>-class from). The handler I pass in (handle) is defined and created in the service. In the <code>onEvent()</code> of the <code>FileObserver</code>-class, I have:</p> <pre><code>handle.post(new Runnable() { public void run() { CharSequence text = "Hello toast!"; int duration = Toast.LENGTH_SHORT; Toast toast = Toast.makeText(context, text, duration); toast.show(); } }); </code></pre> <p>But, I end up with a <code>java.lang.NullPointerException</code>.</p> <p>How do I properly make the toast notification show up when I send it from the <code>onEvent()</code> of the <code>FileObserver</code>-class?</p>
java android
[1, 4]
1,760,310
1,760,311
Config file is appearing in bin folder after publishing
<p>I currently have a configuration file located in the root folder of my project. For some reason, whenever I go to publish the project, it creates two instances of this configuration - one in my root folder and one in my bin folder. Why is this happening and how do I change it so that it doesn't appear in my bin folder?</p>
c# asp.net
[0, 9]
5,459,055
5,459,056
Connect via Bluetooth
<p>I have been working on a bluetooth app for android.I can select a Bt-device from vaible-device-list. How can i connect with the selected device? Could you please help me? Thank you very much </p> <p>Here is my code:</p> <pre><code>public class ScanActivity extends ListActivity { private static final int REQUEST_BT_ENABLE = 0x1; public static String EXTRA_DEVICE_ADDRESS = "device_address"; ListView listGeraete; BluetoothAdapter bluetoothAdapter; ArrayAdapter&lt;String&gt; arrayAdapter; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.list); // adapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); // list of devices ListView listGeraete = getListView(); arrayAdapter = new ArrayAdapter&lt;String&gt;(ScanActivity.this,android.R.layout.simple_list_item_1); listGeraete.setAdapter(arrayAdapter); // if bt disable, enabling if (!bluetoothAdapter.isEnabled()) { Intent enableBt = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE); startActivityForResult(enableBt, REQUEST_BT_ENABLE); } // start discovery bluetoothAdapter.startDiscovery(); registerReceiver( ScanReceiver , new IntentFilter( BluetoothDevice.ACTION_FOUND)); } private final BroadcastReceiver ScanReceiver = new BroadcastReceiver() { public void onReceive(Context context, Intent intent) { String action = intent.getAction(); // find bt devices if (BluetoothDevice.ACTION_FOUND.equals(action)) { BluetoothDevice device = intent .getParcelableExtra(BluetoothDevice.EXTRA_DEVICE); arrayAdapter.add(device.getName() + "\n" + device.getAddress()); arrayAdapter.notifyDataSetChanged(); } } }; // select a device public void onListItemClick(ListView l, View view, int position, long id) { bluetoothAdapter.cancelDiscovery(); String devicesinfo = ((TextView) view).getText().toString(); String address = devicesinfo.substring(devicesinfo.length()); Intent intent = new Intent(); intent.putExtra(EXTRA_DEVICE_ADDRESS, address); setResult(Activity.RESULT_OK, intent); Toast.makeText(getApplicationContext(),"Connecting to " + devicesinfo + address, Toast.LENGTH_SHORT).show(); } } </code></pre>
java android
[1, 4]
910,998
910,999
Creating unique id for textbox
<p>i like to have unique ids for textboxes and hidden filds .is there any property which will give unique id in asp.net ? </p> <p>something like </p> <p><code>&lt;asp:textbox id="ctr001_1" runat="server" uniqueid="textbox" /&gt;</code></p>
c# asp.net
[0, 9]
3,313,043
3,313,044
Correct usage for Page.ClientScript.RegisterForEventValidation
<p>i have the following method in a usercontrol</p> <pre><code> protected override void Render(HtmlTextWriter writer) { base.Render(writer); Page.ClientScript.RegisterForEventValidation(DataList1.UniqueID); if (DataList1.Items.Count &gt; 0) { foreach (DataListItem item in DataList1.Items) { Page.ClientScript.RegisterForEventValidation(item.UniqueID); foreach (Control ctrl in item.Controls) { if (ctrl is Button) { Button btn = ctrl as Button; Page.ClientScript.RegisterForEventValidation(btn.UniqueID, btn.CommandArgument); } } } } } </code></pre> <p>I'm trying to get the page to stop giving me the "Invalid postback or callback argument. Event validation is enabled using in configuration or &lt;%@ Page EnableEventValidation="true" %> in a page" error when a selection is made (button is clicked with databound command argument) in the Datalist. i've tried to register the event validation for the submit control, but i can't get it working.</p> <p>Anyone had any sucess using this method? I really don't want to disable the event validation for the page.</p>
c# asp.net
[0, 9]
1,537,547
1,537,548
Error: uncaught exception: Syntax error, unrecognized expression: $
<p>I need help on this.</p> <p>This is my code:</p> <pre><code>function addEntrance(ent) { ent.parent('tr').after($('.entrance.default').clone().removeClass('default')); } $('.add-entrance').click(function() { addEntrance($(this)); }); </code></pre> <p>And this is the error when I click <code>&lt;a href="#" class="add-entrance"&gt;</code>:</p> <pre><code>Error: uncaught exception: Syntax error, unrecognized expression: $ </code></pre> <p>Thanks!</p>
javascript jquery
[3, 5]
5,218,538
5,218,539
How to dynamically set align property for td in javascript?
<p>Here is my code, my question is in the comment:</p> <pre><code>function (align) { var column = $(`'&lt;td&gt;'`); // now i need syntax to set align property to this td element // column.align = align (not working) } </code></pre> <p>As shown, <code>column.align = align</code> is not working.</p> <p>Where am I going wrong?</p>
javascript jquery
[3, 5]
4,927,271
4,927,272
logging application requests
<p>I have several web services that logged-in user interact with. Currently they're running on ASMX but pending an upgrade to WCF. I'm going to write a logger that tracks the name of the request, the user ID, the parameters, the time processing time, if there was an error and a few other things. I'm thinking of something like this:</p> <pre><code>public class MyWebService : System.Web.Services.Webservice { MyAppLogger TheAppLogger = new MyAppLogger(); [WebMethod(EnableSession = true)] public string SomeWebService(string SomeParameters) { TheAppLogger.StartLogging(); TheJsonStringToReturn = ""; try { //do something that populates TheJsonStringToReturn } catch { TheAppLogger.LogException(); } TheAppLogger.LogRequest(); return TheJsonStringToReturn; } } </code></pre> <p>My question is this: if I go with what I just described, the <code>LogRequest()</code> method would store the request in the DB before the request is complete. Is that going to be performance problem? How would I change this code so that the database write would happen AFTER the request is responded to?</p> <p>Thanks for your suggestions.</p>
c# asp.net
[0, 9]
3,853,714
3,853,715
jquery onclick run
<p>I need to run all onclick events on page load. how can I do something like this:</p> <pre><code>$('.upload').foreach(function(){ //execute onclick for found element (ex: test(this, 'var') ) }); &lt;div class="upload" onclick="test(this, 'var')"&gt;text&lt;/div&gt; </code></pre>
javascript jquery
[3, 5]
2,293,750
2,293,751
Single page temporary PHP file upload
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/166221/how-can-i-upload-files-asynchronously-with-jquery">How can I upload files asynchronously with JQuery?</a> </p> </blockquote> <p>What are the best practices (if any) for allowing a user to select a file and have the contents sent to javaScript(jQuery) in a single page and asynchronously?</p> <p>HTML:</p> <pre><code>&lt;form action="" method="post" enctype="multipart/form-data"&gt; &lt;input type="file" name="file" id="file" /&gt; &lt;input type="submit" name="submit" value="Upload" /&gt; &lt;/form&gt; </code></pre> <p>JS/JQUERY:</p> <pre><code>$.document.ready(function(){ var txtString = new String(); //set the var to &lt;?php [$_FILE]["file"]["data"] ?&gt; } </code></pre> <p>I'm only using the data to kick off some javaScript so I shouldn't need to move the file out of the temp folder. I'm having a hard time figuring out where to put the PHP to send the file data to javaScript. Any suggestions would be much appreciated!</p>
php javascript jquery
[2, 3, 5]
4,333,747
4,333,748
Run PHP code inside JavaScript? Would this be ok to use?
<p>I am not sure if a line of PHP could be run inside of a JavaScript function. For example:</p> <pre><code>&lt;script language=javascript&gt; var int=self.setInterval("message()",1000); function message() { &lt;?PHP mysql_query("SELECT * FROM example"); ?&gt; } &lt;/script&gt; </code></pre> <p>I haven't tried to run this, but I don't think you can run PHP like this. Could anyone help. Could i run a PHP script inside a javascript function somehow without using a call to an outside PHP file through Ajax?</p>
php javascript
[2, 3]
4,209,857
4,209,858
javascript: Switching one pair of class
<p>On Stackoverflow site, the voting arrow initially it can be "vote-up-off"/"vote-down-off" if a user hasn't voted. It can also be one up / another down if the user voted before. Start from this 3 cases, upon the user click, I want to switch class. With help of nice people on this site, I arrived this code so far:</p> <pre><code>if($("a.vote-up-down").hasClass("vote-up-on")){ $(".vote-up-on").removeClass("vote-up-on").addClass("vote-up-off"); $(".vote-down-off").removeClass("vote-down-off").addClass("vote-down-on"); } else if($("a.vote-up-down").hasClass("vote-down-on")){ $(".vote-down-on").removeClass("vote-down-on").addClass("vote-down-off"); $(".vote-up-off").removeClass("vote-up-off").addClass("vote-up-on"); } </code></pre> <p>This works if you don't click up arrow again when it is already vote-up-on, or you don't click down arrow again when it is already vote-down-on. Otherwise, it keeps switching disregarding the actual vote. If initially both arrow is off, this code will change both. In my ajax function, I can provide response message of actual vote value ( 1 or -1), How can I correct the above code? </p>
javascript jquery
[3, 5]
3,601,909
3,601,910
PHP: Delete from a Database with some prompts from javascript
<p>My code is below, I am trying to delete records from mysql database but before deleting the browser has to prompt the user whether the deletion should continue. My problem is my logic is not working its deleting the record no matter what. Any help will be appreciated.</p> <pre><code> if (isset($_POST['outofqcellchat'])){ ?&gt; &lt;script type ="text/javascript"&gt; var question = confirm("Are you sure you want to unsubscribe\nThis will delete all your facebook information in QCell Facebook"); if(question){ &lt;?php $delusr = mysql_query("delete from `chat_config` where `phone` = '$phonenumb'"); $row = mysql_num_rows($delusr); if($row&gt;=1){ header("Location:http://apps.facebook.com/qcellchat"); } ?&gt; alert("Unsubscribed, You can register again any time you wish\nThank You"); }else { alert("Thanks for choosing not to unregister \nQCell Expand your world"); } &lt;/script&gt; &lt;?php } ?&gt; </code></pre> <p>Thats my code. Please help</p>
php javascript
[2, 3]
4,377,980
4,377,981
How to set ImageUrl based on the value of a field in a gridview
<p>I have the following line of code which evaluates whether the value is true or false, if its true it will show an image if its false it shows a different one.</p> <pre><code>&lt;itemTemplate&gt; &lt;img alt="" id="Img1" src='&lt;%# MyAdmin.GetCheckMark((bool)DataBinder.Eval(Container.DataItem, "ShowImg"))%&gt;' runat="server" /&gt;&lt;/ItemTemplate&gt; </code></pre> <p>Can I customize the Eval part in the back end code in c# and then pass a different variable to it for example in C# I want to do</p> <pre><code> bool ImgFlag = false; if(Entity.ShowImg == false &amp;&amp; Entity.SomethingElse == true) { ImgFlag = true; } else if(Entity.ShowImg == false &amp;&amp; Entity.SomethingElse == false) { ImaFlag = false; } else { ImgFlag = true; } </code></pre> <p>And then I want to use ImgFlag instead of ShowImg in my GridView on each row, so ImgFlag will determine which flag to show..</p> <p>Or is there a better way?</p> <p>The issue is that that eval depends now on two things.. not one as before.</p> <p>Thank you</p>
c# asp.net
[0, 9]
2,146,341
2,146,342
The 'MapPath' method cease to work as soon as it's procedure is moved to a C# class file
<p>I'm using C# ASP.NET VS2010.</p> <p>I have a procedure on an .aspx.cs that reads a XML file and works just fine.</p> <p>It goes like this:</p> <pre><code>string fileName = "~/App_Data/" + filename + ".xml"; DataSet ds = new DataSet(); ds.ReadXml(MapPath(fileName)); </code></pre> <p>I use this procedure alot to read various files with minimal changes (the file name), therefore, I tried to put the procedure in a Class1.cs file (in the App_Code folder), but I get this error message:</p> <pre><code>The type or namespace name 'MapPath' does not exist in the namespace 'Microsoft.SqlServer.Server' (are you missing an assembly reference?) </code></pre> <p>I use this MapPath to read an XML file into a dataset this way:</p> <pre><code>ds.ReadXml(Server.MapPath(fileName)); </code></pre> <p>The filename is a string variable declared a few lines earlier:</p> <pre><code>string fileName = "~/App_Data/" + inputString + ".xml"; </code></pre> <p>After putting this line in the class.cs file, the VS2010 asked to resolve the missing <code>Server</code> by replacing it into <code>Microsoft.SqlServer.Server</code> locally (at the same line and not by adding a namespace) , so the line in it's new form looks like this:</p> <pre><code>ds.ReadXml(Microsoft.SqlServer.Server.MapPath(fileName)); </code></pre> <p>For the record, I made sure that all namespaces on the source .aspx.cs file are at the class file.</p> <p>Why the difference between the Class1.cs and the .aspx.cs?</p> <p>How do I workaround this?</p> <p>What should I change in order to read the XML file from this new class file?</p> <p>Is there a replacement for my line to read the XML file into the dataset?</p>
c# asp.net
[0, 9]
4,022,493
4,022,494
How to load javascript function on page load ?
<p>I have used javascript to generate 2D bar-graphs in a HTML page. When i am trying to load this HTML page containing bar-graph in to a div tag of some other HTML page using jQuery <code>.load()</code> function bar-graph (i.e, scripts) are not loading.</p> <p>Please help on this issue.</p> <p>For example i have bar-graph in <code>xyz.html</code>. I am trying to load <code>xyz.html</code> in <code>abc.html</code> div tag using jquery <code>.load()</code> function. Bar-graphs are missing.</p> <p>Hoping for a reply, thanks for help in advance. </p>
javascript jquery
[3, 5]
5,725,451
5,725,452
how can I display dynamically generated bmp in browser
<p>On a .aspx page I am creating a bmp using the System.Drawing namespace. When the bmp is finished I am sending it to the browser using:</p> <pre><code>using (MemoryStream ms = new MemoryStream()) { bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp); byte[] buffer = ms.GetBuffer(); HttpContext.Current.Response.OutputStream.Write(buffer, 0, buffer.Length); HttpContext.Current.Response.Flush(); } </code></pre> <p>This seems to simply send the bmp to the browser which renders it - but not as an html page. You can't view source - it seems to be simply a bitmap.</p> <p>I'd like the bmp to be sent to the browser but as the 'content' of the body tag of an html page.</p> <p>Is the only way to do this to save (write) the bmp to disk and then use that file as the src of an image tag? Or is there a way of rendering it directly to the browswer but still as part of a html page?</p>
c# asp.net
[0, 9]
6,020,203
6,020,204
JavaScript Button Enable and Disable with PHP
<p>I have a while loop that fetches data from a database. I have made three buttons:</p> <pre><code>&gt; Open &gt; Hold &gt; Close </code></pre> <p>The first time when the page loads, only the open button should be enabled, and the others should be disabled.</p> <p>After I click the open button, the open button should be disabled, and the hold and close buttons should be enabled.</p> <p>I got this result for only one row, but in the while loop not for all the rows.</p> <p>I have used JavaScript with php.</p> <p>Example:</p> <pre><code>function onload() { document.getElementById("Hold").disabled = true; document.getElementById("close").disabled = true; return false; } </code></pre> <p>The above code was working for the first row, but I need it to work for all the while loop values.</p>
php javascript
[2, 3]
5,879,715
5,879,716
javascript unexpected token < , is there any way I can escape the errors(or atleast skip those useless characters)
<p>In php, I have an array like this : </p> <pre><code>$arr['a'] = "some big data so may contain some chars that bring us headache" $arr['b'] = "some big data same as above" $data = json_encode($arr) echo $data </code></pre> <p>My javascript code containing a jquery ajax call, $.ajax . It calls the file containing the above php code so, on success, the json_encoded(by php) is returned to my javascript variable . In my javascript file, I am doing like this : </p> <pre><code>jsdata = JSON.parse(data); //Getting error here $.ajax({ type: "post", data: jsdata, url: "url", crossDomain: true, dataType: 'jsonp' }).done(function(d) { print("success"); }); </code></pre> <p>From the above code, in the line jsdata = JSON.parse(data), I am getting errors something like </p> <pre><code> Error : UNEXPECTED TOKEN &lt; </code></pre> <p>As the data contains lot of different content, its normal to get those errors . They need to be escaped properly . Can anyone tell me how to do that correctly . Whatever the data may be , I shouldnot get error regarding the data . </p> <p>Thanks</p>
php javascript jquery
[2, 3, 5]
4,922,851
4,922,852
How to Update in the GridView if the headers are not databound
<p><img src="http://i.stack.imgur.com/Y4qHm.jpg" alt="enter image description here"> I have a <code>GridView</code>, and the header field of the <code>GridView</code> are the items from a <code>ListBox</code> in my program. Therefore the number of columns generated is dynamic every time I run. So when I click on <strong>Update</strong> in the <code>Gridview</code>, the data entered in <code>TextBox</code> of that row has to be updated irrespective of the header field. Also the <code>TextBox</code> should be validated to accept only integer.</p> <p>The .cs code for <code>GridView</code> display is:</p> <pre><code>protected void DONE4_Click(object sender, EventArgs e) { DataTable dt = new DataTable(); DataRow rw = default(DataRow); for (int i = 0; i &lt; ListBox1.Items.Count; i++) { dt.Columns.Add(ListBox1.Items[i].ToString(),System.Type.GetType("System.String")); } for (int j = 0; j &lt; count; j++) { rw = dt.NewRow(); for (int i = 0; i &lt; ListBox1.Items.Count; i++) { rw[ListBox1.Items[i].ToString()] = " "; } dt.Rows.Add(rw); } GridView2.DataSource = dt; GridView2.DataBind(); } } </code></pre> <p>Can anyone help me on this issue with a code for Updating? Thank you.. Hope the question is clear.</p>
c# asp.net
[0, 9]
4,864,749
4,864,750
Android Bitmap to List View
<p>I am trying to pass a bitmap from a url to my list i pass my bitmap as an object but my image wont display</p> <pre><code>for(int i=0;i&lt;CarsArray.length();i++){ HashMap&lt;String, Object&gt; map = new HashMap&lt;String, Object&gt;(); JSONObject e = CarsArray.getJSONObject(i); map.put("InventoryID", String.valueOf(i)); map.put("Year", " " + e.getString("Year") + " " + e.getString("Make") + " " + e.getString("Model")); map.put("Stock Number", "Stock#: " + e.getString("StockNumber")); map.put("VIN", "VIN: " + e.getString("VIN")); map.put("Color", "Exterior Color: " + e.getString("ExteriorColor")); map.put("InColor", "Interior Color: " + e.getString("InteriorColor")); map.put("Mileage", "Odometer: " + e.getString("Mileage")); map.put("Price", "$" + e.getString("Price") + "0"); map.put("VehicleStatus", e.getString("VehicleStatus")); map.put("InsertedDate", e.getString("InsertedDate")); bimage = getBitmapFromURL(imageUrl); map.put("Image", bimage); mylist.add(map); } ListAdapter adapter = new SimpleAdapter(this, mylist , R.layout.parsejson, new String[] { "Year", "Stock Number", "VIN", "Color", "Mileage", "Price", "VehicleStatus", "InColor", "InsertedDate", "Image"}, new int[] { R.id.item_title, R.id.item_subtitle, R.id.item_subtitle2, R.id.item_subtitle3 , R.id.item_subtitle4, R.id.item_subtitle5, R.id.item_subtitle6, R.id.item_subtitle8, R.id.item_subtitle9, R.id.imageView1}); setListAdapter(adapter); </code></pre>
java android
[1, 4]
4,967,878
4,967,879
jQuery navigation bar not working in?
<p>In my mobile application, I use navigation bar. and i use beta version 1.</p> <pre><code>&lt;div data-role="navbar" id="navibar"&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="#" id="searchNav1"&gt;Search&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#" id="shoppingNav1"&gt;Shopping&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; </code></pre> <p>JS:</p> <pre><code> $('#shoppingNav1').live("click",function() { alert("in"); shopping(); $.mobile.changePage("#shoppingListPage","pop", false, false); alert(""); }); </code></pre> <p>when i click this it's change the page in my desktop browser but not in actual device </p>
javascript jquery
[3, 5]
5,294,490
5,294,491
test failed loading of Google Analytics
<p>I noticed that stackoverflow has some JS code which generates: a warning with "Stack Overflow requires external JavaScript from another domain, which is blocked or failed to load.". This happened to me a moment ago when Google Analytics didn't load correctly. </p> <p>How would I do something like this? </p> <p>Note: I could have a but all other JS loads correctly this is only for google analytics which sometimes either never loads or takes forever.</p> <p>When I check the code they have:</p> <pre><code>StackExchange.init = function () { var e = function (a) { if (!window.jQuery) if ("complete" != document.readyState) setTimeout(function () { e(a) }, 1E3); else { var d = document.createElement("div"); d.id = "noscript-padding"; var g = document.createElement("div"); g.id = "noscript-warning"; g.innerHTML = a + " requires external JavaScript from another domain, which is blocked or failed to load."; document.body.insertBefore(d, document.body.firstChild); document.body.appendChild(g) } </code></pre> <p>But I am not sure what is going on with the setTimeout()</p>
javascript jquery
[3, 5]
4,718,553
4,718,554
Simple JQuery Flip-Card animation customisation
<p>I have a working Jquery flip card animation. When you click the front panel, it flips to the back panel and vice versa. Now I added 3 links onto the front panel, and I want each link to flip to its own back panel and back, but I'm not getting it to work. My working example: NOTE: I attached the flipcard js file as a resource (jquery.quickflip.source.js)</p> <p><a href="http://jsfiddle.net/gGAW5/24/" rel="nofollow">http://jsfiddle.net/gGAW5/24/</a></p> <p>So basically when you click on Panel 1, it should only show Panel 1 Back, and when you click Panel 1 Back, it should go back to the front Panel, not the other back panels as it does now. So each link has its OWN back panel.</p> <p>Would appreciate any help.</p> <p>Thanks</p>
javascript jquery
[3, 5]
5,339,881
5,339,882
How we can attach the unobtrusive validation with the id of the field?
<p>I am using <code>unobtrusive validation</code> in jquery. My problem is that the validation is attach with the <code>name</code> of the element, is there any way to attach it with <code>id</code> of the element? </p>
javascript jquery
[3, 5]
4,647,902
4,647,903
How to count elapsed time
<p>I have this counter below. I have a 10 and 20 questions game. I need to count how much time is passed when a user finish the game.</p> <pre><code>Timer T=new Timer(); T.scheduleAtFixedRate(new TimerTask() { @Override public void run() { runOnUiThread(new Runnable() { public void run() { countdown.setText(""+count); count++; } }); } }, 1000, 1000); </code></pre> <p>I use this to stop the counter:</p> <pre><code>T.cancel(); </code></pre> <p>Now I need two things. I need the final value to be a double, for example final score is: 15,49 seconds. And the second thing is of cource a way to count the elapsed time and store it in a variable. Thanks.</p>
java android
[1, 4]
5,062,439
5,062,440
How to specify string parameters in C# using webservice
<p>Hello I recently used a weather asmx web service here is the link as well <a href="http://www.webservicex.com/globalweather.asmx?op=GetWeather" rel="nofollow">http://www.webservicex.com/globalweather.asmx?op=GetWeather</a> , im wondering though how can I only show off what I need. this is the result I get:</p> <blockquote> <p>Berlin-Tegel, Germany (EDDT) 52-34N 013-19E 37M May 03, 2013 - 04:50 PM EDT / 2013.05.03 2050 UTC from the NNE (030 degrees) at 3 MPH (3 KT):0 greater than 7 mile(s):0 51 F (11 C) 33 F (1 C) 50% 30.03 in. Hg (1017 hPa) Success</p> </blockquote> <p>My code(one line): <code>Label1.Text = ws.GetWeather("Berlin", "Germany");</code></p> <p>as you can see above the webservice provides the weather and other details that I really not interested to show in my page thus im wondering how can I only show the details I need</p>
c# asp.net
[0, 9]
6,010,581
6,010,582
How to split the header of an image?
<p>I have designed a website which users upload some images and I store them in a folder.but anyone else can access the uploaded file via URL. However I want to split the header of Uploaded images and insert the header in the database and store the rest of file in the folders. How can I split the header of image? If I convert the image to the array of binary how to distinguish the header part?</p>
c# asp.net
[0, 9]
2,356,244
2,356,245
jquery addClass adding subclass not working
<p>this is my 1st time posting here, so thanks to everyone who can give me some advice!</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;style&gt; &lt;/style&gt; &lt;script src="jquery-1.5.2.js"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div class="super" style=" border: solid black 1px; height:100px; width:100px; "&gt; &lt;/div&gt; &lt;div class="super .eight" style=" background: blue; "&gt; &lt;/div&gt; &lt;script&gt; $(".super").click(function () { $(this).addClass(" .eight"); }); &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>So basically the problem is that I want to add for example a background or some other type of element onto class that is already defined as super. I am trying to use subclasses but it does not seem to be working.</p> <p>Please ask me if there is anything unclear, I apologize if there is. </p>
javascript jquery
[3, 5]
2,729,859
2,729,860
ASP.NET Classes Question
<p>Could someone tell me the difference between </p> <pre><code>static public public static </code></pre> <p>and </p> <pre><code>private int _myin = 0 public int MyInt { get{ return _myInt; } private set {_myInt = value; } } </code></pre> <p>the private set part is what I want to know</p>
c# asp.net
[0, 9]
70,378
70,379
The constructor AdPreferences(int, int, String) is undefined startapp?
<p>I'm trying to use Startapp for my app, i keep on getting this error i don't know why ! the error is at this line</p> <pre><code>AdPreferences adPreferences = new AdPreferences(developers ID,App ID,AdPreferences.TYPE_INAPP_EXIT); htmlAd = new HtmlAd(this); htmlAd.load(adPreferences, this); </code></pre> <p>I removed my IDs </p> <p>Here is the full code </p> <pre><code>public class SplashActivity extends WhatsNewActivity implements OnClickListener { private Button mButtonPlay; private HtmlAd htmlAd = null; @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.splash); mButtonPlay = (Button) findViewById(R.id.button_go); mButtonPlay.setOnClickListener(this); ImageView image = (ImageView) findViewById(R.id.image_splash); image.setImageResource(R.drawable.splash); AndroidSDKProvider.setTestMode(true); AndroidSDKProvider.initSDK(this); AdPreferences adPreferences = new AdPreferences(xxxxxxxxx,xxxxxxxxx,AdPreferences.TYPE_INAPP_EXIT); htmlAd = new HtmlAd(this); htmlAd.load(adPreferences, this); } @Override public void onBackPressed() { if(htmlAd != null) { htmlAd.show(); } super.onBackPressed(); } /** * {@inheritDoc } */ public void onClick(View v) { if (v == mButtonPlay) { Intent intent = new Intent(this, PaintActivity.class); startActivity(intent); } } @Override public int getFirstRunDialogTitleRes() { return R.string.first_run_dialog_title; } @Override public int getFirstRunDialogMsgRes() { return R.string.first_run_dialog_message; } @Override public int getWhatsNewDialogTitleRes() { return R.string.whats_new_dialog_title; } @Override public int getWhatsNewDialogMsgRes() { return R.string.whats_new_dialog_message; } } </code></pre>
java android
[1, 4]
2,116,765
2,116,766
redirecting to other page with value in javascript via click
<p>I want to create a Javascript file to do these operations:</p> <ol> <li>Pass the current link to the other page</li> <li>Click on hypertext or image that is created dynamically in JavaScript file to redirect</li> </ol> <p>Just I want to have a Javascript link in the html body and not other thing same this :</p> <pre><code>&lt;div&gt; &lt;script type="text/javascript" src="JScript.js"&gt;&lt;/script&gt; &lt;/div&gt; </code></pre> <p>And in the JavaScript file I have these: </p> <pre><code>var DivTag = document.createElement("Div"); DivTag.setAttribute('ID', 'MyDivTagID'); $(document).ready(function () { $("$MyDivTagID").click(function(e) { window.location = "http://www.MyLink.com/?Url=" + window.location; }); }); </code></pre> <p>This is not working. Please help me.</p>
javascript jquery
[3, 5]
5,897,336
5,897,337
How to ADD days to selcted date in asp using ajax calendar extendar?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/13006280/how-to-add-or-subtract-dates-in-c-sharp-using-ajax-calendar-extender">How to add or subtract dates in C# using ajax calendar extender?</a> </p> </blockquote> <p>I have two textboxes in which i have used ajax calendar extender. When I choose a date from one textbox, I want the other one filled with a date calculated from the one selected by adding some days or months. How can i do that?</p>
c# asp.net
[0, 9]
5,751,334
5,751,335
The best way to copy the the input values between two view
<p>I have two different views which have the same number of fields (checkbox type) to be filled out.</p> <p>I need to copy the values from one view to the other when clicking on the copy button..</p> <p>Here is my code which works:</p> <pre><code>$('button').on('click', function () { var firstInputSet = $('#contest_data_updatePeriodicity').find('input'), secondInputSet = $('#contest_data_reminderPeriodicity').find('input'); for (var i = 0; i &lt; firstInputSet.length; i ++) { //console.log($(firstInputSet[i]).prop('checked')); $(secondInputSet[i]).prop('checked', $(firstInputSet[i]).prop('checked')) } });​ </code></pre> <p>I would like to know if there is a best way to do this job.</p> <p>Here is the demo:</p> <p><a href="http://jsfiddle.net/D2RLR/2639/" rel="nofollow">http://jsfiddle.net/D2RLR/2639/</a></p>
javascript jquery
[3, 5]
2,473,066
2,473,067
Can running 2 document.ready make them conflict?
<p><br> In my application i am running <code>$(document).ready(</code> twice on on the same page is there going to be a conflict between them?<br> Thanks in Advance,<br> Dean </p>
javascript jquery
[3, 5]
4,910,098
4,910,099
Change Text on click
<p>Ok so if I was doing a form, I could use:</p> <pre><code>&lt;form method="get" action=""&gt; &lt;label for="textinput"&gt;Text:&lt;/label&gt; &lt;input type="text" value="" name="textinput" id="textinput" /&gt; &lt;input type="submit" id="submitbutton" value="Search" onclick="return changeText('submitbutton');" /&gt; &lt;/form&gt; </code></pre> <p>Then add this js:</p> <pre><code>function changeText(submitId){ var submit = document.getElementById(submitId); submit.value = 'Working...'; return false; }; </code></pre> <p>BUT my issue is my link is this:</p> <pre><code>&lt;a id="sharelink" href=""&gt;Post to Here&lt;/a&gt; </code></pre> <p>So wondering if ONCLICK of link ID > sharelink</p> <p>I could show > working...</p> <p>Any suggestions ?</p>
javascript jquery
[3, 5]
2,588,491
2,588,492
How to check if the any of my textbox is empty or not in javascript
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/1854556/check-if-inputs-are-empty-using-jquery">Check if inputs are empty using jQuery</a> </p> </blockquote> <p>I have form and textboxes, how will I determine if any of these textboxes is empty using javascript if else statement once a form button is clicked.</p> <pre><code>function checking() { var textBox = $('input:text').value; if (textBox == "") { $("#error").show('slow'); } } </code></pre> <p>Thanks in advance!</p>
javascript jquery
[3, 5]
4,034,611
4,034,612
Make function execute after user hovers over link for 2 seconds
<p>Yes, I know this question has been asked before, but I can't find an answer that works. This is an accepted answer from one of the other questions:</p> <pre><code>$('#element').hover(function() { $(this).data('timeout', window.setTimeout(function() { alert('hovered for 2 seconds'); }, 2000)); }, function() { clearTimeout($(this).data('timeout')); alert('mouse left'); }); </code></pre> <p><a href="http://jsfiddle.net/nCcxt/" rel="nofollow">http://jsfiddle.net/nCcxt/</a></p> <p>As you see it doesn't do what it's supposed to.</p> <p>What I need is simple in theory but I can't get it to work - when a user hovers over a link for 2 seconds, a function is called. If the user moves the mouse away before 2 seconds pass, nothing happens.</p>
javascript jquery
[3, 5]
3,165,283
3,165,284
Equivalent to PHP's include in C#
<p>What is the equivalent command to PHP's include() in C# ? </p> <p>For example, PHP's include is used as so : include("ex.php");</p> <p>Can I do the same in C#?</p>
c# php
[0, 2]
410,132
410,133
jQuery: How to calculate the maximal attribute value of all matched elements?
<p>Consider the following HTML:</p> <pre><code>&lt;div class="a" x="6"&gt;&lt;/div&gt; &lt;div class="a" x="9"&gt;&lt;/div&gt; &lt;div class="a" x="2"&gt;&lt;/div&gt; ... &lt;div class="a" x="8"&gt;&lt;/div&gt; </code></pre> <p>How would you find the maximal <code>x</code> value of all <code>.a</code> elements ?</p> <p>Assume that all <code>x</code> values are positive integers.</p>
javascript jquery
[3, 5]
5,501,661
5,501,662
How can I know when a certain iframe gets removed from a page
<p>Let's say I have an iframe on a HTML page:</p> <pre><code>&lt;iframe src="/script.php"&gt;&lt;/frame&gt; </code></pre> <p>The iframe is inside a modal box window (I'm using a jQuery plugin for modal window: <a href="http://opensource.steffenhollstein.de/templates/modalbox/" rel="nofollow">http://opensource.steffenhollstein.de/templates/modalbox/</a>).</p> <p>When the modal box gets closed, the iframe inside it is removed from the page's HTML with jQuery remove() method.</p> <p>How can I notice that the iframe has been removed and execute some javascript code? Basically what I want is to refresh the page once the modal box is closed. This is the close method for the modal box plugin:</p> <pre><code>jQuery.fn.modalBox.close = function(settings){ // merge the plugin defaults with custom options settings = jQuery.extend({}, jQuery.fn.modalBox.defaults, settings); if( settings.setFaderLayer &amp;&amp; settings.setModalboxContainer ){ jQuery(settings.setFaderLayer).remove(); jQuery(settings.setModalboxContainer).remove(); jQuery("iframe.modalBoxIe6layerfix").remove(); } }; </code></pre>
javascript jquery
[3, 5]
5,022,086
5,022,087
How can I download image for ImageView in Java, Android?
<p>I need to download image from my server and load this image into imageview. So I have a question - can I download image into memory and set it for ImageView, without saving on sdcard/local storage? Or I must download into some file storage? Give me example please if it possible. </p>
java android
[1, 4]
1,180,590
1,180,591
php code transfer into js
<p>the javascript code in php is</p> <pre><code>&lt;script language="JavaScript" type="text/javascript"&gt; xajax_getCountry('&lt;?php echo $row['mradio_area']?$row['mradio_area']:0 ?&gt;', &lt;?php echo $row['mradio_country']?$row['mradio_country']:0 ?&gt;, &lt;?php echo ($row['mradio_rate']==1?1:0); ?&gt;); &lt;/script&gt; </code></pre> <p>I want to put it into the .js file.</p> <p>How do I change the <code>&lt;?php echo $row</code> into js format?</p> <p>Thanks a lot for any answer!</p>
php javascript
[2, 3]
3,092,677
3,092,678
How to add dynamic asp.net controls in the Gridview in c#
<p><img src="http://i.stack.imgur.com/6dXyR.png" alt="Requirement is as shown in the image"></p> <p>I am trying to achieve this by adding controls dynamically to the gridview. After I click on Add row(+) button all gridview values are vanishing...?</p>
c# asp.net
[0, 9]
2,467,764
2,467,765
Save value in PHP Session variable
<p>I have an html table which contains records, comes from mysql db. Each row also contains id (PK) wrt db table record. Now I want to save record id in <strong>PHP Session variable</strong>, when I click on a row. To do this I used <strong>onclick</strong> property for each row &amp; call a javascript function with record id as function parameter &amp; it works fine but how could I save this id in <strong>PHP Session variable</strong> ? Thanks.</p>
php javascript
[2, 3]
1,945,678
1,945,679
Does using jQuery.get effectively double the ping time?
<p>Suppose I have some script myScript.js that uses jQuery.get() to retrieve a small piece of data from the server. Suppose also that my ping time is horrible at 1500ms. Does using jQuery.get effectively double the ping time to 3000ms? </p> <p>Or is there async magic that allows some sort of parallel processing? The reason I'm asking is that we use jQuery.get() fairly liberally and I'm wondering if it is an area we need to look at optimizing.</p> <p>Edit: double compared to if I can somehow rearrange things to just load all the data upon the initial load and bypass jQuery get altogether</p>
javascript jquery
[3, 5]
1,088,435
1,088,436
Is there an advantage in how I store my data using jQuery?
<p>I know understand more about how jQuery stores data. </p> <p>Is there any advantage to doing one or the other of these:</p> <pre><code>$('#editCity').data('href', "xx"); var a = $('#editCity').data('href'); </code></pre> <p>or </p> <pre><code>$('#editCity').attr('data-href', "xx"); var a = $('#editCity').attr('data-href'); </code></pre> <p>One more related question. </p> <p>If I have this:</p> <pre><code>var modal = { x: 'xx', y: 'yy' }; </code></pre> <p>Can I also store this using .data( .. ) ?</p>
javascript jquery
[3, 5]
3,749,636
3,749,637
strange problem with ToolTip
<pre><code>&lt;asp:CheckBox ID="chkLivrareExterna" runat="server" OnCheckedChanged="ChkLivrare_CheckedChanged" AutoPostBack="true" ToolTip="&lt;%= getChkLivrareExternaToolTip() %&gt;"/&gt; </code></pre> <p>and the method is:</p> <pre><code> protected String getChkLivrareExternaToolTip() { return "testIN"; } </code></pre> <p>I cannot understand why, at tool tip on mouse over it puts:</p> <blockquote> <p>&lt;%= getChkLivrareExternaToolTip() %></p> </blockquote> <p>instead of evaluating this expression...</p> <p>Tried with simple quotes but the same problem.</p>
c# asp.net
[0, 9]
1,330,294
1,330,295
PHP Show next image in the table
<p>I am showing an image on my page from the db table like this:</p> <pre><code>&lt;?php if ($db_found) { $SQL = "SELECT * FROM myTable where id='$posted_id'"; $result = mysql_query($SQL); while ($db_field = mysql_fetch_assoc($result)) { echo '&lt;img src="images/'.$db_field['image'].'" alt="" /&gt;'; } mysql_close($db_handle); } ?&gt; &lt;a href="#"&gt;Next&lt;/a&gt; </code></pre> <p>How can I do so that if $posted_id is for example 1 ... when I click the "Next" link the image id = 2 appears and so on.</p>
php jquery
[2, 5]
2,110,309
2,110,310
JS and jQuery - loop through textboxes and store value
<p>Here's the function that checks if the form is complete.</p> <p>So, what I'm trying to do:</p> <ol> <li>If radio is not selected, throw a message.</li> <li>If radio is "yes", but text is not entered, throw error.</li> <li>If radio is "no" but text is entered, make the text empty.</li> <li>If all is good, add stuff into `allResponses</li> </ol> <p>The form was displayed 5 times, and input was as follows:</p> <pre><code>Yes a1 No Yes a3 No Yes </code></pre> <p>Now, this input should display an error since in 5th case, "yes" is selected but nothing is entered in the textbox.</p> <p>However, I get this:</p> <p><a href="http://i.imgur.com/ya2CUp0.png" rel="nofollow">http://i.imgur.com/ya2CUp0.png</a></p> <p>Also, the text is not being updated as in 1st and 3rd cases.</p> <p>I don't know a lot about JS, so please provide me with as explained responses as you can.</p> <p>EDIT: Complete code: <a href="http://pastebin.com/scNSNM2H" rel="nofollow">http://pastebin.com/scNSNM2H</a></p> <p>Thanks</p>
javascript jquery
[3, 5]
5,841,106
5,841,107
Create "namespace" in $(document).ready(function() {..});
<pre><code>// first.js $(document).ready(function() { var MyNamespace = {}; }); // second.js $(document).ready(function() { console.log(MyNamespace); }); </code></pre> <p>Running this script I'm getting error <code>Uncaught ReferenceError: MyNamespace is not defined</code>. I suppose, I'm getting this error because definition of <code>MyNamespace</code> and <code>MyNamespace</code> calling are in different scopes. How do I solve this problem?</p> <p>I need to create namespace inside $(document).ready() wrapper because functions in this namespace will use jQuery methods etc.</p> <p>What is the best practice?</p> <p>Thank you!</p>
javascript jquery
[3, 5]
2,403,484
2,403,485
Javascript/jQuery: How to increment a number and highlight text when selected
<p>I've searched and search, but cannot find what I need. I know very little about Javascript so I need a bit of help with this.</p> <p>I have a number, say numValue, that I want to increase or decrease based on items being selected in different areas. Plus I want those items to highlight and stay highlights until clicked again. When selected I want numValue to decrease by 1 and when deselected I want numValue to increase by 1. </p> <p>Example:</p> <p><strong>50</strong> (numValue)</p> <p>Group 1 </p> <ul> <li>Option 1</li> <li>Option 2</li> <li>Option 3</li> </ul> <p>Group 2</p> <ul> <li>Option 1</li> <li>Option 2</li> <li>Option 3</li> </ul> <p>So if I click on Group 1/Option 1 and Option 2 plus Group 2/Option 3 I want the numValue to decrease by 3 (for 3 selected options). I want each item to stay selected when clicked not deselect when another option is clicked. Then deselect when clicked a second time. So it becomes:</p> <p><strong>47</strong> (numValue)</p> <p>Group 1 </p> <ul> <li><strong>Option 1</strong></li> <li><strong>Option 2</strong> </li> <li>Option 3</li> </ul> <p>Group 2</p> <ul> <li>Option 1</li> <li>Option 2</li> <li><strong>Option 3</strong></li> </ul> <p>Can anyone point me in the right direction? </p>
javascript jquery
[3, 5]
5,942,060
5,942,061
How to check browser support for capabilities / events?
<p>In the past we used browser sniffing to infer if certain events or capabilities were available. I understand that browser sniffing has been 'deprecated' or 'shunned' in favor of feature sniffing. I would like to know how I can check if a certain event can be handled.</p> <p>Take <code>DOMNodeInserted</code> for example. It is supported by Chrome, FF and Safari, but not by IE. How can I sniff if this event is available? Is there a library present? How do you guys do proper feature sniffing?</p>
javascript jquery
[3, 5]
5,420
5,421
Calculate the Date based on Current Date and No of Days using Javascript/Jquery
<p>I need a help.. I have a Current Date and No of days column. When i enter number of days,i should add current date plus no of days entered. For example, todays date 5th jan + 20(no of days) = 25th Jan 2011 in another column.</p> <p>Kindly help me. Thanks in Advance.</p>
javascript jquery
[3, 5]
5,429,280
5,429,281
Having trouble running an if statement on a jquery ajax output
<p>in my check.php I have an echo "ok";</p> <p>however my if statement to check if the value is ok does not work. Basically I want to execute a javascript function after check.php looks for the email in the database.</p> <pre><code> $.ajax({ type: "POST", url: "check.php", data: "checkit=" + $("#checkEmail").val(), success: function(output){ $("#userCheck").html(output); if(output == "ok"){ alert("yay"); } } }); </code></pre>
php javascript jquery
[2, 3, 5]
2,200,432
2,200,433
How to use List<Data> in android?
<p>How should I use <code>List&lt;Data&gt; dat = new List&lt;Data&gt;();</code> to temporary store data in my software? <code>"Data"</code> is a class in my code with variables(mainly <code>Strings</code>). When I try that method it doesn't store data.</p>
java android
[1, 4]
4,262,111
4,262,112
Where can I find package of Android Media Player?
<p>I need to execute Intent, but I also need to set application directly. I know that I can do it using Intent.setPackage(), and I need to set Android Media Player by default. Please, tell me, how can I do it? Thank you. </p>
java android
[1, 4]
4,929,562
4,929,563
Decimal without decimal places and comma formatted values
<p>How this i can solve, </p> <p>In database I have field for example Test decimal(18,2), and in text box user entered 656,347. In aspx i try</p> <pre><code>&lt;asp:TextBox ID="txtTest" runat="server" Text='&lt;%# Bind("Test", "{0:n0}") %&gt;' /&gt; </code></pre> <p>and get this: Error while setting property 'Test': '656,347 is not a valid value for Decimal.'. When i try F0 everything works, but i dont have comma separator. How can I do this. My UICulture and Culture is en-US, and I can't change database field.</p>
c# asp.net
[0, 9]
1,620,453
1,620,454
How to store variable within javascript to limit number of http calls?
<p>I am using a second party file downloader which returns a progress event. I can capture the event and call a program on the server to perform an update (for security purposes so I can tell the most recent activity).</p> <p>I get about 30 events per second all at percent downloaded 1%, then 30 more at 2%, then 30 more at 3%, etc. I would like to limit my http calls to only once per percentage change, 1%, 2%, 3%, etc. I would put a hidden field on the page and compare that and update it, but I cannot refresh the page since the download is in progress.</p> <p>Is there a way to use some type of client side storage within javascript or jquery for this?</p> <p>In other words, I need to be able to tell when the PercentCurrent value changes from 1 to 2, etc.</p> <p>My javascript function looks like this:</p> <pre><code> function onProgress(PercentTotal, PercentCurrent, Index){ var xmlhttp; //The handler will update the file progress if (typeof XMLHttpRequest != 'undefined') { xmlhttp = new XMLHttpRequest(); } if (!xmlhttp) { throw "Browser doesn't support XMLHttpRequest."; } var data = ""; xmlhttp.open("POST", "UpdateProgress.aspx?PercentCurrent=" + PercentCurrent, true); //Send the proper header information along with the request xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); //xmlhttp.setRequestHeader("Content-length", data.length); xmlhttp.setRequestHeader("Connection", "close"); xmlhttp.send(data); } </code></pre> <p>Thank you, Jim</p>
javascript jquery
[3, 5]
854,370
854,371
Find closest element with display: block
<p>I have a certain jQuery selection and I am looking to find the closest element (so self or parent) that is a block element (<code>display: block</code>).<br> The style is not necessarily inline, so the selector <code>[style*=display:block]</code> does not work in every case for me. I think I would need to use the computed style rather but need an efficient way to do that (if possible without a <code>$(this).parents().andSelf().each</code> loop)</p>
javascript jquery
[3, 5]
4,621,933
4,621,934
Quiting the page before a form submission
<p>In my application I am showing the warning message when the user want to leave the page before submitting the form. I am using window.onbeforeunload() in the script. My application has a Master page.</p> <p>I have four different views for a single form. I am inserting record in first view itself. When user quits the page I want to make some DB change(deletion of record). That's why I want to call a server side function from the script. </p> <p>How to do it ? Can anybody suggest something ?</p> <p>Thanks</p>
asp.net javascript
[9, 3]
1,454,308
1,454,309
Method implementation difference.. need some understadning
<p>Excuse me first. because i don't know this is question is valid or not. i if any one clear my doubt then i am happy.</p> <p>Basically : what is the different between calling a method like:</p> <ol> <li><p>object.methodname();</p></li> <li><p>$('#element').methodname();</p></li> </ol> <p>calling both way is working, but what is the different between, in which criteria make first and second type of methods. is it available in the core javascript as well?</p> <p>In case if i have a function is it possible to make 2 type of method call always?</p> <p>Can any one give some good reference to understand correctly?</p> <p>Thanks in advance.</p>
javascript jquery
[3, 5]
2,731,782
2,731,783
res/ directory tree
<p>I'm going through some book which tries to teach android development. In the book, the author outlines some of the directories found under res/. He mentions res/menu which holds XML based menu specifications. He also makes mention of res/raw which holds "general-purpose files." These folders were not created when I created a new android project. I'm using the latest Android SDK with the latest Eclipse version. Are those folders he mentions from some older version of the android SDK?</p>
java android
[1, 4]
2,367,231
2,367,232
I want to use the gallery swipe in home page
<p>The thing is that,How can i use the photoswipe javascript on page load rather than when trigred with tag. Is there a way or I have to search for alternatives?</p>
javascript jquery
[3, 5]
3,362,065
3,362,066
Highlight the selected row in data list
<p>I have a DataList on ym web page, from which a user can choose a certain option within the DataList row.</p> <p>I use the <code>ItemCommand</code> of DataList for this. Actually, I want to highlight the selected row when the user clicks on the item in the row.</p> <pre><code>&lt;ItemTemplate&gt; &lt;tr&gt; &lt;td style="text-align:center"&gt;&lt;asp:LinkButton ID="Item" Text='&lt;%#Eval("Item")%&gt;' CommandName="select" runat="server" /&gt; &lt;br /&gt;&lt;/td&gt; &lt;td style="text-align:center"&gt;&lt;asp:Label ID="lbQuery" Text='&lt;%#Eval("Query")%&gt;' runat="server" /&gt;&lt;br /&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/ItemTemplate&gt; </code></pre> <p>As shown above, the user can click on the LinkButton to choose an item. How do I highlight the corresponding row or only the cell?</p>
c# asp.net
[0, 9]
483,883
483,884
How to Find my website Visitor Region Code, IP and City Through simple javascript please no Google Analytics or other Software
<p>I want to Know how can i find Region of Visitor and IP adress through java script Region and City is on high priority these ones are not working</p> <pre><code> &lt;script type="text/javascript"&gt; $(document).ready(function () { $("#hdnCountryCode").val(geoip_country_code()); $("#hdnCountyName").val(geoip_country_name()); $("#hdnCity").val(geoip_city()); $("#hdnRegionCode").val(geoip_region()); $("#hdnRegion").val(geoip_region_name()); $("#hdnLatitude").val(geoip_latitude()); $("#hdnLongitude").val(geoip_longitude()); (function(){ $("#btnV").click(); return false; }); }); &lt;/script&gt; </code></pre>
javascript jquery
[3, 5]
429,041
429,042
Hide everything between 2 h2 tags?
<p>I have the following html snippet;</p> <pre><code>&lt;h2&gt;Headline 1&lt;/h2&gt; &lt;p&gt;Lorem ipsum bla bla&lt;/p&gt; &lt;p&gt;Lorem ipsum bla bla&lt;/p&gt; &lt;p&gt;Lorem ipsum bla bla&lt;/p&gt; &lt;h2&gt;Headline 2&lt;/h2&gt; &lt;p&gt;Lorem ipsum bla bla&lt;/p&gt; &lt;h2&gt;Headline 3&lt;/h2&gt; &lt;p&gt;Lorem ipsum bla bla&lt;/p&gt; &lt;p&gt;Lorem ipsum bla bla&lt;/p&gt; </code></pre> <p>I wish to somehow, via jquery, target each "block" so i can append a div arround it. By "block" i mean all the code between h2 start-tag and down to the last p-tag, before the next h2 start-tag. The last h2-tag within the section, should just take the last p-tag.</p> <p>Any suggestions as to how i best do this?</p>
javascript jquery
[3, 5]
198,281
198,282
Binding jQuery click events via looping through hash grabs last element in hash?
<p>I have a number of divs I am toggling on and off. I initially was manually binding the handlers(as per the code below), but decided to do some refactoring. However, a binding issue arose where the last key/value in the hash is the one always selected. In the example code, that would be the contact_data div. I think the problem is that the data is not being closed over, but I am not certain how to force this in JS.</p> <pre><code>var link_div = { "#about_toggle" : "#about_stuff", //more pairs "#contact_toggle" : "#contact_data" }; /* * Before refactoring: $("#about_toggle").click( function() { $("#about_stuff").toggle(); }); */ //After for(var key in link_div) { $(key).click(function() { alert(link_div[key]); toggle_on_element(link_div[key]); }); } </code></pre>
javascript jquery
[3, 5]
2,710,421
2,710,422
How to prompt user to enter a valid mobile phone number?
<p>I am currently developing an Android anti-theft application and I am new in Android development. My apps is able to remotely lock the lost phone, so during configuration, user needs to enter a valid phone number, but how I determine whether the phone number entered is valid? Thanks</p>
java android
[1, 4]
2,854,189
2,854,190
javacript confirm box
<p>I have a href as follows:</p> <pre><code>&lt;a class="eLink" href="http:www.abc.com"&gt;chk here xyz&lt;/a&gt;&lt;/li&gt; </code></pre> <p>and javascript for "eLink" is as follows:</p> <pre><code>$("a.eLink").click(function link(evt) { url = evt.target.href; if (url.toString().toLowerCase().indexOf(".gov") &lt;= 0) { var tk = "Do you really want to continue?"; if (confirm(tk)) { window.open(url, 'newwin'); } } else { window.open(url, 'newwin'); } return false; }); }); </code></pre> <p>Now, when click the hyper link i get the message "Do you really want to continue?", now When i click 'yes' it open a new browser with the target page "abc.com" and my current browser also changes to "abc.com". i want to change the code in sucha way that current browser remains int he same page and taget browser "abc.com" opens in the new page and if i click "No", the browser should remain in the same page. I tried using them in a plain javascript with confirm boxes,but the problem is wherever i have to use this code, the external browser link has to be given in the javascript which i want to avoid. Is there a quick change in the above script that would accompalish what i would want. Thanks.</p>
javascript jquery
[3, 5]
3,558,019
3,558,020
how to call jquery plugin function from other plugin
<p>I have two plugins tabs.js and slideshow.js I need call function timeOut() in tabs.js but I can't accses it becouse it is in slideshow.js file <a href="http://rnt999.arvixevps.com/~rnt999/test/slider/main.html" rel="nofollow">http://rnt999.arvixevps.com/~rnt999/test/slider/main.html</a> this is full code. Please javascaript guru help me!:)</p>
javascript jquery
[3, 5]
5,003,664
5,003,665
jstree 1.0 does not work well
<p>I have a problem with the new version of jstree when using this part of code. At the first execution, the data function returns the root node. The problem is that this code never executes again. So whatever happens, I just have the root node. Does anybody know a solution?</p> <pre><code>$('#tree').jstree( json_data: { ajax: { url: '&lt;%=url %&gt;', dataType: "json", data: function (n) { return { "id": n.attr ? n.attr("id") : 0 }; } } }, themes: { url: '/ThirdParty/jquery/jsTree/themes/', theme: "default", dots: true, icons: true }, plugins: ["json_data", "themes", "ui"] }) { </code></pre>
asp.net javascript
[9, 3]
3,833,664
3,833,665
not alerting the variable value passed from onclick php function
<p>on click, a)I am not getting alert, when i pass $picname variable to jquery img function(the value of the $picname is tulips.jpg)</p> <p>b)i am getting the alert (22) when i pass the variable $picid(the value of the $picid is 22)</p> <p>i think jquery function does not alert images extentions,if so then how can i pass the image name variable whose value having extension,to the jquery function to use its value</p> <pre><code>function profile(){ $sql = mysql_query("SELECT * FROM profile"); while ($row = mysql_fetch_array($sql)) { $picname= $row['picname']; $picid= $row['id']; ?&gt; &lt;table style="margin-left: 110px"&gt; &lt;tr&gt;&lt;td&gt;&lt;a href="#img" class="ok"&gt;&lt;img style='width: 200px' src="images/&lt;?php echo $picname ?&gt;" alt="name" onclick=img(&lt;?php echo $picname ?&gt;); &gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt; &lt;/table&gt; &lt;?php }} </code></pre> <p>jquery function is</p> <pre><code>function img(n){ alert(n); } </code></pre>
php javascript jquery
[2, 3, 5]
4,588,533
4,588,534
How to call a class in the App_Code folder from code behind?
<p>I created a class in ASP.NET C# which is located in the App_Code folder. Now I want to call this class from my code behind from one of my .aspx pages. How can I do this?</p> <p>Any help will be appreciate it.</p>
c# asp.net
[0, 9]
1,747,560
1,747,561
what is the original location for asp.net request?
<p>I am trying to determine when a user opens a link in my website through an email that I sent. What would be the best way to do this? I know I can add a querystring parameter , &amp;OpenedTroughEmail=1 or something.</p>
c# asp.net
[0, 9]
1,587,412
1,587,413
How do I create a honeycomb div grid rather than the standard grid?
<p>Here is a rough normal grid structure: <a href="http://jsfiddle.net/CFxzH/1/" rel="nofollow">http://jsfiddle.net/CFxzH/1/</a></p> <p>I am trying to create what I call a honeycomb grid rather than the standard div grid. Here is a rough illustration.</p> <p>NORMAL GRID</p> <pre><code>[] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] </code></pre> <p>HONEYCOMB GRID</p> <pre><code>[] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] </code></pre> <p>What I also want to achieve is dynamic 100% width of the parent box, expanding with the width of the window.</p>
javascript jquery
[3, 5]
60,254
60,255
How to add Javascript code using jQuery and setTimeout()
<p>I have some tracking code that the provider (WebTraxs) says should be placed at the bottom of the tag. The problem is that this same code is causing everything on the page (including my jQuery code) to run AFTER the WebTraxs is executed. This execution sometimes takes long enough where images rollovers, etc aren't working because the user is mousing over images before WebTraxs has finished.</p> <p>Therefore, I'm trying to add the needed tags (from WebTraxs) to the body after the page is loading in the document ready handler, using the following:</p> <pre><code> setTimeout(function(){ var daScript = '&lt;script language="JavaScript" type="text/javascript" src="/Scripts/webtraxs.js" /&gt;'; var daOtherScript = '&lt;noscript&gt;&lt;img alt="" src="http://db2.webtraxs.com/webtraxs.php?id=company&amp;st=img" /&gt;'; $('body').append(daScript); $('body').append(daOtherScript); }, 5000); </code></pre> <p>I have two problems with the above: </p> <ol> <li>In Firefox, after 5 seconds, it page goes completely blank.</li> <li>In IE, there's no errors thrown, but normally you can see the WebTraxs code trying to load a tracking image in the status bar. This is not occurring with the above code.</li> </ol> <p>Is there a better way to accomplish my objective here? I'm basically just trying to make sure the WebTraxs code is executed AFTER the document ready handler is executed.</p>
javascript jquery
[3, 5]
3,853,336
3,853,337
How to delete or remove an array value randomly in jQuery?
<p>How can I delete an value from an array in jQuery?</p> <pre><code>var prodCode = ["001","002","003","004","005","006","007","008"]; </code></pre>
javascript jquery
[3, 5]
4,746,795
4,746,796
Find word on page, wrap in span tags with class
<p>I would like to Find word on page, wrap in span tags with class. before proceeding to execute a javascript i have almost got ready.</p> <p>If i can work out how to just do this first part i think i can get the rest.</p> <p>Find word on page, wrap in span tags with a class applied to the span tags. Must then be searchable via:</p> <pre><code>     $(document).ready(function(){ var injectionKey = /%id=inject%/ig; var injectionStack = $('#%id%').html();       (function($) {   var theInjectionPage = $("span.myclass");   theInjectionPage.html(theInjectionPage.html().replace(injectionKey, injectionStack)); })(jQuery)     }); </code></pre>
javascript jquery
[3, 5]
781,851
781,852
How do I fake AJAX start / end events in JQuery?
<p>I'm listening to ajaxStart() and ajaxStop() to show/hide a spinner, and I'm doing some mock AJAX stuff in JS while servers are being written. It just calls a function to generate mock data with a setTimeout(). For now I'm just manually calling hide() and show() on the spinner, but I'd really like to just tell JQuery when I'm starting and stopping my "request", and have the events go through that way, so I don't accidentally hide() the spinner while a <em>real</em> ajax request is still going in the background.</p> <p>Can this be done easily?</p> <p><strong>EDIT:</strong> This is the code I settled on, the trick is maintaining the <code>JQuery.active</code> count:</p> <pre><code>function fakeAJAX(f) { if(jQuery.active++ === 0 ) { jQuery.event.trigger("ajaxStart"); } setTimeout(function () { f(); if(!(--jQuery.active)) { jQuery.event.trigger("ajaxStop"); } }, Math.round(Math.random() * 3000 + 250)); } </code></pre>
javascript jquery
[3, 5]
2,949,602
2,949,603
jsquery get all elements contained by a div with given name
<p>So I'll start off by saying I'm completely new to JS and JSQuery. So I'm in the following situation. The page has a structure like:</p> <pre><code>&lt;div id="id1"&gt; &lt;input name="input1" .... &gt; ..... &lt;/div&gt; &lt;div id="id2" disabled="disabled"&gt; &lt;input name="input1" ....&gt; &lt;/div&gt; ..... </code></pre> <p>So the names of the inputs will repeat themselves, only on different divs and only one div will not be disabled at a given moment. I need to be able to get a input element with a given name from a div with a given ID. My approach after reading a bit:</p> <pre><code>var inputs = $('div[id="' + parent_div +'"] input').filter(function() { return (this.hasOwnProperty('name') &amp;&amp; (typeof this.name != "undefined") &amp;&amp; this.name == component_name); });; for (input in inputs){ alert(inputs[input]); alert(inputs[input].name); } </code></pre> <p>Now I would expect this to return only my given component. However the result is very strange to me as a beginner. The alerts will be return something like the following:</p> <p>objectHTMLInputElement component_name ---- so the first one is the correct one, but after:</p> <p>1 undefined</p> <p>object Object undefined</p> <p>object HTMLDocument undefined</p> <p>div[id="data_modelHR"] input.filter(function () { return (this.hasOwnProperty('name') &amp;&amp; (typeof this.name != "undefined") &amp;&amp; this.name == component_name); }) undefined</p> <p>And this goes on for a while with different functions. Any suggestions?</p> <p>Regards, Bogdan</p>
javascript jquery
[3, 5]
4,554,607
4,554,608
static class instances unique to a request or a server in ASP.NET?
<pre><code> public sealed class UserLoginSingleton { UserLoginCollection _userLoginCol = new UserLoginCollection(); UserLoginSingleton() { } public static UserLoginSingleton Instance { get { IDictionary items = HttpContext.Current.Items; if (!items.Contains("TheInstance")) { items["TheInstance"] = new UserLoginSingleton(); } return items["TheInstance"] as UserLoginSingleton; } } public void CreateUserObj(string xmlData) { _userLoginCol = (UserLoginCollection)_xmlUtil.Deserialize(xmlData, typeof(UserLoginCollection)); } public UserLoginCollection getUserObj() { return _userLoginCol; } } </code></pre> <p>Usage:</p> <p>Page 1.aspx</p> <pre><code>UserLoginSingleton.Instance.CreateUserObj(xml); </code></pre> <p>Pase2.aspx:</p> <blockquote> <p>UserLoginCollection userLoginCollection = UserLoginSingleton.Instance.getUserObj();</p> </blockquote> <p>Followed the article here: <a href="http://stackoverflow.com/questions/194999/are-static-class-instances-unique-to-a-request-or-a-server-in-aspnet">link text</a></p> <p>I set my collection object in page 1 and then do a response.redirect or click on link to get me to page 2.aspx. However, my singleton instance has no collection object i set. How do i persist my collection object across diff pages per each session?</p> <p>I know static's wont work as every instance will see the object and i want that to specific per each user.</p>
c# asp.net
[0, 9]
1,249,869
1,249,870
Removing random items,
<p>I have a static page that contains 10 images on the top of the page and 10 paragraps about those images later on the page. I randomly want to show 4 images (which I found the solution for) but I'm unsure how to match those to the text div coming later because I should hide/show the paragraphs about the image</p> <p>the html:</p> <pre><code>&lt;div id="images"&gt; &lt;div&gt;&lt;img src="img1"&gt;&lt;/div&gt; &lt;div&gt;&lt;img src="img2"&gt;&lt;/div&gt; ... &lt;div&gt;&lt;img src="img10"&gt;&lt;/div&gt; &lt;/div&gt; </code></pre> <p>and later on the page</p> <pre><code>&lt;div id="text"&gt; &lt;p&gt;text about image 1&lt;/p&gt; &lt;p&gt;text about image 2&lt;/p&gt; ... &lt;p&gt;text about image 10&lt;/p&gt; &lt;/div&gt; randomElements = jQuery("#images div").get().sort(function(){ return Math.round(Math.random())-0.5 }).slice(0,4) </code></pre> <p>To show the same paragraphs as the random images I have chosen I guess I should use the <code>:nth-child()</code> selector. But I have not been able to find out how to get the child number from the <code>randomElements</code>.</p>
javascript jquery
[3, 5]
5,946,235
5,946,236
How can I refactor this jQuery code?
<p>The code below is for a simple newsletter signup widget.</p> <p>I'm sure there's a way to make it more concise, any ideas?</p> <pre><code>var email_form = $('.widget_subscribe form'); var email_submit = $('.widget_subscribe .submit'); var email_link = $('.widget_subscribe .email'); // Hide the email entry form when the page loads email_form.hide(); // Show the form when the email link is clicked $(email_link).click( function () { $(this).toggle(); $(email_form).toggle(); return false; }); // Hide the form when the form submit is clicked $(email_submit).click( function () { $(email_link).toggle(); $(email_form).toggle(); }); // Clear/reset the email input on focus $('input[name="email"]').focus( function () { $(this).val(""); }).blur( function () { if ($(this).val() == "") { $(this).val($(this)[0].defaultValue); } }); </code></pre>
javascript jquery
[3, 5]
4,972,236
4,972,237
Retrieve substring from given string
<p>This question is related to login. This answer may be simple but still 30 mins I am trying using jquery OR javascript.</p> <p>Given string Example :</p> <p><code>john123,ricky43567,jecobs2</code> and many more like this</p> <p>Retrieve only character from it.</p> <p>above string result will be like..</p> <pre><code>john,ricky,jecobs </code></pre> <p>Thanks in advance. </p>
javascript jquery
[3, 5]
1,765,252
1,765,253
get POST data in C#/ASP.NET
<p>-Edit- Jon Skeet and darin togther answered my question 100%</p> <p>I am trying to get POST data but i have no luck whatsoever. By code is below, when i click the form button NOTHING happens. I expected at least my IDE to snap at A.Ret() but nothing happens whatsoever.</p> <p>Test.cs</p> <pre><code>using System.Web; public class A { public static string ret() { var c = HttpContext.Current; var v = c.Request.QueryString; //&lt;-- i can see get data in this return c.Request.UserAgent.ToString(); return c.Request.UserHostAddress.ToString(); return "woot"; } } </code></pre> <p>Default.aspx</p> <pre><code>&lt;%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="aspnetCSone._Default" %&gt; &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml" &gt; &lt;head runat="server"&gt; &lt;title&gt;Untitled Page&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;form id="form1" runat="server" method="post" action="Default.aspx"&gt; &lt;input type=hidden name="AP" value="99" /&gt; &lt;input type=button value="Submit" /&gt; &lt;div&gt; &lt;a id="aa"&gt;a&lt;/a&gt; &lt;% = A.ret() %&gt; &lt;/div&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
c# asp.net
[0, 9]
3,459,231
3,459,232
Get DataTable values from code behind to client side using javascript
<p>I need help on getting a particular datatable values from the server to the client using javascript. </p> <p>Ex. In my class which is Countries.aspx.cs I have this somewhere on my code say on the page load.</p> <pre><code>DataTable dtbCountries = Repository.GetAllCountries; </code></pre> <p>my dtbCountries now contains this record</p> <pre><code>ID Country 1 HongKong 2 Japan 3 Korea </code></pre> <p>In my webform I want to get the values of my dtbCountries using javascript</p> <pre><code>&lt;script type="text/javascript"&gt; // my code here to get the dtbCountries values &lt;/script&gt; </code></pre> <p>What should I do? Or what's the best thing to do to expose my dtbCountries in the client.</p> <p>Thanks in advance!</p>
c# javascript asp.net
[0, 3, 9]
2,261,836
2,261,837
how to store dynamic button text
<p>I have below code and i would like to get the texts of dynamic created buttons on the server side which is clicked however on the second click of the button,the button is disabled and i dont wanna have its text property.</p> <p>this is the code how i create dynamic buttons with the loop</p> <pre><code>for (int i = 0; i &lt; numberofplants; i++) { builderchart.Append("&lt;th class=style8&gt;"); builderchart.Append("&lt;input type='button' id='btn" + i.ToString() + "' value='" + dtplants.Rows[i][0] + "' style='width:55px;' class='inputbutton'&gt;"); builderchart.Append("&lt;/th&gt;"); } .is-highlighted { background-color:#6FA478; $(function () { $('input[type=button]').on('click', function (e) { e.preventDefault(); $(this).toggleClass('is-highlighted'); }); }); </code></pre>
jquery asp.net
[5, 9]
5,661,088
5,661,089
reading a text file line by line using javascript
<p>I am trying to read in lines from a text file that are in this form; 34.925,150.977 35.012,151.034 34.887,150.905</p> <p>I am currently trying to use this methodology, which obviously isn't working. Any help would be appreciated.</p> <pre><code>var ltlng = []; var txtFile = new XMLHttpRequest(); txtFile.open("GET", "C:\Gmap\LatLong\Coordinates.txt", true); txtFile.onreadystatechange = function() { if (txtFile.readyState === 4) { if (txtFile.status === 200) { // Makes sure it's found the file. lines = txtFile.responseText.split("\n"); // separate each line into an array ltlng.push(new google.maps.LatLng(lines.split(",")[0],lines.split(",")[1]); //create the marker icons latlong array } } } </code></pre>
javascript asp.net
[3, 9]
3,677,735
3,677,736
Add list in Javascript
<p>I want to add another list while I click on anchor or button in Javascript, which should contain multiple textboxes, an option-list and a delete button on the second and onward lists. Look at:</p> <p><a href="http://jsfiddle.net/KMLkn/3/" rel="nofollow">http://jsfiddle.net/KMLkn/3/</a></p> <p>Can we use clone(jquery) for this?</p>
javascript jquery
[3, 5]
4,655,450
4,655,451
How to take user inputted number and assign to byte
<p>I've got a user input dialog box which I'm using to update a value.</p> <p><code>byte valScoreAway = 0;</code></p> <p>The value of valScoreAway is displayed on the screen with:</p> <p><code>tvScoreAway.setText( valScoreAway );</code></p> <p>This works perfectly.</p> <p>During the program the score will increment when the TextView tvScoreAway is clicked. This works perfectly.</p> <p>If there is an error, I have it so that a onLongClickListerner() will inflate a dialog box with an edit field. The user will enter the correct value into the EditView and then click OK. When the OK button is click, I am trying to assign the user inputted value to valScoreAway but it is failing because valScoreAway is a <code>byte</code> type and <code>userInput.getText()</code> is returning a string.</p> <p>Basically, I need to convert the value of <code>userInput.getText()</code> to a byte type.</p> <p>Can someone please help me with this?</p>
java android
[1, 4]
1,157,895
1,157,896
jquery dialog does not show CSS style on load in Internet Explorer
<p>I have a jQuery dialog which loads an external php page. All is working fine except in Internet Explorer (8) the css is switched on and then off again when the dialog is loaded. This means the dialog is transparent! When I drag the dialog the style is applied again, and it keeps applied.</p> <p>This the dialog load method.</p> <pre><code>&lt;script&gt; $(document).ready(function() { //select all the a tag with name equal to modal $('a[name=eventform]').click(function(e) { //Cancel the link behavior e.preventDefault(); $("#dialog").load(e.target.href).dialog({ title : 'Activity' }); }); }); &lt;/script&gt; </code></pre> <p>And this is the external page. All works fine in Firefox but the style is removed somehow when loading in Internet Explorer.</p> <pre><code>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;&lt;?php echo $pgtitle ?&gt;&lt;/title&gt; &lt;script type="text/javascript" src="js/jquery-1.7.1.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="js/jquery-ui-1.8.21.js"&gt;&lt;/script&gt; &lt;link rel="stylesheet" type="text/css" href="calendar/css/popwin.css" /&gt; &lt;/head&gt; &lt;body&gt; ...... </code></pre> <p>I tried to use the @import to get the stylesheet but this makes no difference.</p> <p>The same issue appears on Internet Explorer 9 but there it happens sometimes (????).</p> <p>Thanks, Coen</p>
javascript jquery
[3, 5]
5,179,775
5,179,776
Using jQuery within http.open
<p>I have a jquery function whichh looks like this:</p> <pre><code>&lt;script type="text/javascript"&gt; $(document).ready(function() { $('a#id').click(function(e){ e.preventDefault(); var id = $(this).attr('pid'); var title = $(this).attr('ptitle'); $('#product_list').prepend('&lt;input type="hidden" value="'+ id +'"/&gt;&lt;div&gt;'+ title +'&lt;/div&gt;') }); }); &lt;/script&gt; </code></pre> <p>I have a javascript file which has this code here:</p> <pre><code>&gt; http.open('get', 'livesearch.php?name='+searchq+'&amp;nocache = &gt; '+nocache+'&amp;type=bookings/products'); </code></pre> <p>The livesearch.php file has the a element (which the jQuery is requesting) like this:</p> <pre><code>&lt;a href="#" id="id" ptitle="&lt;?php echo $product['title']; ?&gt;" pid="&lt;?php echo $product['product_id']; ?&gt;"&gt;Add&lt;/a&gt; </code></pre> <p>However when I click on the a element the jQuery doesn't respond. Could any please help?</p> <p>Thanks Peter</p>
php javascript jquery
[2, 3, 5]