Get

url

parameter

jquery

Or

How

to

Get

Query

String

Values

In

js

Ask

Question

I

have

seen

lots

of

jQuery

examples

where

parameter

size

and

name

are

unknown

My

url

is

only

going

to

ever

have

string

http

examplecomsentyes

I

just

want

to

detect

Does

sent

exist

Is

it

equal

to

yes

jquery

url

parameters

querystring

querystringparameter

improve

this

question

Sameer

Kazi

asked

Oct

at

LeBlaireau

Maybe

you

should

post

what

you

have

tried

Florent

Oct

at

possible

duplicate

of

How

can

I

get

query

string

values

James

Donnelly

Oct

at

subZero

Oct

at

Hey

buddy

seeing

as

this

is

a

downvote

paradise

for

me

as

Sameers

answer

obviously

answers

it

better

community

wise

could

you

change

your

accepted

answer

to

his

so

I

am

able

to

delete

mine

and

ease

the

answer

finding

of

Googlers

Thanks

Jul

at

There

is

now

a

pluginlibrary

for

this

called

URIjs

githubcommedializeURIjs

alexw

Feb

at

show

more

comments

Answers

oldest

Best

solution

here

var

getUrlParameter

function

getUrlParameter

sParam

var

sPageURL

window

location

search

substring

sURLVariables

sPageURL

split

sParameterName

i

for

i

i

sURLVariables

length

i

sParameterName

sURLVariables

i

split

if

sParameterName

sParam

return

sParameterName

undefined

true

decodeURIComponent

sParameterName

And

this

is

how

you

can

use

this

function

assuming

the

URL

is

httpdummycomtechnologyjqueryblogjquerybyexample

var

tech

getUrlParameter

technology

var

blog

getUrlParameter

blog

edited

Nov

at

Sebastian

S

answered

Feb

at

Sameer

Kazi

Nice

job

The

only

thing

I

changed

was

I

did

a

break

when

I

find

the

parameter

and

then

do

the

return

radtek

May

at

Thanks

But

when

copying

this

I

found

a

nasty

surprise

involving

a

zerowidth

whitespace

towards

the

end

there

Making

the

script

have

an

invisible

syntax

error

Christofer

Ohlsson

Aug

at

Return

a

false

or

for

empty

search

Stefano

Caravana

Feb

at

Ive

updated

the

answer

to

include

all

the

comments

code

changes

above

this

comment

Rob

Evans

Jul

at

The

decoding

should

be

done

on

the

parameter

value

as

Iouri

suggests

If

the

decoding

is

done

on

the

url

as

in

the

answer

it

wont

work

correctly

if

theres

an

encoded

or

in

a

parameter

value

zakinster

Dec

at

show

more

comments

jQuery

code

snippet

to

get

the

dynamic

variables

stored

in

the

url

as

parameters

and

store

them

as

JavaScript

variables

ready

for

use

with

your

scripts

urlParam

function

name

var

results

new

RegExp

name

exec

window

location

href

if

results

return

return

decodeURI

results

urlParam

name

urlParam

id

urlParam

example

params

with

spaces

http

Coast

console

log

urlParam

city

output

console

log

decodeURIComponent

urlParam

city

output

Gold

Coast

edited

Oct

at

answered

Aug

at

Reza

Baradaran

Gazorisangi

will

it

work

with

all

mobile

devices

Thanks

Andrew

Dec

at

Note

You

need

to

decode

in

case

there

are

special

characters

as

parameter

or

Umlaute

etc

So

instead

of

return

it

should

be

return

Kai

Noack

Dec

at

Just

curious

why

does

it

need

the

part

since

there

is

already

a

check

for

the

result

wouldnt

it

always

return

the

match

array

May

at

an

appropriate

failsafe

though

redundant

never

hurts

to

be

cautious

zanderwar

Oct

at

Here

is

most

likely

the

original

source

sitepointcomurlparametersjquery

but

this

answer

has

some

new

ideas

added

bgmCoder

Jun

at

show

more

comments

Solution

from

We

have

httpexamplecomsentyes

let

searchParams

new

URLSearchParams

window

location

search

Does

sent

exist

searchParams

has

sent

true

Is

it

equal

to

yes

let

param

searchParams

get

sent

and

then

just

compare

it

edited

Jan

at

answered

Feb

at

Optio

i

think

this

is

not

supported

across

browsers

so

why

should

one

use

it

reference

developermozillaorgenUSdocsWebAPIURLSearchParams

Mar

at

you

are

right

But

you

can

use

polyfill

for

URLSearchParams

Optio

Mar

at

currently

not

working

in

IE

Edge

so

do

feature

detection

if

URLSearchParams

in

window

Browser

supports

URLSearchParams

See

here

michaK

Jan

at

Good

enough

for

me

and

my

intended

audience

caniusecomfeaturlsearchparams

jontsai

Feb

at

Its

nicer

use

const

instead

let

Just

saying

Cesar

Jr

Rodriguez

Sep

at

show

more

comments

I

always

stick

this

as

one

line

Now

params

has

the

vars

params

location

search

replace

gi

function

s

k

v

params

k

v

multilined

var

params

window

location

replace

gi

function

str

key

value

params

key

value

as

a

function

function

getSearchParams

k

var

p

location

search

replace

gi

function

s

k

v

p

k

v

return

k

p

k

p

which

you

could

use

as

getSearchParams

returns

or

getSearchParams

returns

edited

Feb

at

answered

Nov

at

AwokeKnowing

Ugly

hack

that

modifies

the

search

string

but

no

external

modules

or

jquery

required

I

like

it

Bryce

Jun

at

Bryce

It

actually

doesnt

modify

the

search

string

the

replace

actually

returns

a

new

string

and

those

returned

strings

are

processed

into

the

params

object

AwokeKnowing

Jun

at

Nice

short

and

contrary

to

accepted

solution

doesnt

need

to

reparse

url

each

time

you

need

a

value

Could

be

slightly

improved

with

replacegi

to

reconize

character

as

a

separator

too

Le

Droid

Feb

at

clear

and

painless

oneliner

better

than

accepted

answer

for

me

no

extra

libs

Sam

May

at

This

is

what

one

would

use

if

one

uses

hashes

instead

of

GETquery

delimiter

questionmark

var

paramswindowlocationhashreplacegifunctionstrkeyvalueparamskey

value

This

is

useful

for

things

such

as

AJAX

where

the

hash

in

window

is

updated

with

ajaxrequests

but

one

also

one

the

user

to

go

to

a

uri

containing

a

hash

Tommie

May

at

show

more

comments

May

be

its

too

late

But

this

method

is

very

easy

and

simple

script

type

textjavascript

src

jqueryjs

script

script

type

textjavascript

src

jqueryurljs

script

URL

script

type

textjavascript

function

urlattrprotocol

Protocol

http

urlattrpath

host

wwwexamplecom

urlattrquery

path

correct

urlattrmessage

query

done

urlattryear

query

UPDATE

Requires

the

url

plugin

pluginsjquerycomurl

Thanks

Ripounet

edited

Apr

at

answered

Mar

at

Sariban

DCl

Whoever

decides

on

this

should

check

the

repo

first

Usage

has

changed

urlattrmessage

becomes

urlquery

and

it

only

gives

the

full

query

To

get

only

one

parameter

I

had

to

url

github

link

pseudozach

Jul

at

add

a

comment

Yet

another

alternative

function

function

param

name

return

location

search

split

name

split

answered

Sep

at

rodnaph

Nice

and

short

nkkollaw

Oct

at

name

needs

to

be

a

string

Worked

like

a

charm

mintedsky

Mar

at

Awesome

nice

and

clean

Thank

you

so

much

BilalReffas

Jun

at

This

is

my

favorite

Of

note

though

this

is

an

ends

with

type

of

search

For

example

if

you

pass

in

Phone

for

the

name

and

theres

also

a

field

called

HomePhone

it

may

return

the

value

of

the

wrong

one

if

it

comes

first

in

the

url

efreed

Sep

at

This

is

wrong

For

example

paramt

paramsent

yes

in

the

OP

example

Heres

a

fix

return

locationsearchsplitnew

RegExp

name

Also

note

that

you

can

not

tell

