w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Assign text from file to variable in Ruby without returning text
Start your irb as below : irb --simple-prompt --noecho --simple-prompt is to get the IRB prompt as >> --noecho is to off the echo on IRB Here is an example: C:>irb --simple-prompt >> x = 2 => 2 >> exit C:>irb --simple-prompt --noecho >> x = 2 >>

Categories : Ruby

SelectedItem.Text returning selectedvalue instead
Try this: ASPX: <asp:DropDownList ID="MonthSelectionDrop" runat="server"></asp:DropDownList><br /> <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" /><br /> <asp:Label ID="MonthLabel" runat="server"></asp:Label> Code behind: protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { MonthSelectionDrop.Items.Add(new ListItem("--please select--", "0")); MonthSelectionDrop.Items.Add(new ListItem("January", "1")); MonthSelectionDrop.Items.Add(new ListItem("February", "2")); //and so on } } protected void Button1_Click(object sender, EventArgs e) { MonthLabel.Text = MonthSelectionDrop.SelectedItem.Text; }

Categories : C#

Textbox.text returning blank
Due to security precautions ReadOnly fields do not persist their values upon postback. If you need to prevent user input into this field and still post the value back - do not set textbox'es ReadOnly property. Instead give it a ReadOnly appearance via CSS and then prevent user input thru something like txtShipmentDate.Attributes("onclick") = "this.blur();" (You may want to handle 'onselect' and 'onpaste' as well). This way user input is prevented, giving user complete ReadOnly field appearance and still value is posted back.

Categories : Asp Net

getSelection returning text after cleared
DEMO jsFiddle JS var previousText = ''; function getSelectionHtml() { var html = ""; if (typeof window.getSelection != "undefined") { var sel = window.getSelection(); if (sel.rangeCount) { var container = document.createElement("div"); for (var i = 0, len = sel.rangeCount; i < len; ++i) { container.appendChild(sel.getRangeAt(i).cloneContents()); } html = container.innerHTML; } } else if (typeof document.selection != "undefined") { if (document.selection.type == "Text") { html = document.selection.createRange().htmlText; } } if(html!= previousText) { console.log(html); } previousText = html; } $(document).mousedown(function () {}).mous

Categories : Javascript

text file returning null and 0.0
You're incrementing index before you print items so you try to print items that were not yet added, which have default-constructed values of null and 0.0d your arrays are filled with when they're created. Just reordering the following lines like this shall help: System.out.println(studNum[index] + grade[index]); index ++;

Categories : Java

Apache always returning js as text/plain
Use the other JavaScript mime types: AddType application/x-javascript .js #AddType application/x-ecmascript .js #AddType application/ecmascript .js #AddType text/javascript .js #AddType text/ecmascript .js Try one at a time until you find a match. References RFC 4329: Scripting Media Types

Categories : Apache

javascript not returning the value of a text input
okay i found the problem, and i would like to thank This link and This Link for helping me get to the answer. Okay so this was the actual problem: The iframe is created dynamically and the inputs were in the iframe (which i at first didnt feel the need to say in the original question) but after some further research and review i found that this was the cause of the problem I assume its because the input was in the iframe which is a seperate document (and i still stand under correction). So the actual code to get the value was document.getElementById('content').contentDocument.getElementsByName('edtGroupName').item(0).value which could also be solved using the methods mentioned in the links. for all beginners with js this is what the code does: //this gets the i frame of the c

Categories : PHP

returning text in xml using ajax with a function
Since your are using ajax the execution will be asynchronous, means you can't return any value from the ajax callback. The correct way to solve this is to use a callback method or use the ajax promise. Ex function preSubmit(callback){ var optionTexts = []; $("section").each(function(){ var h2 = $(this).find("h2").text(); //optionTexts.push("<b>"); optionTexts.push(h2); optionTexts.push(" "); $("ol li", this).each(function() { optionTexts.push($(this).text()) }) }); var splitText = optionTexts.join(" "); getFromWho().done(function(xml){ splitText += $(xml).find('recipient').text(); callback(splitText) }); } function getFromWho() { return $.ajax({ type: "GET", url: "forWho.xml",

Categories : Jquery

