I want to create a webform with a width and a height locked by a specific ratio so if someone changes one of them
: alert(new Date().getTime());
When_I_Fall, lowecase won't even submit the form in ie
Good for you. Why is it so important to do it that way?
When_I_Fall, if its lowercase in ie clicking the submit button does nothing
…um, then you are really doing something wrong
don't want to create objects if i don't need them.
can you pastebin the code?
When_I_Fall, yeah one sec
ok
Doward
When_I_Fall, http://pastebin.com/m468b242a
thats the html in the iframe
When_I_Fall, any guesses?
ni idea
When_I_Fall, is there any other way to break out of that frame?
wait lemme take a look again…
how do i make a javascript regexp not greedy? the ? character doesnt seem to be working for me
hi folx
is it possible to create associative arrays in js?
knittl, yes.
somehow it didn't work
how?
array['key'] = var
assoccArray = new Array();
assocArray['key'] = var
okay
gotta try it out
first do some sql
When_I_Fall, any more ideas?
idk, dude i always use target="_top"
actually, the assoc arrays in javascript are really just messed up objects (they don't behave exactly like normal arrays)
When_I_Fall, and does that work in ie?
it does for me…
try _parent?
When_I_Fall, i'm seeing that it specifically doesn't work for ie6 sp2?
t-, tried that too
anything lowercase in that version wont' submit the form, i even tried it in a regular link as well as an attribute
onclick="document.form_upload.style='display:block;'" this somehow doesn't seems to work
is it possible to do a screen capture in javascript
Fushuing, try .style.display = "block";
style.display = 'block'
okay
don't think so
anyone have any other opinions on thematter?
t-: not a difference
ah, nvm
is there any sort of "onready" event that fires every time the page is fully ready - that is, lets say I change an image host on the page dynamically - is there an event that is fired when it is done loading the new image?
u could try
getElementById(yourimgid).onload = function() { //do sth }
metoikos, would probably require a java applet or activex control
knittl, yeah, but I want to do it globally, for eveything on the page
u could loop through all elements xD
funny
you could load all the possible images at the start
mf
not possible
working with google maps
does javascript have anything resembling heredoc?
i just don't wanna have to be putting in \r or \n in a bunch of places
that's kind of annoying and difficult to read as well
i know, that's nasty
u can do it this way (either not beautiful, but i think nicer to look at):
str = ''
str += 'texttexttext\n'
str += 'abcabcasasfasf\n'
str += '…\n'
and so on….
hello everyone
hi barryog1
can you attach or store js objects in html host elements?
html elements are already js objects
ah the dom
right
hmm can I add my own member variable to a html element/js object
hum… i am not sure, but i think yes
is this for use when event handling?
well not particularly, I want to form a grid of div boxes which represents a chessboard
and using extjs or yui drag and drop be able to move elements between them
it would be sweet if I could have a class on each div which stored its x, y and so on
x means offsetLeft?
no x would be its position on the board/playing field
boxes on the first column have an x of 0
send column x of 1
second*
third have x of 2 and so on
hm
i would just create a multidimensional array
and somehow link it to the divs
anyhow, i think table cells are better for this case
me se back
knittl, naw i dislike that method equally
table cells sorta suck when it comes to using the drag and drop stuff
hm
to be honest, never tried it before
xD
knittl, and i would prefer to do concats rather than keep doing str +=, just put + on each line instead, much cleaner that way
oh
kay
str = 'blablabla'
+ 'lalalala'
indeed
+ 'blubluuu'
k
right
gotta recode some passages in my code
whats the function for checking length of a variable?
string?
the only way I can think of it is the set their class names to be something like 0X0 for space at x:0 y:0 and than have a hash table of the objects
string.length
can you do hashtables in javascript?
yes a string.. I want to check if I received a reply back or not
if(string != '') //ok
how can I use a variable within a javascript regular expression?
new RegExp(regexpstring)
i've tried that but its not working for some reason
does this look ok? var regexp = new RegExp('/a href=\"\/files\/190.*?\/a/gim');
ketasety not?
thats without the var
i cant even get to work that way
but if I put that same regexp in the .replace method directly it works fine
hm, i can't see an error right now
what does it throw out?
gotta go… thanks for all help!
nothing just no match
hm, that's bad
then the expression is broken
but str.replace(/a href=\"\/files\/190.*?\/a/gim,'') does match
same exact expression
driving me crazy
try alert(regexp);
knittl, http://www.webdeveloper.com/forum/archive/index.php/t-68481.html
knittl, \ does it
knittl, ok if take out the leading / and trailing /gim it does work
kooooooooool
but i need my /gim
oh man
ketaset
new RegExp(regstring, params)
so
var regexp = new RegExp('yourlinkstuff', 'gim');
ahh awesome thanks
you're welcome
\ (returnkey)
is just an alias for \n
so the newline is escaped… neat
might be a silly question, but is it possible to disable the browsers menu on right click in a browser. eg over fckeditor ?
knittl, sort of… but it's more than that because you don't need '
true
but it's rly cool
p_masho, doubt it. Tiny MCE ftw
never thought of googling for it
tiny mce \m/
knittl, yeah… you and the rest of the IRC population
knittl, too many people who don't google
Is there a way to do something like HEREDOC in JS?
lol
just switched from tinyMCE, fck is better fro images and uploading for my app
aaroncampbell, hahahah rofl, yes
aaroncampbell, http://www.webdeveloper.com/forum/archive/index.php/t-68481.html
lol
aaroncampbell, i *just* asked that question and then found the answer on google
never had a laugh like this
knittl, 0.o apparently you've never read bash.org
knittl, http://bash.org/?top
i did
but those are just quotes
Thanks abstrakt
how are optional arguments specified in javascript?
and how is null specified?
woah
this is rly sick
$sqlAccounts[$sqlAccount[$sql['col']['user']]]
knittl, sick as in disgusting or sick as in awesome?
i would vote for the former
both simultaneously
i always thought that "ill" slang was retarded
i just want to fill an assoc-array with usernames of an sql query as keys xD
maybe that's the point
deltab, except it's not
i.e. it's not likely to be used by uncool people
anyway, all arguments are optional in javascript
deltab, it's an attempt to be "cool" derived from wannabe gangsta's in NYC and NJ which really just results in being much more uncool than if otherwise not used
deltab, ok good to know
lol
u confuse me
deltab, how do i specify default values for them? function foo(bar, baz = false) - does that work?
and parameters not given a value are set to undefined
it's like brainfuck2d
no; check for undefined
deltab, k
`js default
All parameters in a javascript function are optional. Any you don't pass into the function are set to javascript's 'undefined' value. Check for param==undefined if you want to set a default value.
hmm, that was supposed to have extra info too
param === undefined is better, I think
yes
!!(0 == undefined)
false
!!(null == undefined)
true
!!(null === undefined)
false
`js default
All parameters in a javascript function are optional. Any you don't pass into the function are set to javascript's 'undefined' value. Check for param===undefined if you want to set a default value.
jseval '' == undefined
false
deltab, when checking for undefined should i use typeof(var) == undefined; or typeof(var) == 'undefined'; or does it matter?
typeof undefined
undefined
typeof typeof undefined
string
deltab, erm, was that supposed to answer my question?
the result is a string, so you do need the quotes
deltab, okers, thanks
note also that typeof is an operator, and doesn't need the brackets
deltab, ok then, the brackets won't hurt it though will they?
no
k
deltab, is there a circumstance where i would not need the quotes around undefined?
deltab, e.g. if(var == undefined)
would that have the same effect as if(typeof var == 'undefined')
when you're referring to the value undefined
v === undefined
yes
note that 'var' is a keyword, so not the best example variable name
deltab, k so really i don't particularly need the typeof operator when checking to see if a var is undefined, because type will be 'undefined' and value will be undefined
deltab, k good to know
hmm
`js undefined
hi there.
ok i'm just gonna use if (myVar == undefined) instead of if(typeof myVar == 'undefined')
===
everyone here familiar with behavior.js?
remember null == undefined
If I declare a class behavior that is not on the page until after a later Ajax request does it still work?
deltab, erm, so i should check for undefined with explicit type comparison? e.g. is: if(myVar === undefined); better than if(myVar == undefined); ?
i am using protype.js
yes, unless you want null to be treated the same as undefined
deltab, ok, in this particular instance i don't think it will matter but that's also good to know thanks… i'll go ahead and use === just to be safe
if (min != undefined && typeof(min) == 'number' && value.length min)
!==
deltab, so i'm doing an explicit type check anyway, so the !== shouldn't really be needed should it?
ah, right
deltab, k, but i get what you're saying about the explicit type comparison === and !==
bdeltab, k, but i get what you're saying about the explicit type comparison === and !==/b
does foreach exist in javascript?
nope
but for in
and only for objects
If I declare a class behavior that is not on the page until after a later Ajax request does it still work?
knittl, does an array qualify as an object?
knittl, heck a string is an object isn't it?
and it iterates over properties not usually what you want
deltab, ok
not just numbered properties
deltab, does .length work for an array too? how do i get the number of array elements?
myArr.count ?
length
k, and how do i typeof check for array?
because according to this site i googled typeof myArr will return 'object'
hum
future versions of JS will have foreach; but until then, use for (var i = 0; i seq.length; i++) { … }
yes, as with any object
what do you need to check for?
deltab, errr, i guess no particular reason, it would really be more for internal error checking so my function doesn't bomb out
deltab, just to make sure it's actually an array before attempting to treat it as such and run it through a for loop
note that it could receive an object that isn't an array, but works in the same way
ok, so i don't really have to worry
Whooo! Doom rocks!
Jan-, surely you mean DOM?
:P
for instance, DOM methods can give you collection objects that aren't Arrays but have length and numbered properties
Jan-, or perhaps Doom 3?
no, no. Doom, the movie!
Jan-, oh… the movie? doesn't seem like that could be very good, but hey, to each their own.
Oh it's not good in the conventional sense.
But it's a ton of fun.
ok guys
cu 2moz
bye and nite
deltab, k, this will be a function used by the developers only so if they accidentally pass an object that isn't an array that'll be their (my) bad
nini kniolet
er, knittl
Jan-: does it have the familiar sound effects?
Yeah, to an extent.
have you guys ever seen Counter Struck?
(speaking of familiar sound effects in movies)
It also has the amusing spectacle of Rosamund Pike trying to be American
i don't know who that is
deltab, ok how do i check a regex? string.match or something? someone said it in here earilyer
udeltab, ok how do i check a regex? string.match or something? someone said it in here earilyer/u
hrm, well there's string.replace i just want a match
yes, string.match
ok cool
Can anyone help me with changing an onkeyup handler?
deltab, and do i need quotes around the // such as string.match('/foo|bar/') or can i just do string.match(/foo|bar/)
eboyjr, not unless you tell us what your problem is
no, /…/ is regex literal syntax
?
deltab, er no to which? that was a two part question
use string.match(/foo|bar/)
k
lol okay! I'm using GreaseMonkey on I want to have it change the onkey handler from an input box. It isn't working and someone said that I have to set it when the page loads. But, the document.body.onload OR the document.onload doesn't work!
deltab, yeh, vim highlights it properly without '' so i figured it was probably correct
without quotes
IIRC, Greasemonkey scripts don't run until the page has loaded anyway
eboyjr, define doesn't work. does it sit on the couch all day eating all your potatoe chips and drinking all your beer? does it refuse to get a job?
Ohh. How can I change: document.getElementById('q').onkeyup = makeRequest; When I /do/ key up on the text box, nothing happens.
eboyjr, that change has to occur after that particular dom element has been loaded on the page
tag
eboyjr, you've gotta register those handlers somehwere at the bottom of the page
IIRC, Greasemonkey scripts don't run until the page has loaded anyway
Its in Grease Mokney
i don't eve know what that is, sorry
i'm not a javascript guy
Ohh. GreaseMonkey is just a Firefox Extension that lets you execute JavaSfript on specified pages. e.g. Get rid of MySpace ads.
well, to add your own event handler, you'd have to use addEventListener
Cool! Thanks, I'll look into that.
http://www.oreillynet.com/pub/a/network/2005/11/01/avoid-common-greasemonkey-pitfalls.html should have everything you need to know
(the tips themselves start on page 3)
Greasemonkey is an amazing tool, especially since you can use all the Firefox-only stuff you'd never use anywhere else
greasemonkey?
does getElementByName() exist and work like getElementById() ?
i've got two field names coming into a function and i want to retrieve the values associated with the inputs with those names in a given form
No.
no
`js forms @ abstrakt
js forms: Accessing form elements via JavaScript: Don't use document.forms[index].elementName or document.formName.elementName. Use document.forms['formName'].elements['elementName'] or document.getElementById('formID').elements['elementName'] or document.getElementById('elementID')
Accessing form elements via JavaScript: Don't use document.forms[index].elementName or document.formName.elementName. Use document.forms['formName'].elements['elementName'] or document.getElementById('formID').elements['elementName'] or document.getElementById('elementID')/u
Cute. ^_^
Ka-waiiii!
Jan-: Huh?
…what is it?
Kawaii. Japanese for 'cute'
Ah.
I don't speak Japanese.
You should.
Indeed.
It's amazing that when an operating system is old and full of strange quirks and even bugs, people go nuts.
But when a language is old and full of buggy quirks, people go, oh, must learn!
I just like languages.
Japanese will turn your head inside out
does the channel support 3rd party scripts?
if a problem is interesting enough, some kind soul may help - ask and see
I have been waiting for Dorward to show up, but I'm getting tired…
I hope he doesn't.
Jan-: he seems to know YUI very well
he would, he works for Yahoo.
However, he's also a fucking prole.
I know
he works for Yahoo
And I know he's a fucking prole.
I didn't.
Aankhen“: I have a little question: How did you make it so it said: Aankhen“ shrugs.??
/me shrugs.
Jan-: what I want to do is the tabview widget used on yahoo.com page, the one with mail | messenger | radio
Good for you.
I know nothing about it.
write your own, and stop being such a girl
Jan-: I'm writing my own
good for you
rawr
Rawr?
so I have a checkbox. I use onclick to trigger some ajax stuff when it's toggled, and I replace the checkbox with an image temporarily. When the ajax is done, I replace the image with the checkbox. This all works great except for one thing:
When the checkbox is put back on the page, it's value hasn't changed.
No amount of elem.checked, elem.value, elem.defaultValue or anything seems to change the value of it
ohh I see
since I replaced innerHTML on the parent, the original handle to the element is no longer valid
fixed
that's the problem with innerHTML
yeah it invalidates everything I guess.
Usually you find yourself drifting away from using it, even though the DOM methods are a bit verbose.
and even though you have to work around IE if you want to give an input element a name :/
band even though you have to work around IE if you want to give an input element a name ://b
I use http://www.jonathanbuchanan.plus.com/repos/js-utils/12-dombuilder.html to take away some of the pain
Whos' Jonathan Buchanan?
what's the syntax for declaring an array? var foo = array(x, y, z); ?
var foo = new Array(a, b, c, …);
Jan-, Pat Buchanan's butt buddy?
_fury, does the capital A matter on Array(….
I think so
var foo = [x, y, z];
k
Does anyone know of a good tutorial of setting the selection in a text box in Firefox?
somebody else probably knows better
insin, erm, so is that just an alternat syntax?
eboyjr, there are issues with that, check quirksmode.org
actually it's a bit prettier
eboyjr, basically it's not really do-able, and or there are limitations
ok
_fury, uhhh, i think new Array( is prettier but that's just me
that's the object literal syntax
hey everyone
insin, any reason to use that aside from style preference?
hey fall
what's up?
I'm curious as well
When_I_Fall, i fell
it's more compact
oh just trying to get through the day
yourself?
insin, i said aside from style preference
so, not other than style preference
so funny i forgot to laugh…
boredom =p
as in, it's less typing
I feel ya
insin, depends on what editor you use
that's why I'm in here
insin, i've got macros baby!
i'm so bored i've actually bothered looking for the Python download site =p
insin, anyway, is the capital 'A' in var foo = new Array(… required? or does var foo = new array(… work just as well
it has to be capital, yes
=O don't succom the the desires!
k thx
the constructor function is called Array
?
When_I_Fall, learn ruby instead
I'd guess its required
but IE will probably take either
Python and Django
but that's just me
bah rubuy
…ehh… no thanks
yeha, that's just abstrakt
haha
C++, python in order of preference
and utility
D, C++, javascript
preference order
Ruby syntax is nice
lol D
as the "is different from" operator
anyone know how I can make the scrolling on https://www.chegworthvalley.com/v789/products2.asp smoother?
import.every.python.lib.known.to.man.and.his.second.cousin.*
D is useless, no C compatibility
bbl
what are you talking about?
it has C compatibility
yah, that is often the issue.
and i have an issue with the Python whitespace deal from a purist's compiler construction perspective. whitespace should be a stylistic element, not a syntactic one
require 'urgh/I/an/including/files/like/php.rb'
have you heard of the whitespace language?
LMAO!
DDustin, if this is a joke, the setup better be worth the punchline…
DDustin, so… "no, i haven't"
its not, it's a real language
I was wondering if you'd heard of it
its pure whitespace
a great language
right up there with lolcode
CAN HAS STDIO? KTHX BUI
so yall like python eh? is there a correlation between javascripters and pythoners?
I don't like python
its interpreted
javascript isn't?
I do hope that's irony
javascript is the only language I like that's interpreted
ahh, k
it actually has a *reason* to be interpreted
as opposed to just doing it for the sake of doing it
out of everything interpreted, are your thoughts?
[kidding]
When_I_Fall, yes. my thoughts are, in fact. thanks for asking.
probably a wise observation
insin, so what's your strange reason for not liking Ruby?
how do I get a value from a input when clicked I have onclick="process();" for the function in my input button, but I need to get the value attribute and assign it into a variable
I don't mind well written Ruby, but there are so many ways to do everything!
Plus I have to deal with Ruby code written by Java developers at work… oh my
insin, you could say that about Perl
d-media: onclick="process(this.value)"
I do
insin, bad code can be written in any language, that argument doesn't hold very well
insin, as do i
insin, don't blame the code on the language, blame it on the coder
I believe in in the middle ground, languages should do their best to do everything, but think carefully about ditching certain paradigms for the sake of others
insin, we get tons of retards in PHP doing insane shit
okay there ain't a way I can do it like var value = input.inputname.value ?
or does it have to be this.value
I'm not blaming anything on anyone, I don't actually dislike Ruby
d-media: why would you want to do input.inputname.value?
I just prefer Python
that sounds much harder
I didn't know if it could work like that
insin, ahh, and i don't actually dislike Python, i just prefer Ruby
hi fives all around
d-media: yeah sure, but that's probably not going to be the way you want to do it
insin, i've learned them both
ok, well anyways I'm use this.value now how would I get the value into the function?
insin, i really like Ruby syntax, i don't have an issue with Python syntax particularly, but i really like Ruby syntax
d-media: you just got the value into the function… what do you mean?
how would I pass it into the function, what do I need to do to use it window.location = /pages/website-package-form.html?value=valuehere?
insin, although i don't usually find either Ruby or Python installed in the shared hosting environments used by most of my clients, and most of them want PHP because they know the name… so, whatever, they're paying me
that's rather unfortunate
insin, getting paid is unfortunate… what do you eat for lunch? rocks?
scriptfunction gofarfaraway(val) { window.location = "blah/" + this.value; } /script
(joke)
d-media: gr, I typoed that really bad
let me do it again
scriptfunction gofarfaraway(val) { window.location = "blah/" + val; } /script
errr, it's usually a better idea to register event handlers in javascript rather than with attributes
cleaner code, more modular
d-media: does that clear it up?
less compatible
DDustin, not really
yes really
DDustin, less compatible with what Netscape 3?
with older browsers
I have free reign in what I use for my freelance work for clients, as it's usuall something I'll be setting up on their intranet servers - guess I'm just lucky in that respect
the lot of them
DDustin, yeah, netscape 3
that is an older browser
good observation
Yarrgh!
no because you don't have a value in that input type? this is what my input type looks like input type="button" name="sbw" value="Buy Now!" onclick="process(this.value)" value="599"
DDustin, yeah it's like 0.00002% of the market
you don't know that
The DVD player just did the "ejecting the disc while it's still spinning" thing
DDustin, i suppose we should use HTML 3.2 so we can support old browsers eh?
bDDustin, i suppose we should use HTML 3.2 so we can support old browsers eh?/b
bbDDustin, i suppose we should use HTML 3.2 so we can support old browsers eh?/b/b
if that's all your site needs, yes
DDustin, heck if you're worried about that kind of thing, don't even use javascript in the first place
DDustin, no site needs that
d-media: just pass a string in
the FBI should monitor who still uses Netscape 3 and shoot them
input type="button" name="sbw" value="Buy Now!" onclick="process(599)"
problem solved
you can bicker all you want but it won't change any facts
DDustin, yup, that would solve the problem once and for all… now you see the light!
okay great, now how do I get that parameter into a variable?
DDustin, the fact that old browser account for a negligible portion of the marketshare which is not worth the ROI to target? yes that fact doesn't change
inside the functino?
d-media: function process(var) { … }
'var' now has the number 599 in it
k cool
so I can name it anything if I want?
gr! I'm typoing a lot today
even value?
you can't use the name var
k
value, yes you can use
you can use anything but var
k
is that it?
the investment is very small
bingo
worked
hehe
great
still getting famaliar with javascript
DDustin, and helps keep your code less maintainable which creates more overhead and higher cost in the future. initial development is not the primary cost in the software industry, it's future maintenance overhead
onclick is hardly overhead
DDustin, and even that "very small" investment isn't worth it, that's what i'm saying, just so you can keep targeting a virtually non-existent portion of the browser market
future maintance is created by crappy code, not using onclick
there are better things to focus on
onclick is perfectly valid
hmm
but I do see your point here
I agree with it, to a certain level
DDustin, k, that's all i'm saying
the point where I draw the line is slightly tighter then you, aparently
http://www.seo-blackhat.com/about/
anyone?
DDustin, it's not a be all end all absolute
DDustin, might as well write more modular code as long as you don't fit into that negligible portion of the developer world who needs to target that negligible portion of the browser market
DDustin, than… it's than… sorry, one of my pet peeves
DDustin, i have very few grammatical pet peeves, but that's one of them XD
the browsers are still out there. I have no idea what the numbers are, and that's what scares me
brb
people draw up numbers all the time. but frankly I think they're all full of it
d-media, http://www.quirksmode.org/js/introevents.html
anyone interested in fixing a bug related to capturing the key pressed event in IE6 (it works in FF and IE7).
DDustin, i think it's safe to say the numbers are small and things like backwards compatibility is part of what keeps better technologies from emerging
ofcourse, ask away
what are you using to get the keypress right now?
DDustin, i think it's better to ditch backwards compatibility in favor of better code/better practices/better technology in most cases
with javascript? nah I blame that on lack of quality js developers
most of them are plain horrible
DDustin, ditto for PHP devs
DDustin, luckily i fall into neither of those categories
you should see VB developers
using onkeypress
DDustin, naw… i was one, i've been there
i wish i could ditch backwards compat
DDustin, did ASP for a while before i did PHP
I've seen some narly slow and horrible VB code
i am calling a function actually onkeypress="return (tagsubmit_ajax(event));"
maybe I need more exposure to bad php code