if

the

param

exists

because

you

get

empty

string

for

missing

parameters

oriadam

Jan

at

show

more

comment

Or

you

can

use

this

neat

little

function

because

why

overcomplicated

solutions

function

getQueryParam

param

location

search

substr

split

some

function

item

returns

first

occurence

and

stops

return

item

split

param

param

item

split

return

param

which

looks

even

better

when

simplified

and

onelined

tldr

oneline

solution

var

queryDict

location

search

substr

split

forEach

function

item

queryDict

item

split

item

split

result

queryDictsent

undefined

or

value

But

what

if

you

have

got

encoded

characters

or

multivalued

keys

You

better

see

this

answer

How

can

I

get

query

string

values

in

JavaScript

Sneak

peak

a1b2c3dea5at20e20x20tehttp3A2F2Fw3schoolscom2Fmy20testasp3Fname3Dståle26car3Dsaab

queryDict

a

t

e

x

t

b

c

d

undefined

e

undefined

testaspnamestålecarsaab

queryDict

a

queryDict

a

edited

May

at

Community

answered

Jul

at

Qwerty

string

split

is

likely

to

be

faster

than

regex

too

Not

that

that

is

a

factor

considering

the

url

would

only

be

parsed

once

Patrick

Apr

at

add

a

comment

This

one

is

simple

and

worked

for

me

urlParam

function

name

var

results

new

RegExp

name

exec

window

location

href

return

results

so

if

your

url

is

try

this

console

log

urlParam

city

answered

Oct

at

Shuhad

zaman

add

a

comment

Perhaps

you

might

want

to

give

Dentist

JS

a

look

disclaimer

I

wrote

the

code

code

document

URL

var

currentURL

document

URL

var

params

currentURL

extract

console

log

params

id

console

log

params

author

kelvin

console

log

params

message

hello

with

Dentist

JS

you

can

basically

call

the

extract

function

on

all

strings

eg

documentURLextract

and

you

get

back

a

HashMap

of

all

parameters

found

Its

also

customizable

to

deal

with

delimiters

and

all

Minified

version

edited

Apr

at

fabsenet

answered

Nov

at

kelvintaywl

add

a

comment

Using

URLSearchParams

var

params

new

window

URLSearchParams

window

location

search

console

log

params

get

name

answered

Aug

at

Xin

add

a

comment

function

GetRequestParam

param

var

res

try

var

qs

decodeURIComponent

window

location

search

substring

get

everything

after

then

in

URI

var

ar

qs

split

each

ar

function

a

b

var

kv

b

split

if

param

kv

res

kv

return

false

break

loop

catch

e

return

res

Run

code

snippet

answered

Mar

at

add

a

comment

I

hope

this

will

help

script

type

textjavascript

function

getParameters

var

searchString

window

location

search

substring

params

searchString

split

hash

if

searchString

return

for

var

i

i

params

length

i

var

val

params

i

split

hash

unescape

val

unescape

val

return

hash

window

load

function

var

param

getParameters

if

typeof

param

sent

undefined

Do

something

script

edited

Nov

at

kiamlaluno

answered

Jan

at

Tarun

Gupta

add

a

comment

Theres

this

great

library

httpsgithubcomallmarkeduppurl

which

allows

you

to

do

simply

url

httpexamplecomsentyes

sent

url

url

param

sent

if

typeof

sent

undefined

sent

exists

if

sent

yes

sent

is

equal

to

yes

The

example

is

assuming

youre

using

jQuery

You

could

also

use

it

just

as

plain

javascript

the

syntax

would

then

be

a

little

different

answered

Mar

at

Michael

Konečný

This

library

is

not

maintained

any

more

however

I

use

it

and

its

great

Make

sure

you

use

param

not

attr

to

get

those

query

string

parameters

as

the

author

has

included

in

their

example

Action

Dan

Jun

at

add

a

comment

This

might

be

overkill

but

there

is

a

pretty

popular

library

now

available

for

parsing

URIs

called

URIjs

Example

var

uri

httpexampleorgfoohtmltechnologyjquerytechnologycssblogstackoverflow

var

components

URI

parse

uri

var

query

URI

parseQuery

components

query

document

getElementById

result

innerHTML

URI

uri

document

getElementById

result

innerHTML

brtechnology

query

technology

If

you

look

in

your

console

you

will

see

that

this

library

generates

a

JS

array

for

multivalued

queries

console

log

query

technology

console

log

query

blog

script

src

script

span

id

result

span

Run

code

snippet

answered

Feb

at

alexw

add

a

comment

So

simple

you

can

use

any

url

and

get

value

function

getParameterByName

name

url

if

url

url

window

location

href

name

name

replace

g

var

regex

new

RegExp

name

results

regex

exec

url

if

results

return

if

results

return

return

decodeURIComponent

results

replace

g

Usage

Example

query

string

var

foo

getParameterByName

first

var

bar

getParameterByName

second

Note

If

a

parameter

is

present

several

times

you

will

get

the

first

value

and

second

value

as

answered

Sep

at

ImBS

add

a

comment

Try

this

working

demo

API

inArray

httpapijquerycomjQueryinArray

This

should

help

code

var

url

httpmyurlcomsentyes

var

pieces

url

split

alert

pieces

inArray

sentyes

pieces

answered

Oct

at

only

works

for

a

single

var

the

would

throw

it

off

could

be

extended

with

regex

Alvin

Aug

at

add

a

comment

This

will

give

you

a

nice

object

to

work

with

function

queryParameters

var

result

var

params

window

location

search

split

params

forEach

function

it

if

it

var

param

it

split

result

param

param

return

result

And

then

if

queryParameters

sent

yes

edited

Aug

at

answered

Aug

at

Brian

F

split

this

means

Selva

Ganapathi

Nov

at

add

a

comment

This

is

based

on

Gazoris

s

answer

but

URL

decodes

the

parameters

so

they

can

be

used

when

they

contain

data

other

than

numbers

and

letters

function

urlParam

name

var

results

new

RegExp

name

exec

window

location

href

Need

to

decode

the

URL

parameters

including

putting

in

a

fix

for

the

plus

sign

return

results

decodeURIComponent

results

replace

g

edited

May

at

Community

answered

Jun

at

Stephen

Ostermiller

add

a

comment

There

is

another

example

with

using

URIjs

library

Example

answers

the

questions

exactly

as

asked

var

url

httpexamplecomsentyes

var

urlParams

new

URI

url

search

true

Does

sent

exist

var

sendExists

urlParams

sent

undefined

Is

it

equal

to

yes

var

sendIsEqualtToYes

urlParams

sent

yes

output

results

in

readable

form

not

required

for

production

if

sendExists

console

log

Url

has

sent

param

its

value

is

urlParams

sent

if

urlParams

sent

yes

console

log

Sent

param

is

equal

to

yes

else

console

log

Sent

param

is

not

equal

to

yes

else

console

log

Url

hasnt

sent

param

script

src

script

Run

code

snippet

answered

Oct

at

userlond

add

a

comment

Coffeescript

version

of

Sameers

answer

getUrlParameter

sParam

sPageURL

window

location

search

substring

sURLVariables

sPageURL

split

i

while

i

sURLVariables

length

sParameterName

sURLVariables

i

split

if

sParameterName

sParam

return

sParameterName

i

answered

Mar

at

mrmusicman

add

a

comment

A

slight

improvement

to

Sameers

answer

cache

params

into

closure

to

avoid

parsing

and

looping

through

all

parameters

each

time

calling

var

getURLParam

function

var

paramStr

decodeURIComponent

window

location

search

substring

var

paramSegs

paramStr

split

var

params

for

var

i

i

paramSegs

length

i

var

paramSeg

paramSegs

i

split

params

paramSeg

O B I I O O O O B I I O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O

url parameter jquery
query string values
jquery examples


Email

Validation

Ask

Question

It

is

said

With

we

need

no

more

js

or

a

server

side

code

to

check

if

the

users

input

is

a

valid

email

or

url

address

How

can

I

validate

email

after

a

user

enter

and

without

JS

how

to

display

a

message

if

the

user

enter

a

wrong

form

of

hisher

email

address

input

typeemail

pattern

placeholderEnter

your

email