Is there an efficient way of returning a sub-section of a text string
I believe you don't need to do anything as complicated - you can use the awesome package stringr's function str_extract str_extract(tmpstr,"[0-9]") This uses regex to extract only the numbers. Obviously, your real data might make this more complicated, but this should hopefully give you a good starting point. Edit A specific extraction between two full-stops, with the full-stops removed (with my poor regex skills I have to do it this long way) str_replace_all(str_extract(tmpstr,"[.][[:alnum:]]*[.]"),"\.","")

Categories : R

MySQL Full Text Search Returning 0 Results
With the current query you are looking for a full word match. So for instance to get the row you show inserted above, you would need to do: SELECT * FROM parentregionlist WHERE MATCH(regionnamelong) AGAINST ('Birmingham (and vicinity), England, United Kingdom' IN BOOLEAN MODE); However if you want to search for all results that start with 'Birm' you will need to add the '*' modifier: SELECT * FROM parentregionlist WHERE MATCH(regionnamelong) AGAINST ('Birm*' IN BOOLEAN MODE); Alternatively you could also use LIKE: SELECT * FROM parentregionlist WHERE regionnamelong LIKE 'Birm%'; The MySQL docs give good MATCH examples to work from: http://dev.mysql.com/doc/refman/5.5/en/fulltext-boolean.html

Categories : Mysql

Reading from a text file in java is returning some garbage value
while ((string[i] = in.readLine()) != null) { System.out.println(string[2]); } over there you are missing the i++; However I would advise you to use this structure: Use a ArrayList instead of an array, since this allows you to have a self-resizing structure, also instead in the while use the method ready(); from the BufferedRead in order to check the end from the document, at the end the for it's just to display the elements in String ArrayList. ArrayList<String> string = new ArrayList<String>(); try { File file = new File("drive.txt"); BufferedReader entrada; entrada = new BufferedReader(new FileReader(file)); entrada.readLine(); while (entrada.ready()) { string.add(entrada.readLine())

Categories : Java

Traversing the Ordered List backwards returning each li text
Here; I'll show a down and dirty method to get you rolling, then you can find a better way (maybe using textContent)... $('li').click(function(e){ var parents = $(this).add($(this).parents('li')) .map(function(){ return $(this).clone().children().remove().end() .text().replace(/ | |^s+|s+$/g,''); }) .toArray().join('/'); alert(parents); e.stopPropagation(); });

Categories : Javascript

Returning Translated Text from Google Translate Activity
I also am curious to know if this is possible. Meanwhile, if you need to translate simple text here a class that wrap the Google Translate Http Service. I've never used it in a production enviroment (read a released app) becouse I'm not sure if it's legal. So if a Google (employee) will answer to your question..maybe could let me know if this approach is legal. For convenience here the simple AsyncTask that wrap the Google Translate Http Service: import java.io.IOException; import java.util.Arrays; import java.util.Collections; import java.util.Locale; import java.util.Random; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import android.os.AsyncTask; import android.os.Bundle; import android.util.Log;

Categories : Android

alert(eventArgs.get_value()) returning selected text and not the ID
Its not returning the row ID because you haven't populated it in the AutoExtender, you've only given it a text value not an underlying value. Customers should be populated like this (assuming NPI is your row id?) customers.Add(AjaxControlToolkit.AutoCompleteExtender.CreateAutoCompleteItem( reader("NPI").ToString, reader("Provider Last Name (Legal Name)").ToString + ", " + reader("Provider First Name").ToString + " " + reader("Provider Business Mailing Address City Name").ToString + ", " + reader("Provider Business Mailing Address State Name").ToString + " " + reader("Provider Business Mailing Address Postal Code").ToString))

Categories : Javascript

Returning a text string from fortran subroutine to python using f2py
The problem here is with the len=* character declaration. you're telling the fortran compiler to accept any length string which was input. That's great except when you wrap it with f2py and have intent out, f2py needs to guess what length string to allocate and pass to your function and it has no way of doing that. (After all, what length string should it assume?). It looks to me like f2py assumes a 0 length string. When you assign a bigger string to a smaller string in fortran, the result gets truncated (although I would need to go back and read the standard to find out if that could result memory errors). In any event, it looks like that's what the gnu compiler is doing. If you change it to len=3, it works. Alternatively, doing something like this can make this work for f2py wi

Categories : Python