input

typesubmit

valueSubmit

improve

this

question

asked

Oct

at

abcid

d

You

always

need

to

validate

on

the

server

side

A

clever

client

can

bypass

any

clientside

security

measure

Benjamin

Gruenbaum

Oct

at

This

answer

might

help

when

trying

to

set

up

form

validation

Of

course

you

would

probably

still

need

serverside

validation

though

Nov

at

regex

Email

validation

should

never

be

used

under

any

circumstances

Regex

checks

have

too

many

flaws

The

best

way

to

validate

an

email

addresses

is

to

simply

have

them

type

it

twice

and

run

a

Regex

check

that

gives

a

WARNING

to

the

user

that

it

doesnt

look

like

a

valid

email

address

if

it

does

not

match

the

pattern

and

asks

the

user

to

double

check

This

way

if

it

actually

is

valid

but

regex

is

failing

like

it

so

often

does

the

user

can

just

acknowledge

that

they

know

it

is

valid

and

continue

Far

too

many

sites

Mar

at

Answers

oldest

In

you

can

do

like

this

form

input

typeemail

placeholderEnter

your

email

input

typesubmit

valueSubmit

form

And

when

the

user

press

submit

it

automatically

shows

an

error

message

like

answered

Oct

at

Midhun

MP

What

is

the

benefit

of

the

pattern

here

Specifying

the

type

as

email

already

includes

a

built

in

pattern

to

determine

this

Rich

Bradshaw

Oct

at

RichBradshaw

Yes

you

are

correct

No

need

to

specify

the

pattern

I

just

copied

code

from

OP

I

corrected

now

Midhun

MP

Oct

at

MichaelDeMutis

You

can

use

the

required

attribute

Midhun

MP

Mar

at

the

email

doesnt

check

for

com

in

an

email

It

only

checks

sign

Ex

I

can

enter

examplegmail

and

save

the

form

though

it

is

not

a

valid

email

address

Is

there

workaround

to

check

properly

examplegmailcom

Liz

Jan

at

Liz

examplegmail

might

not

be

a

valid

email

but

it

is

a

valid

email

address

format

pajaja

Jul

at

show

more

comments

The

input

typeemail

page

of

the

site

notes

that

an

email

address

is

any

string

which

matches

the

following

regular

expression

Use

the

required

attribute

and

a

pattern

attribute

to

require

the

value

to

match

the

regex

pattern

input

typetext

required

edited

days

ago

Nick

Larsen

answered

Oct

at

Stefan

Ciprian

Hotoleanu

You

must

insert

the

pattern

without

the

two

and

the

start

and

end

symbol

Like

these

Victor

Nov

at

Victor

Sorry

but

youre

partially

wrong

This

symbols

are

important

without

them

the

pattern

will

start

to

match

everywhere

in

the

string

and

make

it

useless

Where

youre

correct

is

letting

the

slashes

out

Hexodus

Feb

at

Victor

your

answer

worked

for

me

OPs

regex

gave

me

a

false

positive

saying

to

match

the

forms

requirements

even

when

its

a

valid

email

address

Perhaps

its

that

Im

not

using

regular

HTML

but

using

React

JS

to

render

the

HTML

form

Ka

Mok

Oct

at

I

almost

down

voted

this

because

the

correct

answer

is

to

use

typeemail

and

check

the

valid

boolean

property

on

the

DOMNode

no

need

to

repeat

the

underlying

regex

Dominic

Jan

at

Thank

you

for

mentioning

this

Stefan

Ciprian

Hotoleanu

Jan

at

show

more

comments

Using

for

somemailemailcom

somemailemailcomvn

edited

Mar

at

Nakilon

answered

Nov

at

Van

Nguyen

This

regex

places

a

number

of

inappropriate

requirements

on

email

addresses

for

instance

it

rejects

email

addresses

that

have

a

one

or

twoletter

username

or

which

are

hosted

at

a

oneletter

domain

name

duskwuff

Nov

at

Edited

Thank

you

duskwuff

Van

Nguyen

Nov

at

Still

rejects

oneletter

domain

names

duskwuff

Nov

at

This

allows

letternumber

domains

Ruddernation

Designs

May

at

Also

note

that

for

example

postmasterai

is

a

valid

email

address

and

this

regexp

would

ban

that

too

Source

Mikko

Rantalainen

May

at

Here

is

the

example

I

use

for

all

of

my

form

email

inputs

This

example

is

ASPNET

but

applies

to

any

aspTextBox

runatserver

classformcontrol

placeholderContacts

email

titleContacts

email

format

xxxxxxxxx

typeemail

TextModeEmail

validaterequiredtrue

aspTextBox

still

validates

using

the

pattern

when

not

required

Havent

found

one

yet

that

was

a

false

positive

This

renders

as

the

following

HTML

input

classformcontrol

placeholderContacts

email

typeemail

titleContacts

email

format

xxxxxxxxx

answered

May

at

Keith

H

add

a

comment

documentgetElementByIdemailvalidityvalid

seems

to

be

true

when

field

is

either

empty

or

valid

This

also

has

some

other

interesting

flags

Tested

in

Chrome

edited

Mar

at

answered

Mar

at

Nakilon

using

the

Valid

property

is

not

enough

try

something

like

fsfsddffsdfsdfd

and

you

will

get

validtrue

Emad

Dehnavi

May

at

EmadDehnavi

Nakilon

May

at

add

a

comment

I

know

you

are

not

after

the

Javascript

solution

however

there

are

some

things

such

as

the

customized

validation

message

that

from

my

experience

can

only

be

done

using

JS

Also

by

using

JS

you

can

dynamically

add

the

validation

to

all

input

fields

of

type

email

within

your

site

instead

of

having

to

modify

every

single

input

field

var

validations

email

Please

enter

a

valid

email

address

documentreadyfunction

Check

all

the

input

fields

of

type

email

This

function

will

handle

all

the

email

addresses

validations

inputtypeemailchange

function

Set

the

regular

expression

to

validate

the

email

validation

new

validate

the

email

value

against

the

regular

expression

if

validationtestthisvalue

If

the

validation

fails

then

we

show

the

custom

error

message

return

false

else

This

is

really

important

If

the

validation

is

successful

you

need

to

reset

the

custom

error

message

thissetCustomValidity

answered

Feb

at

Please

dont

only

post

link

answers

Just

put

the

essential

parts

of

the

link

in

your

answer

Feb

at

Apologies

i

will

correct

that

Feb

at

add

a

comment

It

is

very

difficult

to

validate

Email

correctly

simply

using

attribute

pattern

If

you

do

not

use

a

pattern

someone

will

be

processed

which

is

NOT

valid

email

Using

will

require

the

format

to

be

someoneemailcom

however

if

the

sender

has

a

format

like

someoneemailnetau

or

similar

will

not

be

validated

to

fix

this

you

could

put

this

will

validate

comau

or

netau

or

alike

However

using

this

it

will

not

permit

someoneemailcom

to

validate

So

as

far

as

simply

using

to

validate

email

addresses

is

still

not

totally

with

us

To

Complete

this

you

would

use

something

like

this

form

input

idemail

typetext

nameemail

required

placeholderEnter

you

Email

br

input

typesubmit

valueSubmit

The

Form

form

or

form

input

idemail

typetext

nameemail

required

placeholderEnter

you

Email

br

input

typesubmit

valueSubmit

The

Form

form

However

I

do

not

know

how

to

validate

both

or

all

versions

of

email

addresses

using

pattern

attribute

edited

Mar

at

Nakilon

answered

Mar

at

Keith

regex

checks

should

never

be

used

under

any

circumstances

There

are

too

many

patterns

and

they

have

too

many

flaws

For

example

someonecustomwordhereemailcom

is

considered

invalid

to

many

regex

checks

when

in

fact

it

is

valid

Regex

is

a

thorn

in

mine

and

many

other

users

sides

and

it

has

to

go

An

alternative

method

to

ensure

a

user

is

entering

a

valid

email

address

needs

to

be

used

Mar

at

Also

note

that

for

example

postmasterai

is

a

valid

email

address

and

this

regexp

would

ban

that

too

Source

Mikko

Rantalainen

May

at

add

a

comment

The

only

correct

method

is

to

check

for

sign

somewhere

in

the

entered

email

address

and

then

posting

a

validation

message

to

given

email

address

If

they

can

follow

validation

instructions

in

the

email

message

the

inputted

email

address

is

correct

David

Gilbertson

wrote

about

this

years

ago

There

are

two

questions

we

need

to

ask

Did

the

user

understand

that

they

were

supposed

to

type

an

email

address

into

this

field

Did

the

user

correctly

type

their

email

address

into

this

field

If

you

have

a

well

laidout

form

with

a

label

that

says

email

and

the

user

enters

an

symbol

somewhere

then

its

safe

to

say

they

understood

that

they

were

supposed

to

be

entering

an

email

address

Easy

Next

we

want

to

do

some

validation

to

ascertain

if

they

correctly

entered

their

email

address

Not

possible

Any

mistype

will

definitely

result

in

an

incorrect

email

address

but

only

maybe

result

in

an

invalid

email

address

There

is

no

point

in

trying

to

work

out

if

an

email

address

is

valid

A

user

is

far

more

likely

to

enter

a

wrong

and

valid

email

address

than

they

are

to

enter

an

invalid

one

In

addition

some

email

addresses

that

may

be

syntactically

or

politically

invalid

do

work

For

example

postmasterai

does

technically

work

even

though

TLDs

should

not

have

MX

records

Also

see

discussion

about

email

validation

on

the

WHATWG

mailing

list

where

is

designed

in

the

first

place

answered

May

at

Mikko

Rantalainen

add

a

comment

protected

by

Midhun

MP

Oct

at

Thank

you

for

your

interest

in

this

question

Because

it

has

attracted

lowquality

or

spam

answers

that

had

to

be

removed

posting

an

answer

now

requires

reputation

on

this

site

the

association

bonus

does

not

count

Would

you

like

to

answer

one

of

these

unanswered

questions

instead

Not

the

answer

youre

looking

for

Browse

other

questions

tagged

or

ask

your

own

question

asked

years

months

ago

viewed

times

active

days

ago

Blog

Adios

to

Winter

Bash

People

Chatting

SO

Close

Vote

Reviewers

hour

ago

Radiodef

PHP

hour

ago

Paul

Crovella

Linked

How

to

force

a

form

validation

without

submitting

it

via

jQuery

How

to

verify

form

input

using

input

verification

HTML

Validation

for

phone

numbers

Validating

email

through

php

and

jQuery

Email

Validation

JavaScript

print

out

div

in

JavaScript

if

return

false

jQuery

validation

on

not

working

for

input

array

Add

validation

to

PHP

form

in

responsive

HTML

Multi

Page

Form

javascript

submit

How

to

get

rid

of

error

message

once

correct

email

address

entered

in

form

see

more

linked

questions

Hot

Network

Questions

A

critic

made

a

comment

that

my

female

character

sounds

like

she

was

written

by

a

man

Can

scale

mail

be

modified

to

remove

disadvantage

on

Stealth

checks

How

could

a

planet

have

a

sky

without

stars

at

night

If

perfect

blackness

violates

the

Uncertainty

Principle

how

isnt

dark

matter

a

violation

What

importantcrucial

realworld

applications

use

blockchain

Identically

distributed

vs

PX

Y

PY

X

Diagrams

in

category

theory

I

keep

rolling

terribly

How

can

I

keep

playing

this

character

and

have

fun

despite

my

luck

How

is

rabbit

allowed

to

stream

anime

Why

would

a

previously

spacefaring

civilization

become

unable

to

build

another

interstellar

ship

Why

does

an

interrupted

dd

process

result

in

disk

partitions

How

would

trees

communicate

Can

Intel

Optane

memory

compensate

for

less

RAM

Why

does

my

Pi

always

have

the

same

IP

address

Can

someone

read

my

EMail

if

I

lose

ownership

of

my

domain

How

should

I

respond

to

a

reviewers

complaint

about

selfcitation

Super

hard

system

of

equations

Where

is

the

energy

transfer

from

a

metal

ball

falling

from

a

magnet

Seven

segment

display

with

TikZ

Is

eventide

a

correct

word

for

the

kanji

汐

Workaround

for

Apex

switch

bug

when

multiple

values

and

one

of

them

is

Steam

Powered

Door

My

Druid

wants

to

transform

into

a

blink

dog

How

do

I

rule

this

How

to

quickly

minimize

all

windows

for

a

single

application

question

feed

B B I O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O


jsrender jsviews how to loop a selected object list 4 How can I loop a selected group object list only from my json data For instance I just want to loop ID2 in the example below json ID1 items 0 VALUE1 1 VALUE2 2 VALUE3 4 VALUE4 ID2 items 0 VAL21 1 VAL22 2 VAL23 js myTmpl2 templates myTmpl2 result2 html myTmpl2 render data2 template script id myTmpl2 type textxjsrender props data tr td key td for prop props items td key prop td props for tr props script result ID1 0 VALUE1 1 VALUE2 2 VALUE3 4 VALUE4 ID2 0 VAL2 1 1 VAL2 2 2 VAL2 3 The result I am after result ID2 0 VAL2 1 1 VAL2 2 2 VAL2 3 Is it possible and btw what does data mean in props data I am using it but dont understand it can I do this if I want to select a group only props dataID2 jquery json jsrender jquery19 jsviews improve this question asked Jan 3 14 at 959 laukok 192k 108 309 535 1 Answer oldest 5 accepted data is the current data item or data context if you will See httpwwwjsviewscomassigntag for a sample illustrating this In fact data is short for viewdata and is the current view See this sample for example httpwwwjsviewscomsamplesjsrpaths Data paths such as foobar start at the current data item so datafoobar and foobar are equivalent In your sample above you could go straight to the ID2 object by writing tr td ID2 td props ID2items td key prop td props tr Other variants for ID2 tr td ID2 td props items td key prop td props tr for or props data if key ID2 tr td key td for prop props items td key prop td props for tr if props answered Jan 4 14 at 005 BorisMoore 7129 1 9 24 thanks for the answer laukok Jan 4 14 at 554 Your Answer By clicking Post Your Answer you acknowledge that you have read our updated terms of service and cookie policy and that your continued use of the website is subject to these policies Not the answer youre looking for Browse other questions tagged jquery json jsrender jquery19 jsviews or ask your own question

O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O


Invalid

setup

on

nonvirtual

member

on

an

interface

Ask

Question

While

unit

testing

using

Moq

I

get

the

following

error

Message

System

NotSupportedException

Invalid

setup

on

non

virtual

overridable

in

VB

member

cm

cm

AppSettings

It

IsAny

string

Per

these

findings

I

understand

that

its

preferable

to

use

abstract

classes

or

interfaces

with

Moq

Why

does

the

property

I

want

to

mock

need

to

be

virtual

Moq

is

throwing

Invalid

setup

on

a

nonoverridable

member

when

class

is

in

Service

Project

Invalid

setup

on

a

nonvirtual

overridable

in

VB

member

Moq

Invalid

setup

on

a

nonoverridable

member

x

xGetByTitleasdf

In

short

Ive

done

my

homework

But

what

if

Im

actually

using

an

interface

ConfigurationServiceTests

TestFixture

public

class

ConfigurationServiceTests

Test

public

void

DialectShouldQueryConfigurationManagerAppSettings

Given

configurationManagerMock

Setup

cm

cm

AppSettings

It

IsAny

string

Returns

It

IsAny

string

When

var

dialect

configurationService

Dialect

Then

dialect

Should

BeOfType

string

configurationManagerMock

Verify

cm

cm

AppSettings

It

IsAny

string

SetUp

public

void

ConfigurationServiceSetUp

configurationManagerMock

new

Mock

IConfigurationManager

configurationService

new

ConfigurationService

configurationManagerMock

Object

private

Mock

IConfigurationManager

configurationManagerMock

private

IConfigurationService

configurationService

IConfigurationManager

public

interface

IConfigurationManager

NameValueCollection

AppSettings

get

ConnectionStringSettingsCollection

ConnectionStrings

get

IConfigurationService

public

interface

IConfigurationService

string

ConnectionDriver

get

string

ConnectiongString

get

string