MongoDB query for full text search and Geo returning wrong result
According to the 2.4 documentation, text indexes do not work with $near: Note You cannot combine the text command, which requires a special text index, with a query operator that requires a different type of special index. For example you cannot combine text with the $near operator.

Categories : Mongodb

Scroll position in Text View object on detail view doesn't reset when returning
Since you are reusing a HardlyWorkingDogsDetailViewController, this behavior makes sense. If HardlyWorkingDogsDetailViewController is light weight enough, there really isn't any need to reuse it. Simply reinstantiating it everytime should fix your problem: self.detailViewController = [[HardlyWorkingDogsDetailViewController alloc] initWithNibName:@"HardlyWorkingDogsDetailViewController" bundle:nil ]; Dog *dog = self.sortedDogDictionaryArray[indexPath.row]; self.detailViewController.dogName= dog.dogName; self.detailViewController.dogLicense = dog.licenseString; self.detailViewController.dogScrollingInfo = dog.whatMakesDogSpecial; self.detailViewController.dogPhoto = dog.dogPhoto; [self.navigationController pushViewController:self.detailViewController animated:YES]; Although, having not

Categories : Iphone

Python - Chaining methods: returning `self` vs returning a new cloned object
Django does this so that the base query can be kept around and reused, without inheriting changes from a future "child" query, like your exclude() on your filter(). I'm guessing somebody tried storing queries for later, and realized that didn't work well without copying. I cloned the django repo and did a quick git log on django/db/models/query.py, searching for the phrase clone. The patch that introduces this change is here: https://github.com/django/django/commit/d4a3a4b

Categories : Python

Oracle Query is returning value when setting value to it, but not returning value when passing date value
Since you're already forcing the date format, you can use the following query instead: SELECT INCIDENT_ID FROM INC_SM1 I WHERE I.CLOSE_TIME >= START_DATE AND I.CLOSE_TIME < END_DATE

Categories : Oracle

JavaScript, stringify, replacer - returning undefined vs. returning nothing
If you don't provide an explicit return, the return value is undefined. Your second function always returns undefined, in other words. Because the function always returns undefined, there'll never be anything included in the JSON stringified result, so the overall effect is that you get undefined. It's sort-of an anti-pattern to do this: if (something) { return whatever; } else { return somethingElse; } Your first function would be more idiomatic as: str = JSON.stringify(o,function(k,v) { return Object.isSealed(this) ? undefined : v; }); edit — note that JSON.stringify() calls your replacer function first with an empty key, and "v" equal to this a new wrapper object containing the object to be stringified (and note that that object is not sealed). That is, before chec

Categories : Javascript

Returning 'nil' from a Lua function in C vs returning 0 values
Yes, this is perfectly valid. If you're trying to request/assign more return values than there are (no matter whether you try to get one or ten), you'll get nil for the undefined ones (i.e. those not returned). function test1() return 5 end local a, b = test1() -- a = 5, b = nil function test2() return 1, 2 end local c, d, e = test2() -- c = 1, d = 2, e = nil function test3() end local f, g = test3() -- f = nil, g = nil You probably can't find it in Lua's source because it's no special case or anything. It's just Lua's generic way to handle return values. Update: The difference you've noticed when trying to print return values is the fact that this is not just an assignment. Of course there is a slight difference between returning nil and returning nothing at all - and it

Categories : C

As we all know constructor is not having a returning type but in the code below constructor is returning...can any one explain
This: complex_1 complex_1::operator+(complex_1 c) is a definition of a class complex_1 member function (complex_1:: means this) that returns an object of type complex_1. c is not a constructor but an object of type complex_1 that is returned in this function.

Categories : C++

Returning a Unicode string vs. Returning a normal string encoded as UTF-8?
UTF-8 is an encoding of the entire Unicode character set. It is backwards compatible with ASCII. For characters outside the ASCII set, multibyte encodings are used. All ASCII strings are Unicode strings. All Unicode strings are not ASCII strings.

Categories : Python

Adding "new line"s to text in text supporting objects (i.e Buttons, Rich Text boxs) both in and out of code
" " is the escaped character for a line break. So code like: label.Text = "This is a button"; Should put the word button on a new line. Edit: If you want to do it using the properties window in designer, click on the arrow on the far right of the text property field and it will open a small box. If you type multiple lines on that as you would normally (ie actually pressing enter, not using ) then the component will treat them as new lines and put the new lines in for you.