Dialect

get

ConfigurationService

public

class

ConfigurationService

IConfigurationService

public

ConfigurationService

IConfigurationManager

configurationManager

this

configurationManager

configurationManager

public

string

ConnectionDriver

get

return

configurationManager

AppSettings

ConnectionDriver

public

string

ConnectionString

get

return

configurationManager

ConnectionStrings

ConnectionStringKey

ConnectionString

public

string

Dialect

get

return

configurationManager

AppSettings

DialectKey

private

readonly

IConfigurationManager

configurationManager

private

const

string

ConnectionStringKey

DefaultConnectionString

private

const

string

DialectKey

Dialect

Why

have

I

created

the

IConfigurationManager

interface

Unit

Testable

Configuration

Manager

In

addition

to

it

I

want

to

bind

it

directly

using

Ninject

in

my

production

code

So

I

need

no

concrete

implementation

of

the

interface

hence

my

big

surprise

with

the

abovementioned

exception

kernel

Bind

IConfiguration

To

ConfigurationManager

InSingletonScope

And

doing

so

allows

me

to

unit

test

my

ConfigurationService

Any

idea

c

unittesting

ninject

moq

improve

this

question

edited

May

at

Community

asked

May

at

Will

Marcouiller

Answer

oldest

You

are

trying

to

mock

indexer

of

NameValueCollection

instead

of

your

property

getter

You

need

to

do

something

like

note

SetupGet

instead

of

Setup

SetupGet

cm

cm

AppSettings

Returns

If

you

want

mocked

collection

that

returns

anything

for

anything

you

may

need

to

override

actual

class

check

if

it

is

even

possible

to

do

If

you

know

what

settings

you

are

looking

for

returning

populated

collection

from

Mock

may

be

an

option

configurationManagerMock

SetupGet

cm

cm

AppSettings

Returns

new

NameValueCollection

SettingName

Value

Another

option

would

be

to

return

some

custom

interface

or

IDictionarystringstring

so

you

can

mock

indexing

too

interface

IConfigurationManager

IDictionary

string

string

AppSettings

get

edited

May

at

Community

answered

May

at

Alexei

Levenkov

Yes

I

know

what

setting

to

query

for

After

having

done

the

changes

suggested

because

I

was

using

ItIsAnystring

it

was

always

returning

hence

my

dialect

was

always

then

causing

the

test

to

fail

on

dialectShould

You

definitely

helped

out

I

love

SO

Will

Marcouiller

May

at

Not

the

answer

youre

looking

for

Browse

other

questions

tagged

c

unittesting

ninject

moq

or

ask

your

own

question

asked

years

months

ago

viewed

times

active

years

months

ago

Hot

Network

Questions

question

feed

B I O O O O B I O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O B I O O O O O O O O B I O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O


Cassandra

cql

how

to

select

the

LAST

n

rows

from

a

table

Ask

Question

I

want

to

verify

that

rows

are

getting

added

to

the

table

What

cql

statement

would

show

the

last

n

rows

from

the

table

below

Table

description

below

cqlshtimeseries

describe

table

CREATE

TABLE

ts

bigint

id

text

strike

decimal

callask

decimal

callbid

decimal

maturity

timestamp

putask

decimal

putbid

decimal

PRIMARY

KEY

ts

id

strike

WITH

AND

AND

comment

AND

AND

AND

AND

AND

AND

AND

AND

AND

AND

compactionclass

SizeTieredCompactionStrategy

AND

cqlshtimeseries

cassandra

improve

this

question

asked

Oct

at

Ivan

Answer

oldest

You

didnt

specify

last

n

by

what

To

get

the

last

N

per

id

SELECT

FROM

WHERE

ORDER

BY

id

DESC

LIMIT

N

ORDER

BY

clause

can

only

be

applied

to

the

second

column

in

a

compound

primary

key

If

you

need

to

query

by

time

you

will

need

to

think

about

your

data

model

a

little

more

If

your

queries

are

most

often

last

N

you

might

consider

writing

something

like

this

CREATE

TABLE

id

text

t

timeuuid

data

text

PRIMARY

KEY

id

t

WITH

CLUSTERING

ORDER

BY

t

DESC

where

id

is

your

time

series

id

The

CLUSTERING

ORDER

reverses

the

order

of

timeuuid

t

causing

the

cells

to

be

stored

in

a

natural

order

for

your

query

With

this

you

would

get

the

last

five

events

as

follows

SELECT

FROM

WHERE

idstream

id

LIMIT

There

is

a

lot

of

information

out

there

for

time

series

in

Cassandra

I

suggest

reading

some

of

the

more

recent

articles

on

the

matter

This

is

concise

and

relatively

recent

httpwwwdatastaxcomdocumentationtutorialsTime_Seriespdf

answered

Oct

at

Adam

Holmberg

Adam

thank

you

Ivan

Oct

at

Your

Answer

By

clicking

Post

Your

Answer

you

acknowledge

that

you

have

read

our

updated

terms

of

service

and

cookie

policy

and

that

your

continued

use

of

the

website

is

subject

to

these

policies

Not

the

answer

youre

looking

for

Browse

other

questions

tagged

cassandra

or

ask

your

own

question

asked

years

months

ago

viewed

times

active

months

ago

question

feed

O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O


Default for generic type duplicate 42 favorite 1 This question already has an answer here Is there a reasonable approach to default type parameters in C Generics 5 answers Is it possible to do something like public class PriorityQueue TValue TPriority int where TPriority IComparable note the int Before you suggest it yes I know I can just add another line public class PriorityQueue TValue PriorityQueue TValue int But Im wondering if its possible to do it as a param c generics net40 improve this question edited Jul 18 14 at 2126 ricksmt 503 1 9 24 asked Apr 30 10 at 2139 mpen 121k 168 637 937 marked as duplicate by nawfal pswg Ganesh Sittampalam Larry rene Dec 22 13 at 2057 This question has been asked before and already has an answer If those answers do not fully address your question please ask a new question 1 thats a nice c50 option Jhonny D Cano Leftware Apr 30 10 at 2146 add a comment 1 Answer active oldest votes 29 accepted No There is no option for default types on generic types in C Your second example is often the best option available if you need this behavior answered Apr 30 10 at 2142 Reed Copsey 464k 57 968 1270 add a comment Not the answer youre looking for Browse other questions tagged c generics net40 or ask your own question

O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O


Dynamically fill in an ArrayList with objects Ask Question 2 I have the abstract class Human which is extendet by other two classes Student and Worker Im am trying to fill in two array lists ArrayList of type Student and ArrayList of type Worker dynamically public class Human private String fName null private String lName null public String getfName return fName public Human String fName String lName super this fName fName this lName lName public void setfName String fName this fName fName public String getlName return lName public void setlName String lName this lName lName public class Student extends Human private String grade null public Student String fName String lName String grade super fName lName this grade grade public String getGrade return grade public void setGrade String grade this grade grade public class Worker extends Human private int weekSalary 0 private int workHoursPerDay 0 public Worker String fName String lName int weekSalary int workHoursPerDay super fName lName this weekSalary weekSalary this workHoursPerDay workHoursPerDay public int getWorkSalary return weekSalary public void setWorkSalary int workSalary this weekSalary workSalary public int getWorkHoursPerDay return workHoursPerDay public void setWorkHoursPerDay int workHoursPerDay this workHoursPerDay workHoursPerDay public int moneyPerHour return weekSalary 5 workHoursPerDay public class Program public static void main String args ArrayList Student student new ArrayList ArrayList Worker worker new ArrayList java oop arraylist improve this question asked Mar 14 15 at 2250 Metala 18 1 2 6 1 And where is your problem Jens Mar 14 15 at 2256 Dynamically With what data ug_ Mar 14 15 at 2258 The problem is that i can not understand how to fill in the arraylist or just a simple array of type Worker worker dinamically Because when i make an instance if Worker for example the constructor that i ve made must be initialized with its parameters but i do not want to hard code them I m trying to do somethind like this but with objects int arr Scanner input new ScannerSystemin int n inputnextInt for i 0 i n i arri inputnextInt Metala Mar 14 15 at 2259 Do you need to take input from the user mk Mar 14 15 at 2300 I want to fill in the lists with objects for type Student and Worker Metala Mar 14 15 at 2302 1 Answer oldest 2 Sure just add the students ArrayList Student students new ArrayList note students students add new Student Jens Nenov A You can do almost exactly the same thing for the workers If you want to use a loop do the following for int i 0 i 50 i students add new Student Jens i Nenov A This will create a list of new students with different numbers after their names If you want different data though that data needs to come from somewhere For example you might get the data from user input Scanner input new Scanner System in for System out println Enter a first name String firstname input nextLine students add new Student firstname lastname grade answered Mar 14 15 at 2258 mk 6707 4 32 51 Yes that is an option but if i want to add 25 students i have to do that 25 times Thats why i want to do this dinamically with loop But i do not know how Metala Mar 14 15 at 2306 Thanks dude You really help me with that post Metala Mar 14 15 at 2325 Awesome Im glad I could help Good luck with your program mk Mar 14 15 at 2328 Your Answer By clicking Post Your Answer you acknowledge that you have read our updated terms of service and cookie policy and that your continued use of the website is subject to these policies Not the answer youre looking for Browse other questions tagged java oop arraylist or ask your own question asked 3 years 9 months ago viewed 2600 times active 3 years 9 months ago Blog Adios to Winter Bash 2018 question feed