Categories : C#

Give a block of text, some keyshorts, and the target text, how to get the minimal key press to convert the text?
It's probably NP-hard. This paper gives a hardness proof for an editor where insertions, deletions, and substring moves all have constant cost. %0 Book Section %D 2002 %@ 978-3-540-43862-5 %B Combinatorial Pattern Matching %V 2373 %S Lecture Notes in Computer Science %E Apostolico, Alberto %E Takeda, Masayuki %R 10.1007/3-540-45452-7_9 %T Edit Distance with Move Operations %U http://dx.doi.org/10.1007/3-540-45452-7_9 %I Springer Berlin Heidelberg %8 2002-01-01 %A Shapira, Dana %A Storer, JamesA. %P 85-98 %G English

Categories : Algorithm

Ignoring leading whitespace in the "lazy-text" quasiquoter in Haskell Text.Shakespeare.Text
It doesn't appear to, however it isn't hard to add the feature yourself. lt is just a QuasiQuoter, which is the data type: QuasiQuoter { quoteExp :: String -> Q Exp , quotePat :: String -> Q Pat , quoteType :: String -> Q Type , quoteDec :: String -> Q [Dec] } They take a String, and return the appropriate template haskell type (depending on the context it is used in. It is a simple matter to transform a string so it works as you described with a regex: stripWhiteSpaceBeforeBackslash :: String -> String stripWhiteSpaceBeforeBackslash str = subRegex (mkRegex "^[[:space:]]*\\") str "" Also, a function that transforms a QuasiQuoter with a string transform function is simple: transformQuasiQuoter :: (String -> String) -> QuasiQuoter -> QuasiQuoter transfo

Categories : Haskell

Change encoding of text file (shell archive or script for antique kernel text to ASCII text, with CRLF, LF line terminators)
Unix uses a single character for line termination. If you want to convert your file with CRLF to single character termination, you can do the following: sed -e 's/<CTRL-V><CTRL_M>//' filename where <CTRL-V> is the Control key pressed with V (do not include < and > characters in the command.

Categories : Bash

Checkbox - check add text, uncheck remove original text in text area
So you want different activity depending on whether your text box is being checked or unchecked. At the moment, you call one method whenever you click on the checkbox, so now you need to look at the state of the checkbox, when it is clicked on. Give your checkbox an ID, and swap out your Javascript for this. <script language="javascript" type="text/javascript"> function moveNumbers(num) { if(document.getElementById("checkBoxId").checked){ var txt=document.getElementById("result").value; txt=txt + num; document.getElementById("result").value=txt; } else{ document.getElementById("result").value=txt=""; } } </script>

Categories : PHP

Dnn text editor doesn't change form a basic text box to Rich text box
What version of DNN are you using? If you're using DNN7 you will want to make sure you are using the RadEditor controller, not FCK which it appears to be. DNN7 doesn't work with the FCK Editor.

Categories : Asp Net

To copy the selected Text from a div to a text field on double click the Text
Here is how to get the selected text with double click, Update : now it also copies to last focused input. First you need to set focus one of the inputs before double click the text. DEMO http://jsfiddle.net/yeyene/GYuBv/15/ $(document).ready(function () { $("input[type=text]").focus(function(){ $("input[type=text]").removeClass('lastFocus'); $(this).addClass('lastFocus'); }); $('#myDiv').dblclick(function() { $('#selected').append(getSelectionText()); $("input[type=text].lastFocus").val($("input[type=text].lastFocus").val()+getSelectionText()); }); }); function getSelectionText() { var text = ""; if (window.getSelection) { text = window.getSelection().toString(); } else if (document.selection && d

Categories : PHP

Android - hidden text --> show text for 2 seconds --> hide text again
Try the following: Show "I'm thinking" Calculate your move but don't actually do the move, just store it for a while Schedule timer When timer runs out remove the text and do the move Something like this: onAndroidTurn(){ textView1.setVisibility(View.VISIBLE); saveMove(calculateNextMove()); new Handler().postDelayed(new Runnable(){ void run() { textView1.setVisibility(View.GONE); doNextMove(restoreMove()); } }, 2000); }

Categories : Java

Multiple Check box input to text area - add text - remove text from text area
If you want to arbitrarily add text that is not known in advance and then later remove it, you'll need to either keep a list of items that have been added and regenerate the result each time, or do a search/replace operation to remove it. I think keeping the list is easier: var itemsAdded = Array(); function moveNumbers(text) { var i = itemsAdded.indexOf(text) if ( i >= 0) { itemsAdded.splice(i,1); } else { itemsAdded.push(text); } document.getElementById("result").value=itemsAdded.join(" "); //if you want each on a separate line, use " " instead of " " }

Categories : PHP

Inserting text from text file into MySQL TEXT column
This is a possible duplicate of this question: http://serverfault.com/questions/316691/mysql-binlog-format-dilemma Anyway, the key is Statement is unsafe because it uses a system function that may return a different value on the slave. When the MySQL database is setup to use replication, system functions like load_file can cause issues. The file C: emp exttoinset.txt is likely different between the master server and the slave server (or may not even exist on one of them). When using replication, it is best to avoid system functions (like load_file and NOW()) because the values will be different when executed on different servers. If you want to load a file into a MySQL database that uses replication, consider using PHP's file_get_contents to read the file, and then use that to insert

Categories : PHP

how can i have a text field which have text in it and when the user clicks on the text field the text inside the field vanishes
You should use attrs parameter for form field widget like this: from django.forms import TextInput class CategoriesForm(ModelForm): class Meta: model = Categories widgets = { 'category_name': TextInput(attrs={'placeholder': 'PLACEHOLDER TEXT HERE'}) } Here is documentation

Categories : Python

ASP.NET ListBox converts ListItem from text, value to text, text
You need to set the data text and value fields, e.g: lbl_users.DataSource = users; lbl_users.DataValueField = "userID"; lbl_users.DataTextField = "name"; lbl_users.DataBind();

Categories : C#

Read from text file, capture text, write to another text file in specific syntax
I'd personally do something like that with Perl, because I'm familiar with Perl and it works great for these kinds of tasks. You can also write a sed one-liner to get that done. If you're not a fan of Perl, any modern dynamic language should let you get the job done with minimal effort. EDIT: An example Perl script (full file for readability) would look like this: use warnings; use strict; while (my $line = <>) { $line =~ /^s*(.+?), '(.+?)', '(.+?)';$/; # Doesn't handle internal escaping print "DELETE ATTRIBUTE "$1" IN FOLDER "$2" FROM PROJECT "$3"; "; } See the result.

Categories : Misc

How to create spaced text fields with a description of the text field at the top of each text field
hope the following code will help you, You have to place TextView in between EditText to give reference, <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:context=".AddContact" > <TextView android:id="@+id/lbl_name" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="User Name" /> <EditText android:id="@+id/edit_name" android:layout_width="wrap_content" android:layout_height="wrap_content" android:hint="Enter name" > </EditText> <TextView a

Categories : Android

Perl Program to Read a Text File, Search for text within the File and copy the text to a new file
Why not awk? awk '/ Directory of /{at=$3;print;next}{print $0""FS""at}' your_file Perl: perl -lne 'if(/ Directory of (.*)/){$a=$1;print}else{$_.=" ".$a;print}' your_file if you want to do an inline replacement: perl -i -lne 'if(/ Directory of (.*)/){$a=$1;print}else{$_.=" ".$a;print}' your_file

Categories : Regex

CSS: ellipsis in left-aligned text of single line of dynamic width text where width of left-aligned text = 100% - right-aligned text
1) Remove float:left from your left div and 2) Add display:block on your left div and bingo! - the right div takes up only as much space as it needs - without giving it a fixed width anymore. UPDATED FIDDLE + FIDDLE 2 (just to prove it works) Markup <div id="wrap"> <div id="right">Right</div> <div id="left">Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left</div> </div> CSS #wrap { width: 100%; } #left, #right {padding:5px;} #left { background-color:red; text-align:left; display: block; text-overflow: ellipsis; white-space: nowrap; overflow: hidden; } #right { background-color:orange;

Categories : CSS

text file doesn't match when i try to create text box according to the text file
It's creating 10 more because you have 10 lines that ends with a comma. Say you have a string like: var s = "A,B,C," Splitting this would result in 4 string, the last one being empty. Now reproduce this for 10 lines and you will get the same behaviour as you are having. If that's unwanted behaviour, you need to change your logic to take into account a line that is ending with a comma.

Categories : C#



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.