O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O B B O O O B O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O


PowerShell change datatypes of the DataDataTable object Ask Question 0 I am working on a script which creates a DataDataTable with the data from a csv file Everything worked fine I have it in my database with the right values But to help my database performance I would like to set the data types for the columns of the DataDataTable Unfortunately all my values are converted to strings from the CSV to the DataDataTable columns My CSV looks like this example Name UserID Salary Peter 1 120003 Jennifer 2 100050 I tried following methods foreach object in csv Write Output line countline foreach property in object PsObject get_properties property TypeNameOfValue System Type SystemInt32 and the other try property Value System Type SystemInt32 Both times nothing happened except errors So I want the following to happen The first column should be a datatype of string name The others should be double or float Does anyone have a solution for this powershell csv datatable improve this question asked Apr 16 15 at 1450 Arturka1 20 1 1 8 1 Answer oldest 0 There are several ways to solve this dilemma I will say ImportCSV has some limitations if you want to work with anything other than strings but it can be done Method 1 Hash Tables data import csv data csv Delimiter hashtable ordered Name data name UserID data UserID ToDouble Salary data Salary ToDouble Example output PS C hashtable Name Peter Jennifer PS C hashtable Name GM TypeName System String PS C hashtable UserID 1 2 PS C hashtable UserID GM TypeName System Double Method 2 CSV Files with Type Information This method is a little easier to use the traditional way Im used to ImportCsv but I couldnt combine the results into a single variable Not the end of the world but also a little more work to make more CSV files and figure out how to apply a type to them Example CSV files TYPE SystemString Name Peter Jennifer And TYPE SystemDouble UserID Salary 1 120003 2 100050 Example results from using ImportCsv PS C Import Csv double csv Delimiter UserID Salary 1 120003 2 100050 PS C Import Csv double csv Delimiter GM TypeName CSV System Double Optional Method If youre feeling brave someone who wrote proxy script for ImportCsv over here Importing typed objects with typed properties from a CSV file but I did not test that myself I mention it because it looks like a good way to deal with this if it comes up frequently I found this article on how to deal with some of the quirks of hash tables to be helpful answered Apr 18 15 at 352 Booga Roo 806 1 12 18 Your Answer By clicking Post Your Answer you acknowledge that you have read our updated terms of service and cookie policy and that your continued use of the website is subject to these policies Not the answer youre looking for Browse other questions tagged powershell csv datatable or ask your own question asked 3 years 8 months ago viewed 1368 times active 3 years 8 months ago Blog Adios to Winter Bash 2018 0 Unable to convert string to date type using ImportCsv question feed

B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O


How do I set combobox readonly or user can not write in a combo box only can select the given items duplicate Ask Question 39 6 This question already has an answer here How can I make a ComboBox noneditable in NET 5 answers I am facing a problem in setting the combo property such that only user can select the values form given items but I can not write in the combo box How can I do so in C c combobox improve this question edited Mar 15 16 at 1740 Peter Mortensen 135k 19 83 111 asked Jun 17 10 at 1100 Badr 4369 11 58 99 marked as duplicate by Andy Korneyev karthik Gregory Higley Synchro SW4 Jan 6 15 at 806 This question has been asked before and already has an answer If those answers do not fully address your question please ask a new question This question has been asked before Please see here stackoverflowcomquestions85702 Peter Jun 17 10 at 1105 6 Answers active oldest 100 Just change the DropDownStyle to DropDownList Or if you want it completely read only you can set Enabled false or if you dont like the look of that I sometimes have two controls one readonly textbox and one combobox and then hide the combo and show the textbox if it should be completely readonly and vice versa answered Jun 17 10 at 1103 Hans Olsson 442k 12 78 103 But please note readonly disabled Henk Holterman Jun 17 10 at 1109 Henk Yep thats why I said if you dont like the look of that since thats usually the main issue people find with disabling a control rather than setting it as readonly Hans Olsson Jun 17 10 at 1117 thanx buddy it was simple but if you dont know about this it is a mystery for you thanx it works Badr Jun 17 10 at 1120 too bad the combobox can not show default text and have a dropdownlist style at the same time nurettin Mar 12 17 at 1750 15 I think you want to change the setting called DropDownStyle to be DropDownList edited Mar 15 16 at 1742 Peter Mortensen 135k 19 83 111 answered Jun 17 10 at 1104 Ryan 4597 10 40 64 add a comment 12 In the keypress event handler e Handled true edited Nov 17 12 at 300 McGarnagle 858k 23 180 227 answered Jul 15 11 at 1208 Naa3er 129 1 2 Best solution Thanks MrJack Mcfreder Aug 18 17 at 457 That does not prevent deleting a selected text in the combo box ajeh Aug 28 17 at 1529 add a comment 10 Make the DropDownStyle to DropDownList stateComboBox DropDownStyle ComboBoxStyle DropDownList answered Dec 9 13 at 724 Tijo Tom 374 4 11 add a comment 4 The solution is to change the DropDownStyle property to DropDownList It will help edited Mar 15 16 at 1742 Peter Mortensen 135k 19 83 111 answered Jun 18 10 at 802 scatterbraiin 79 1 2 5 add a comment 3 Try this private void comboBox1_KeyDown object sender KeyEventArgs e comboBox1 is readonly e SuppressKeyPress true answered May 18 14 at 1205 Frans 41 1 add a comment Not the answer youre looking for Browse other questions tagged c combobox or ask your own question asked 8 years 6 months ago viewed 130010 times active 2 years 9 months ago 58 People Chatting SO Close Vote Reviewers 1 hour ago Shree PHP 1 hour ago bwoebi Linked 186 How can I make a ComboBox noneditable in NET 48 How to make Combobox in winforms readonly Hot Network Questions Collapsing numbers Can I work just what Im paid for while leaving Windows bulk rename middle filename via CLI Find if a list is an ABCtriple Where did the concept of Passive Insight come from How do you say in all directions in a single word Reviewer signs name on review Should the editor censor Why Laser Guns Why is initializing a string in an if statement seem different than in a switch statement xargs unmatched single quote by default quotes are special to xargs unless you use the 0 option Converting none to zero 0 in geodatabase table using ArcPy Short story read 25 year ago where changing persons name prevents a war Timespanning alien intelligences gamble with the fate of Earth Preparing in case ATMdebit cards might go missing during a long trip Why would a previously spacefaring civilization become unable to build another interstellar ship Reversing a queueInteger and converting it into an int array Why does it take so long to transmit an image from New Horizons to Earth Is there a way to make sure my government does not exchange SSL certificates POSIX shell does lose its special meaning if it is the last character in a word Are these claims about Japans health system true Unbookable column of seats on 777200 Why is angle of incidence equal to angle of reflection Length of the Longest Descent Buying someone a steam game without a steam account

O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O


How

to

correctly

use

the

Image

Source

property

with

XamarinForms

Ask

Question

I

am

having

difficulty

bringing

up

an

image

on

the

content

page

in

a

stack

layout

I

looked

through

Xamarin

API

Documentation

and

found

XamarinFormsImageSource

Property

but

no

sample

code

to

see

how

its

written

I

also

checked

to

see

how

it

was

written

in

C

and

seems

to

match

my

code

in

terms

of

filename

path

but

in

Xamarin

it

may

be

slightly

different

since

its

the

first

time

doing

this

The

code

Im

currently

testing

through

an

Android

emulator

Google

Nexus

in

Visual

Studio

which

runs

fine

with

the

exception

of

the

Image

not

showing

Image

Source

new

VerticalOptions

LayoutOptions

Center

HorizontalOptions

LayoutOptions

Center

Full

Code

public

NFCPage

StackLayout

stackLayout

new

StackLayout

instantiate

a

StackLayout

object

to

layout

its

children

Spacing

amount

of

spae

between

each

child

element

HorizontalOptions

LayoutOptionsCenter

VerticalOptions

LayoutOptions

FillAndExpand

defines

how

the

elements

should

be

laid

out

fill

the

entire

width

of

the

content

to

the

screen

BackgroundColor

Color

Blue

Children

gets

a

list

of

child

elements

new

Label

TextColor

Color

White

BackgroundColor

Color

Red

XAlign

TextAlignment

Center

set

text

alignment

horizontally

Text

Google

new

Label

Text

Place

your

device

directly

at

the

symbol

XAlign

TextAlignment

Center

TextColor

Color

White

new

VerticalOptions

LayoutOptions

Center

HorizontalOptions

LayoutOptions

Center

new

Button

Text

QR

Code

TextColor

Color

White

new

Button

Text

TextColor

Color

White

Content

stackLayout

apply

stackLayout

to

Content

c

xamarin

xamarinforms

imagesource

improve

this

question

asked

Jun

at

TheAmazingKnight

Have

you

read

this

doc

developerxamarincomguidescrossplatformxamarinforms

Generally

on

Android

you

add

the

images

as

drawable

resources

and

then

specify

just

the

image

name

and

Forms

will

find

the

appropriate

images

in

resources

Jason

Jun

at

Thanks

for

the

information

I

have

another

question

to

ask

where

do

I

specify

the

image

placement

onto

the

page

with

this

code

var

NfcImage

new

ImageAspect

AspectAspectFit

NfcImageSource

Doesnt

work

if

I

place

it

in

the

new

Image

constructor

TheAmazingKnight

Jun

at

I

figured

it

out

I

followed

the

one

titled

Local

Images

and

adjusted

the

file

path

name

to

Source

and

it

worked

Thanks

so

much

again

for

the

link

It

really

helped

TheAmazingKnight

Jun

at

Answers

oldest

You

shouldnt

reference

the

path

because

the

source

property

is

crossplatform

and

since

every

platform

has

a

different

folder

for

assets

like

images

you

only

need

to

specify

the

filename

and

extension

The

Image

class

knows

where

to

look

to

find

the

file

Image

files

can

be

added

to

each

application

project

and

referenced

from

XamarinForms

shared

code

To

use

a

single

image

across

all

apps

the

same

filename

must

be

used

on

every

platform

and

it

should

be

a

valid

Android

resource

name

which

means

no

spaces

and

special

characters

Place

images

in

the

Resourcesdrawable

directory

with

Build

Action

AndroidResource

High

and

lowDPI

versions

of

an

image

can

also

be

supplied

in

appropriately

named

Resources

subdirectories

such

as

drawableldpi

drawablehdpi

and

drawablexhdpi

var

beachImage

new

Aspect

Aspect

AspectFit

beachImage

ImageSource

FromFile

waterfrontjpg

Source

httpsdeveloperxamarincomguidesxamarinformsworkingwithimagesLocal_Images

answered

Feb

at

Adam

In

UWP

project

keeping

all

the

images

under

the

root

folder

is

not

a

best

solution

do

you

have

any

other

solution

where

to

keep

the

images

under

the

sub

folder

Please

refer

the

question

over

here

Ashaar

Jun

at

If

you

are

willing

to

add

images

using

code

try

this

Downloaded

automatically

and

display

the

image

var

webImage

new

Aspect

Aspect

AspectFit

webImage

ImageSource

FromUri

new

Uri

httpsxamarincomcontentimagespagesformsexampleapppng

answered

Mar

at

Asbar

Ali

Add

the

image

in

Solution

Explorer

by

clicking

ResourcesDrawable

folder

and

select

NewExisting

itemPlease

dont

copy

image

to

ResourcesDrawable

folder

I

Hope

it

helps

answered

Oct

at

Karthikeyan

Ramasamy

Not

the

answer

youre

looking

for

Browse

other

questions

tagged

c

xamarin

xamarinforms

imagesource

or

ask

your

own

question

asked

years

months

ago

viewed

times

active

year

month

ago

question

feed

O O O O O B I I O O O O O O O O O O O O O O O O O O O O O O O O O B I I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O

image source property
xamarin api documentation


Basic Bubble Sort with ArrayList in Java Ask Question 5 1 I was implementing a comparator and it wasnt working so I thought Id write a basic bubble sort int numbers 5 8 14 1 5678 int tempVar for int i 0 i numbers length i for int j 0 j numbers length j if numbers i numbers j 1 tempVar numbers j 1 numbers j 1 numbers i numbers i tempVar for int i 0 i numbers length i System out println numbers i toString Is this tutorial correct at all httpsblogudemycombubblesortjava I followed the example and applied it to Last Names in an arraylist but the results are a bit wack String a String b Person c Person d for int i 0 i list size i for int j 0 j list size 1 j a list get i getLastName b list get j 1 getLastName c list get i d list get j 1 if a compareTo b 0 Person temp d list set j 1 c list set i temp Id really like to get a grip on a few methods like figuring out why my comparator didnt work but right now Id just like to get a Bubble Sort to work correctly Thanks java sorting arraylist improve this question drewmoore 184k 15 63 99 asked Jun 20 15 at 832 gummiBear 29 1 6 1 a bit wack doesnt give us much to go on What exactly is wack about them drewmoore Jun 20 15 at 848 The order of the objects in the arraylist are changing but they are not in alphabetical or any other recognizable order gummiBear Jun 20 15 at 849 2 gummiBear See bubble sort only compares adjacent pairs and yes the tutorial about bubble sort is wrong Sumeet Jun 20 15 at 901 1 SumeetSingh you are wrongIn bubble sort we need to initialize the inner loop with j0 but we need to limit the upper bound as the larger elements are pushed towards the end aakansha Jun 20 15 at 1640 1 Yes it is called bubble sort because of that if you sort ascending ie desc then the big ie small values rise like bubbles this means they travel towards the end of the array or list Look for a visualization of it and you will see Already 1 aa1992 maraca Jun 20 15 at 1954 show 6 more comments asked 3 years 6 months ago viewed 9195 times active 3 years 6 months ago 16 People Chatting SO Close Vote Reviewers 1 hour ago Hovercraft Full Of Eels PHP 2 hours ago Wes question feed

O B I O B O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O B I O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O


Clear contents and formatting of an Excel cell with a single command Ask Question 20 3 If you want to clear the contents of a cell or range in Microsoft Excel you can use ClearContents If you also want to clear the formatting you can use ClearFormats Sheets Test Range A1C3 ClearContents Sheets Test Range A1C3 ClearFormats If you want to do both you can use Delete but then the other cells in the spreadsheet shift to replace the deleted cells Sheets Test Range A1C3 Delete How can you remove the contents and the formatting of a cell or range in VBA with a single command without affecting the rest of the worksheet vba excelvba excel2013 excel improve this question edited Jul 9 18 at 1934 Community 1 1 asked Aug 7 15 at 1857 MackM 1821 3 23 35 1 Answer active votes Use the Clear method Sheets Test Range A1C3 MSDN documentation here answered Aug 7 15 at 1857 MackM 1821 3 23 35 4 I spent an embarrassingly long time looking for that solution hopefully it will save someone else the trouble MackM Aug 7 15 at 1857 2 Happens to the best of us MatthewD Aug 7 15 at 1859 Realise this is old but when I call my macro from a VBA script everything but the delete out of data works Any idea Please see my question stackoverflowcomquestions39742599 E_McAndrew Sep 28 16 at 1208 1 Word of Caution Clear API also removes the formula if any in the target cells In that regard ClearContents is much safer RBT May 14 18 at 1240 RBT Im dont think thats the case the documentation for ClearContents specifically mentions removing formulas The only further consideration I can think of before using Clear is that it will also clear any notes you have left on that cell MackM Jul 2 18 at 1939 Your Answer By clicking Post Your Answer you acknowledge that you have read our updated terms of service and cookie policy and that your continued use of the website is subject to these policies Not the answer youre looking for Browse other questions tagged vba excelvba excel2013 excel or ask your own question asked 3 years 5 months ago viewed 115123 times active 2 years 6 months ago Blog Adios to Winter Bash 2018 question feed

B I O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O


How

to

configure

Spring

facet

in

IntelliJ

IDEA

Ask

Question

Im

new

to

Intellij

I

was

using

Netbeans

but

my

colleagues

told

me

to

shift

to

intellij

and

so

I

did

I

need

to

run

the

same

project

that

I

ran

on

netbeans

in

Intellij

The

project

that

Im

working

on

is

made

of

grails

and

spring

When

I

tried

to

run

the

project

using

Intellij

this

is

what

I

get

Spring

Configuration

Check

Unmapped

Spring

configuration

files

found

Please

configuresetup

Spring

facet

for

modules

file

And

this

is

the

file

applicationContextxml

xml

version

encoding

beans

xmlns

httpwwwspringframeworkorgschemabeans

xmlnsxsi

xsischemaLocation

httpwwwspringframeworkorgschemabeans

httpwwwspringframeworkorgschemabeansspringbeansxsd

bean

id

grailsApplication

class

orgcodehausgroovygrailscommonsGrailsApplicationFactoryBean

description

Grails

application

factory

bean

description

property

name

grailsDescriptor

value

WEBINFgrailsxml

property

name

grailsResourceLoader

ref

grailsResourceLoader

bean

bean

id

pluginManager

class

orgcodehausgroovygrailspluginsGrailsPluginManagerFactoryBean

description

A

bean

that

manages

Grails

plugins

description

property

name

grailsDescriptor

value

WEBINFgrailsxml

property

name

application

ref

grailsApplication

bean

bean

id

grailsConfigurator

class

orgcodehausgroovygrailscommonsspringGrailsRuntimeConfigurator

constructorarg

ref

bean

grailsApplication

constructorarg

property

name

pluginManager

ref

pluginManager

bean

bean

id

grailsResourceLoader

class

orgcodehausgroovygrailscommonsGrailsResourceLoaderFactoryBean

bean

id

characterEncodingFilter

class

orgspringframeworkwebfilterCharacterEncodingFilter

property

name

encoding

value

value

property

bean

bean

id

conversionService

class

orgspringframeworkcontextsupportConversionServiceFactoryBean

beans

Honestly

I

dont

have

any

idea

how

to

fix

it

Based

on

my

understanding

it

is

looking

for

some

modules

but

I

could

not

fix

it

I

even

tried

this

Add

framework

support

But

I

couldnt

find

spring

in

the

list

Could

you

help

me

fix

this

Thanks

spring

intellijidea

improve

this

question

edited

Sep

at

Bohuslav

Burghardt

asked

Sep

at

Answer

oldest

Go

to

FileProject

StructureModules

click

the

green

plus

icon

select

Spring

from

the

dropdown

and

select

your

module

in

the

next

dialog

Then

click

the

green

plus

in

the

right

pane

click

plus

and

select

your

Spring

configuration

files

and

classes

and

click

OK

Also

take

a

look

at

IntelliJ

Help

for

Spring

Facet

answered

Sep

at

Bohuslav

Burghardt

Your

Answer

By

clicking

Post

Your

Answer

you

acknowledge

that

you

have

read

our

updated

terms

of

service

and

cookie

policy

and

that

your

continued

use

of

the

website

is

subject

to

these

policies

Not

the

answer

youre

looking

for

Browse

other

questions

tagged

spring

intellijidea

or

ask

your

own

question

asked

years

months

ago

viewed

times

active

years

months

ago

Blog

Adios

to

Winter

Bash

Please

configure

Spring

Facet

for

modules

question

feed

O O O O O O B O O O O O O O O B O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O


How do I display even and odd numbers based on user input java Ask Question 0 Please help I need to write a program that displays even and odd numbers based on user input but it loops forever during my last print statement Here is what I have so far whats wrong import java util Scanner public class Integer public static void main String args Scanner input new Scanner System in int n 0 int odd 0 int even 0 System out println How many numbers will be entered n input nextInt while n 0 n 100 System out println ERROR Valid range 0100 REEnter n input nextInt while n 0 System out println Now enter n integers int num input nextInt while num 0 for int i 0 i n i if i 2 0 even else odd System out println You entered odd odd numbers and even even numbers java whileloop improve this question asked Nov 22 15 at 1917 user5486437 Well the indentation is wrong for a start Correcting this will help you find your problem Otherwise add print statements or use a debugger Meaningful variable names might help to see the problem too hagello Nov 22 15 at 2118 3 Answers oldest 0 You have a couple of issues with too many while loops You dont decrement n anywhere but you also loop on num while its greater than 0 So it will loop forever if they stick something other than 0 in there System out println Now enter n integers while n 0 int num input nextInt if num 0 if num 2 0 even else odd n System out println You entered odd odd numbers and even even numbers answered Nov 22 15 at 1933 Redroy 106 1 3 2 Scanner input new Scanner System in int n 0 int odd 0 int even 0 System out println How many numbers will be entered n input nextInt while n 0 n 100 System out println ERROR Valid range 0100 REEnter n input nextInt while n 0 System out println Now enter integer n int num input nextInt if num 2 0 even else odd n System out println You entered odd odd numbers and even even numbers Explanation You handle n inputs from user and just check if the input is odd or even with an ifstatement You were overcomplicating it Flexo 689k 21 142 225 answered Nov 22 15 at 1918 ehehhh 857 2 13 26 so you would recommend to remove that statement Or just add n somewhere user5486437 Nov 22 15 at 1921 Add n at the end of the while n 0 loop ehehhh Nov 22 15 at 1922 Also in the end of the while num 0 loop you should add a num that should get you closer to the correct solution whatever that is ehehhh Nov 22 15 at 1925 I just need to create a program that will allow a user to input how many integers he wants to enter then enter that specific number of integers and then it will tell you how many entered was odd and how many was even It still loops no matter what user5486437 Nov 22 15 at 1928 I edited the answer should give you what you need ehehhh Nov 22 15 at 1931 1 The infiniteforever loops is happening because of inputnextInt and this is due to the behavior of next method of Scanner class next nextInt and its other variations do not move the cursor to the next line end of current line instead reads the first complete token with default delimiter as whitespace nextLine method on the other hand reads the whole input and moves the cursor to the next line Your code can be fixed by adding inputnextLine to move the cursor to the beginning of the line before taking the next input See below modified code public static void main String args Scanner input new Scanner System in int n 0 int odd 0 int even 0 System out println How many numbers will be entered n input nextInt while n 0 n 100 System out println ERROR Valid range 0100 REEnter n input nextInt for int i 0 i n i System out println Now enter integer i 1 of n integers int num input nextInt while num 0 System out println ERROR Valid range 0100 REEnter num input nextInt this line is needed to move the input cursor to next line due to use of nextInt above input nextLine if i 2 0 even else odd System out println You entered odd odd numbers and even even numbers edited Nov 22 15 at 1956 answered Nov 22 15 at 1930 Raf 4486 1 18 35 Actually the while n 0 n 100 is needed to keep bugging the user for correct input until it is received ehehhh Nov 22 15 at 1936 ehehhh thanks for pointing out i totally missed that anyway updated the answer The issue of forever looping was because of nextInt method in the while loop What do you think Raf Nov 22 15 at 1957 Your Answer By clicking Post Your Answer you acknowledge that you have read our updated terms of service and cookie policy and that your continued use of the website is subject to these policies asked 3 years 1 month ago viewed 17689 times active 3 years 1 month ago question feed

O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O