basically i have two multiple select box im doing a add button so that when i choose some field from left sellect
hmm, is there a reason why link href="javascript:if (boolean) return; doSomething();" wont work?
it works fine in an onClick event
forget about using href="javascript:"
it's really bad for accessibility and just causes problems
how then
i need a link on an image
a link? so when people click it, they go to another page?
its just an image that submits a form if clicked and confirmed
the other image hosting works fine, a href="javascript:openEditor(data here);"img…
and a form onsubmit="return checkForm(this)"
nope, i need to do the check in the image
there are no actual submit buttons
sure there is - you just told me the image submits the form
all are just type=button with onClick javascript with checks and then form.submit()
logic like "if this button is pressed, set hidden field 'action' to 'someaction', check if input valid, if so do form.submit()'
i need to do the checks when clicking the image
maybe input type image will work
sure, but why can't you have an input type="image"? there's nothing there that isn't better done in an onsubmit
have to try
hey guys
I want to find a certain substring in an element's className.
and extract information from it.
say I have a classname = "s-class-13-20"
I want to match for "s-class-" and extract 13 and 20
those integers can vary in size.
Buggaboo, regular expressions are your friend
which function should I start looking into?
btw, there can be multiple occurences of classnames like this, so "s-class1-…" "s-class2…" "s-classn-" etc.
ah found it.
"string literal".search(/s-class1-/)
finds the initial position.
hm. how do I ge the rest?
http://pastebin.com/m5cab5b5f that sucefull add new fields to table1, but no to the form, when i clique submit that values was not be send
hm, I know the string length of s-classn … add it to the value returned by search.
split on '-'
voila.
hm easier than I thought
http://pastebin.com/m5cab5b5f - what fail to that on add that elements to form ?
just add on table
but on submit form show the same
firebug
firebug will even check your aja
x
shiznit.
Buggaboo firebug sucks :X
i make a ajaxscript on firebug
and now that script only work if firebug is enable
if i disable firebug not work anymore :C~
maybe it tries to solve some errors :p ?
tag, only the content within the cell -
I would like to display some persistent information at the top right (or left) of the user's browser. Information which should be updated based on the user's interaction with a html form.
Is this something typically done in JS?
tags… any ideas?
can someone link me to a decent preprocessor for js?
Can someone point me to some code which does anything similar?
Or a guide to this sort of JS coding?
How do I pass a reference to a function as a variable?
can anyone help pleasE?
tag, only the content within the cell -
tags… any ideas?
var obj1 = obj2; is obj1 *always* a reference to the same entity that obj2 is referring to or is there some case where that might not be true?
is there anything wrong with…
document.getElementByTagName(\'fieldset\').style.backgroundColor=\'#FFFFFF\'; ?
why the \' ?
miro it's an array
getElement_s_ByTagName
escaping \ because its part of an echo ""
oh you're right.. i'll see if it helps, thanks
tags… any ideas?
fieldset id='test' ….
echo "a … onclick='document.getElementById(\'test\').style.backgroundColor=\'#FFFFFF\';' "; … doesn't seem to work
"a … onclick='document.getElementById(\'test\'
fishsponge__, you DONT put script tags in any other place than in HEAD
you dont need to escape the '
tag?
no
ok I removed the \, didn't change anything :-/
maybe this will help you more:
echo "a id='nd".$i."' href='#' onclick='javascript:showh(".$i.", false); return false; document.getElementById('test').style.backgroundColor='#FFFFFF';' style='display:inline;'Test/a";
"a id='nd".$i."' href='#' onclick='javascript:showh(".$i.", false
echo "a … onclick=\"document.getElementById('test').style.backgroundColor='#FFFFFF';\" ";
can't use onclick - it needs to happen without any user interaction
tag with all it's contents in the cell and it'll work?
sorry, wasn't for you… I'm in need of help, too
will test if it helps. buubot: how did you post a part of the snipped I didn't even provide :p ?
oh
lol.
that's doable with styles directly. a: visited …. etc.
do anyone knows of a js framework wrapping some util of dynamic injection of code? i'd like to encapsulate library dependancies
you might want to rephrase that request.
well, i need runtime inclusion of script node in the document. Could it be a good practice? I coded myself something, but i'd like to know if there are patterns on this.
yes.
but you don't need a lib or anything.
it's quite simple
lemme look it up
have it somewhere here.
well I can code it, that's not the problem
well, but if there are more integrated/extensible solutions i'd appreciate :p
I'd say, keep the code small, and pull out the big guns when you really need them.
is there a popular tool js people use to strip their code of whitespace?
dmead, split
is the name?
then join
with 'big guns' you mean prototype and the such?
not necessarily.
eh?
theres not a complete preprocessing tool?
i thought i remember the javascript hosting guy from yahoo talking about it on google lectures
Pyloneer, you mean the library prototype or the reserved keytord in the language?
keytord?
libraries
How do I get rid of the anoying "blue background selection" that IE does when I CTRL-click att something?
Pyloneer, yeah.
dmead, There are many such tools.
could you suggest one?
jsmin, minifier, dojo compressor, yui compressor
good morning everyone
ty
I've used jsmin, minifier and yui compressor
I'd recommmend yui compressor because it seems the best whilst remaining completely safe.
jsmin is good, but yui compressor is better. However YUI compressor cannot be done live (it's too slow)
Although I don't advise doing it live anyways
right
i'm already using a live compressor on my cgi programs
upx
use /packer/
http://dean.edwards.name/packer
Yeah, better off using something like a post-checkout hook if you're using svn.
(he's the guy who made the algorithm. I'd trust him
)
right right
cool
Can a javascript function edit behavior of another function? Example, if I have function doSomething() { alert('fail'); }, can some other function change that 'fail' to 'succeed' ?
you mean does js have introspection/reflection/macros?
not sure
document.body.innerHTML = document.body.innerHTML.replace('fail', 'succeed'); - it changes the text I see in Firebug, but the function still alerts 'fail'.
Hi again!
Expected ':' but found '='. Declaration dropped." and then a file. However, it doesn't say where in the file. How can I solve this?
That's a CSS error
Any idea how I can locate it then?
look for an '=' in your CSS.
It doesn't belong there
Sadly it's mixed lasso, html, css and js on the page _
But I managed to find it.
Looked att all style="" lines
an " had gone missing
scuse me … i know is not a JS question, but .. someone knows how much is the max size of an input's value?
CieNTi, I don't think there's a limit, if it's not defined by the user
there's probably some browser limit
nice, thanks
i'll try doing a infinite bucle then hehe
but just so you know, you can only send a maxiumum of 255 chars to the server if you're using the GET method
yeah, but i'll use post
use POST if you want to send binary data, or a large amount of text
http://pastebin.ca/667969 anyone knows what the problem can be? I am getting undefined _id error-msg…
The paste 667969 has been copied to http://erxz.com/pb/4144
where did you get that 255 limit from? Netscape 1.1?
another question, this Js one I know how to send files to server in a tipical html form … but allways u send it, u navigate to the getter page … There is a way to send files to server, but in js, or avoiding to navigate to another page ?
Woosta, probably hehe
I can't remember then, I know there's some limit on GET sends
CieNTi, sounds like you're talking about the AJAX technique
Woosta isn't 255 but is poor method. about 1k or 2k chars
Not even that
breakerfall never use ajax, but if u know a tutorial to do that i want … that's would be perfect
http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.3
if you want to send the data asynchronously, you need to stop the default event of submitting and instead parse the form and send the data yourself using the xhr object
http://support.microsoft.com/kb/208427
Yes, browsers themselves may have limits, but the protocol doesn't
even better - max url lengths: http://www.boutell.com/newfaq/misc/urllength.html
Woosta wins
hahhaç
nice
but i prefer POST hahaha
breakerfall reading …
even the MS document you linked to admits there's no limit in the protocol
preference is immaterial, they serve two different purposes
right.. the 2nd link has tested limits for everything and states (and links) no limit in the spec
fair enough
there's no limit in the protocol
everything as in browsers, apache, etc
but the original point still stands
255?
you shouldn't use it for transmitting large amounts of data
agreed
Woosta yeah i know i use both, get for some things, and post for others
you shouldn't use it to transmit data AT ALL
aside from the fact there are browser limits, it looks obscene
POST is for transmitting data
Woosta, sorry, I mean even sending requests to the server
not even passwords?!?!
GET is for requesting data
bad semantics on my part
using GET for requests can look obscenely ugly
a password isn't part of the request, it's data you're sending to the server host in order to get authority to request data
although it's got it's advantages over POST
ugly doesn't come into it
You should use GET to request information and POST to send information
I know
the name's kind of give it away
how can I dynamically remove an event-handler set on a link for onmouseover?
set it to something else
yourElement.onmouseover = null;
hello, I am trying to write a script that will read ALL the html from the page it is on, and POST it back to my server
should I be looking at innerhtml or DOM
I am not sure of the page structure the script will be run on, so it will have to be as generic as possible
dusk, you can use document.body.innerHtml, but I don't think you can get the head
yea, what if they aren't using body tags
(for whatever reason)
then it's not html
heh, i have to play devils advocate here
so, hypothetically, if they were not using body, html, or any of the other 'standard' tags, would I be forced to use DOM to pull tags tag, serialize them into a variable, and send them off?
peepsalot, can you go document.getElementsByTagName("html") ? I havent tried it.
k i tried it
works
hm
so something like…
document.contentDocument is the HTML tag
wait what?
document.contentDocument.innerhtml ?
innerHTML
so.. function bob { a = document.contentDocument.innerHTML; alert(a); }
eternal_enigma, yeah it looks like you can do that, but I don't think innerHtml is defined on it
or innerHTML
peepsalot, document.getElementsByTagName("html")[0].innerHTML is fine
but woosta has suggested something even more elegant :0)
how would I test that?
in an alert?
alert(document.getElementsByTagName("html")[0].innerHTML);
hm, what Woosta said
lol
awww,
lol
alert(document.contentDocument.innerHTML);
Oops
got the name wrong
alert(document.documentElement.innerHTML)
^^ works
does not appear to work for me in FF
works here
Works for me in FF
ah, yeah that one works
didn't see you updated on there
hmm
it doesnt grab under the code
under the code?
does anybody know if there's an event i can trap for when the browser window is no longer in 'focus'?
window.onload = function () { alert(document.documentElement.innerHTML); }
window.onblur
dusk, you need to call your code after the document has completed loading
oh sweet
that worked, thanks
cheers
ahh .. peepsalot's ESPN is better than mine
http://pastebin.ca/667969 anyone knows what the problem can be? I am getting undefined _id error-msg…
The paste 667969 has been copied to: http://erxz.com/pb/4144
why not use document.getElementById('_checked' + id) ?
instead of making it an alert, how can I save it to a variable?
function () { sfoo = document.documentElement.innerHTML }
have you programmed javascript before?
no
got it
http://developer.mozilla.org/en/docs/A_re-introduction_to_JavaScript
and you should use the "var" keyword
thanks
i have some vars into a function, how can i do it globals instead locals ? (without defining before the function, just from the function)
in that case you don't use var
in my xml-doc and I just cant get it to work…
the document is really simple
documentid1/id/document
peepsalot i have not defined it before, never, but i want that var accesible from other functions and that …
if i not use var, i get a error
var id = response.responseXML.getElementsByTagName('id').firstChild.nodeValue; - Whjy does this not work?
`doesn't work
What do you mean it doesn't work? What happens when you try to run it? What's the output? What's the error message? Saying "it doesn't work" is pointless.
xDDD Woosta u roolz
kanzie, getElementsByTagName returns an array, not an element, firstChild is not defined on arrays
well…javascript stops parsing
It actually returns a collection
`collection
(or nodeList) Think of it as an array that's immutable and live. It's immutable so there's no push/shift/etc.. It's live because if you add new elements to your document then the collection returned by getElementsByTagName() will change WITHOUT calling it again.
ah
heh oops
(minor quibble really)
so getElementById('id').firstChild.nodeValue: will work then?
sure. If you have an id="id"
response has the xmlobject, when but javascript console does not give me any error
I do
But your example doesn't
how can i convert a local variable to global one, without defininig it before the function
what a strange idea
globals are bad hmmkay
you can'tm, and you shouldn't
And you don't 'convert' it
ok
i have a string with some javascript code
Why??
in that string i say to create an object, from a constructor i did
Don't prefix the variable name with a var and it will automatically be a global one.
that shouldn't be either
from a function, i do an eval of that string
Ergh
but the created objects are just accesible from that function
and i need that object accesible from entire document
and for all the others functions
It's 1.15 am .. I can't handle any more of this .. I'm outta here for the night.
bIt's 1.15 am .. I can't handle any more of this .. I'm outta here for the night./b
is that because i want to convert local to global hehe
oh crappit
and the number and names of that vars can change, i cant define all before the function
is possible ?=
i read "window.eval()" do a global, and in FF works great, but not in IE
another solution ?
eval is also bad
''ERROR: 28765: Can't locate object method "is" via package "also" (perhaps you forgot to load "also"?) at (eval 212) line 1.
lol
CieNTi, what is your end goal?
peepsalot why eval is bad ?
my end
?
is a web that have some dinamical layers (can be img, div or some … not neccesary a layer)
dinamical++
and i create some objects related to that layers
nope…cant get it to work
var id = response.responseXML.getElementByTagName('id')[0].firstChild.nodeValue; does not work, it just stops parsing and breaks the function without no error (as usual)
why is it so messy parsing xml
FFS kanzie .. read you code
.getElementByTagName - elementS
Sorry, it's late .. I get pissed off easily
I have tried both dude
peepsalot why eval is bad ?
and being pissed off here is perfectly fine, gets you in level with my mood about this shitty problem too
CieNTi, it's slow, it's ugly, and it's insecure
any suggestion?
I'm using IE. I provided the window.onBlur event handler with a method to execute. it appears to work in all cases except: when i explicitly minimize the browser window and then maximize it again it no longer gets executed when the focus leaves the window
http://24ways.org/2005/dont-be-eval
CieNTi, there is almost always a way to do without it. paste some codeo f what you are trying to do
so noone knows…
(1) it's onblur, not onBlur (2) IE is a steaming pile of dog turd.
you've been told several times
listen
that aside, have you ever heard of this particular issue?
I've tried what Ive been told and it does not work! =(
no. I ignore IE-only problems. If you use IE, bad luck.
then pay someone to do it for you
unfortunately i work for a microsoft shop, so IE avoidance isn't possible
but fair enough
if you work for a MS shop, give MS a call and ask them
Nothing shows up in FF error console? Is the responseXML in proper format? Have you printed it out?
yep
looks fins
Its onblur not onBlur.
why the fuck do we have to provide support for their shitty browser? They don't bother fixing it because they know there's plenty of professionals around who spend all their time working around it's stupidities
Is anyone in here familiar with an IE-only problem related to the onblur event handler?
amen brotha
One word, Silverlight. Its because of this they won't bother upgrading to newer version of javascript.
Nor fixing the sucky things.
silverlight means nothing to me .. sorry
and unless silverlight means they lose their critical mass, then that's not why they don't bother fixing things
Anyways MS has decided to give web developers a hard time developing applications and thats that.
hi
Hi
how can i make the mause draw a circle where it is when it clicks?
how can I get the postion of the mouse in relation to a scrolled window. clientY is only in relation to the body.
is this code http://www.java2s.com/Code/Python/Event/Canvaspaintprogramdraganddraw.htm in JS ???
hi
anyone know any way to work with zip archives on IE - at least some unzipping features (a activex component or someting, someting that works - i've found a couple of components on the net by they are crapy) ?
Hello
Leonord, java might be best hosting if you want cross-browser compatibility
Leonord, or if the situation allows it, you should implement unzipping as a server-side component
is there a way i can measure the extent of some text string in pixels when rendered in the browser using a certain font?
what event is triggered if i write something inside input field…and then press the back button to delete character?
onchange
How can I clear the whole page?
You mean make it blank ?
no just delete one character
Yeah.
or make it blank
Try onchange
document.write(''); document.close();
onkeydown, onkeyup, onkeypress
thanks JLearn! I 'll try it now
and onblur and onchange when the user leaves the text box
oki thanks
how can i make the mause draw a circle where it is when it clicks?
I must be doing something wrong. I tried your suggestion but for some reason it's not working (the page doesn't end up blank). Here is my page if you would like to see it. http://dev.grulez.com/anim/
why use multiple script tags? Only one will suffice. Inside that put: document.write(''); document.close();
hi!his there any debugger for javascript for internet explorer?
foutrelis, document.body.innerHTML=''; should do the trick
hi!his there any debugger for javascript for internet explorer?
I'm doing a php script that outputs each line.
Even the suggestion provided by NooruIslaam is a nice one. You can use document.write(''); or document.body.innerHTML = ''; depends on what suits you.
JLearn, i think document.write('') only appends '' to what is already in the document
so it makes no difference
i just looked at his webpage and viewed the generated code using the webdev addon for firefox
and that is what seems to be the case
Once the document is rendered, a document.write('') overwrites what was previously there.
JLearn, oh ok
Thanks both of you.
Welcome
hi guys
How do I check if an array in a reference exists?
with document.write you might need document.open before it
is there any debugger for javascript for internet explorer?
I think it works with document.body.innerHTML=''
Not needed.
I think that there is a version of firebug that works for IE, Opera, etc
it lacks some of the features of firebug for firefox however
thanks, i will take a look
oh, yeah firebug lite, but you gotta add some files to the server side
http://www.getfirebug.com/lite.html
i haven't tried it actually
You said before that document.write('') works after the document is rendered. I need to clear the document before even closing the body tag so I guess that won't work. (lol.. I think I'm using javascript in a quite weird way O_O)
document.write('') will be an ideal solution if you want to clear the document after it has been rendered.
I see.
what about even if dropdown menu is…pressed?
?
onclick
event*
oki thanks
there is web developer toolbar and script debugger (but visual studio is better at debugging javascript)
anyway… firebug lite has only logging features and basic code evaluation console
Hi, how can I create a date variable that is 7 days in the past? I know how to format it, but to get a timestamp that isnt NOW, how?
bosko, dateObj.setDate or something, use dateObj.getDate and subtract
new Date(new Date().getTime() - 1000 * 60 * 60 * 24 * 7)
awesome thanks
can anybody tell me why http://pastebin.ca/668157 is returning a "missing formal parameter" error?
The paste 668157 has been copied to http://erxz.com/pb/4145
sweet thanks buubot
If I wanted to make a list, like a to-do list, with checkboxes next to each li, where checking them and pressing Submit would write the word "Complete" next to the li, what would I have to do?
My guess would be that the javascript hosting would change the id of the element, and have CSS add the text.
hi there,
I want to do unbotrusive js, using standard attributes
e.g. input validates="true" /
and use this to assingn observers..
I get the impression this is fairly standard..
is this valid w3c?
i'm having an issue with this javascript menu class i'm using (in IE 7). if i activate the menu a floating div layer is created, when i open another window on the desktop the div layer remains on the 'top' of the desktop even though i'm not using the browser
any ideas on how to fix this behaviour?
hey!i'm having troubles in IE to fill in a dynamic way a dropdown box, in firefox it works butt in IE it doesn't
the code that fills the select is
document.getElementById('queues').options[i] = new Option(separaQueue[1],separaQueue[0]);
is there any error for this to work with IE?
i'm having troubles in IE to fill in a dynamic way a dropdown box, in firefox it works butt in IE it doesn't
the code that fills the select is
document.getElementById('queues').options[i] = new Option(separaQueue[1],separaQueue[0]);
is there any error for this to work with IE?
can you pull a links href from a node?
instead of just getting hte link text
jackyyll1 check mynode.Children, find the A element using .tagName and extract the href
not .Children, it'S childNodes
so like
yea
node.childNodes.tagName('a') ?
huh no
we
er
childNodes[i]
loop your childNodes until you find a node that has .tagName == 'a'
how do yo get the href out of it?
..href or regexp?
like for (var key in n.childNodes) if (n[key].tagName == 'a') { boom!!!! }
regexp!?!? no check the .href, and if it doesn't work, check the .getAttribute('href');
How to handle a form in JS? this.f = document.forms['form_name']? And will this.f be a copy or a reference??
How to handle a form in JS? this.f = document.forms['form_name']? And will this.f be a copy or a reference??
you could try… change the name of this.f and check the name of document.forms['form_name']
can you explain what do you mean?
heh
hello
hi
does anyone know a link we I can get some more information on the formatting of $
POST
this.f = document.forms['form_name']; this.f.whatever = 'Hailz!'; alert(document.forms['form_name'].whatever); and see if it'S the same
if yes, reference, if no, copy
I am trying send a POST with xmlhttprequest… but if theres a space… it won't take a it
even it I escape it with "\ "
atula usually… adress.php?field1=value&field2=value
that's get
GET
change space for %20 (% and hex code)
no, actually it's the same for a post
without the adress.php?
but there must be somethign to encode your values… urlencode() or httpencode()
don't remember
hehe… lemme try the %20
you'd better find the function
caus space won't be the sole erroneous character
actually all charactor non-alphanumeric should be encoded that way
The function is encodeURI()
thanks. let me look up on that
Thank you
hi, I have a link with an onclick = function() { alert('a'); return false } and whenever I click that link, firefox gives me a permission denied error (http://pastebin.com/m7ae4c112)… any idea what I'm doing wrong?
(the alert fires though)
ld- : Thats the entire code?
what's the onclick attached to/
JLearn, I also have prototype included, let me see if it reproduces without prototype
looner, an a
the function getElementById, i'm trying to do the same thing but only return elements within a specific node. much like how document.forms[3].getElementById() looks like it should work. any idea on how I can do this or if there's custom code to reintroduce the method to other elements?
hey guys — when i preload an image via JS, does it also apply to CSS background-image properties? or those get loaded separately?
JLearn, I just entered a new firefox tab, typed this http://pastebin.com/m2291afa5 in the firebug plugin, then clicked the test link… same thing, the alert appears but I see the same permission error…
getElementById() is a method of document object with its own native implementation.
anyone familer with JSON?
what about JSON?
when i decode a JSON string with var a = eval('(' + document.getElementById('tags').value + ')'); i get a extra key/val with the key being 'toJSONString'
the .value is ["asd","dfgdfg"]
anyone know where the key toJSONString is coming from?
ld- : its working in my case without any errors…
ld- : Try this..http://pastebin.com/d7ca703cc
JLearn, same…
eh, must be something from me then
is there a better way to supress the browser from going to the link and doing something else instead?
ld- : What exactly do you need to do?
I have a delete link and I want it to go to the delete action by default, but if the user has javascript enabled, I want it to first ask the person if they're sure then do an ajax request and update the table from the response…
I'm using prototype and I said $$('td.delete a').each(function() { a.onclick = function() { … } });
and in the latter function I used a confirm() that, if it returned true, it went on and made the request and updated the table, and I ended the function with return false
Try using a button and see if you get the same error…
is that a correct way to do it?
Why not? I don't know about prototype but what you are doing seems to be fair enough…
can I fearlessly create anonymous functions everywhere? or does that make everything slow?
I see that the thing works pretty well on ff, opera and safari, but in ie it's very slow…
and I don't know where the bottleneck is…
Of course creating closures always makes you vulnerable to memory leaks.
Only through practice and profiling would you be able to pin point your problem areas..
how can I profile?
is there a tool available?
`Venkman
JavaScript debugger extension for Mozilla and Netscape browsers. http://www.mozilla.org/projects/venkman/
thank you
hey there.. i'm new to javascript.. after declaring that i'm going to use javascript (let's say prototype) between head tags, how can i use it ?
Hi… I need to display a simple calendar of the current month, generated dynamically with javascript. Anyone have any tips? There's a lot of crap out there…
you better find one aldready written there must be a lot for free on the google
the Yui one is nice
there's one called DHTML Calendar too iirc
on this page: http://extjs.com/downloads/tutorial/layouts-with-ext-p1/simple3.js
}();
what's that all about?
those () look like they don't belong there but the code wont work without it
Hi, I was wondering if there was some function that let me read the image width/height of an image hosting before it is loaded?
Ie6 seems to be having trouble doing that, see here:
http://flyingsoft.phatcode.net/flowers/pictures.htm
the images are distorted in IE6 until they are refreshed, and I *think* everything is cached
What's the best way to add rules to form's elements? (e.g. field can contain only digits or it must match to specified pattern)
when you have a regex and you have a [^\t^\s^]+ and want to do [^\t^\s^^http:] how do you make it not match every letter in http: and match only occurrences of the entire string?
[^\s]+http:
i needa stop asking questions before i try to fix it :p
[^\t^\s^(^)^\?^^(http]+
that works :p
how to add new element to array in the shortest way?
or no… in JS i can't have associative arrays (e.g. name=value)
you can have associative arrays
assocArray = {};
example
it's an object - so i can add values like: assocArray.newValue=1; ?
no
assocArray["thing"] = "other thing";
oh yeah
so
other thing
i'm creating a library which will catch forms and send them using AJAX
man
regex's can get confusing
and how to check if property exists?
hmm
if(typeof(object[propertyName]) != 'undefined')
or not… rules will be checked seperately so i don't need it
okay
(?:[.\w-]+\.[\w-]+)\b)
how to i make it stop at "http:"
ya know what
i'm not going to cater my script to morons who put 10 links on one line -.-
without spaces..
and how to check how many properties object has? or… if it has no properties, does it return "false" when: if(objectName) …?
for(var property in object) { alert(property + " " + object[property]); }
boy, so many basic questions get repeated and repeated and repeated and repeated..
uboy, so many basic questions get repeated and repeated and repeated and repeated../u
you just need a Couple more farms and 2 more breweries
if one trick ie to except xhtml, then what does the browser think it is getting? sgml? html? xml?
if a browser receive xhtml, it interprets it as HTML and will render it according to its own taste
so result will vary on browsers
not sure it that is right
Is it possible to delete 2 first characters from a string and save them to another variable?
what about namespaces?
namespaces ?
Look into substring function of String Object.
to me namespace is a folder in a project in my visual studio
:P
(also being a scope for type declaration)
yes, what happens to namespaces when ie reads the xhtml. Is it treated like xml?
xml namespaces
is there anyway to turn an html hosting element node into a textnode?
One question - how to break executing all functions in such example: http://phpfi.com/258268 ??
The paste 258268 has been copied to http://erxz.com/pb/4146
jackyyll1, i'm pretty sure that all text in an html element is actually stored in a child textnode
peepsalot, well i have an html element node so i can get the links HREF but, i need to do splitText on the HREF because it contains two links .. i then need to put the siblings back into the array of link candidates
and i don't know how to go about it :s
why do you have an href with two links in it?
peepsalot, well the href is one link, but it needs to be split href="http://anony.to/http://website.com"
i understand what you mean, but why the hell would you have a link like that
lol
anony.to makes the refer anonymous or something
so i guess people use it for thta
but i want the second part of hte link
so you want to put those URLs into text nodes? or do you want to put them into separate anchor tag hrefs?
seperate anchor tag hrefs
…………
can someone answr my question, or does no one know?
var a1 = document.createElement('a'); a1.href = link1; someParentElement.appendChild(a1);
Hi, I was wondering if there was some function that let me read the image width/height of an image before it is loaded?
the images are distorted in IE6 until they are refreshed, and I *think* everything is cached
http://flyingsoft.phatcode.net/flowers/pictures.htm
Agamemnus, i don't think there is a way to know unless the server sends the dimension data separately
i see
any idea what might be causing my problem?
sometimes it loads properly, and sometimes it doesn't. (even after deleting all cached files)
not sure, i don't even have ie6
aiight =\
here:
http://www.flyingsoft.phatcode.net/flowers/pictures.htm
oops
hihi javascripterinos
hi
Does anyone here read Czech?
you better Czech yourself before he wrechs yourself
ahaaaa ha.
….ha.
lol sorry, crappy pun. i didn't even type that sentence right.
sigh.
Agamemnus, that page looks totally static, why do you even need javasript
it's not static
"Pointer Fun with Binky"
it has a lot of internal stuff that you can't see.
i think the problem is angus's iepngfix, but the forums are don
down
how do you split a string by index?
Wow wtf, there's a lot of wacky javascript keywords
default, volatile, export, debugger
jackyyll1
you still there?
yes?
what do you mean "by index"?
i figured it out :p
dont worru
ehhe
k
does anyone here have IE6?
I think I fixed my problem but I can't be sure
i need someone to look at my site..
Agamemnus - you don't have ie6?
I do but I can't trust mysel
myself.
it doesn't always not work
ok nvm/
i am having troubles with deleting text created by createTextNode();
it definitely doesn't work now.
using removeChild();
i'd be all fine if i could set an id to the text
|Razor, removing the wrong child perhaps..?
but if i do that the script wont work in IE
var AddTxt = document.createTextNode("Question" + counter +": ");
AddTxt. id = "blah"
what happens when you try removechild?
space between addtxt. and id?
no not that, i was just making an example
however
if i removechild(AddTxt) it works
but obviously not well
what's wrong with ie6?
what happens?
it wont execute
nothing happens
im like o_O
no errors?
i never had problems with this before
no errors
give me a link
local
=\
…..
its strange
i'll put up the script
no warnings in mozilla?
no warnings
i have debug tools
show the script
no warnings at all
yeah i will hold on
Can form.elements contain other elements than "input" and "textarea"?
http://pastebin.parentnode.org/22388
thats the code
not the same but same principle
aight
settlerx, probably yes..
emm… in FF displays "type" in "textarea" as "textarea"
thing is that i remove several elements with the method that does not work
its just for the text node that it wont work
Can anyone tell my why my dom dump program is not working? http://pastebin.com/d153c008c … I'm calling it via domDump( win, document, 1 ) and not getting any elements printed.
so in the first example, in ie6 it doesn't work
and in the second example it does work?
yup
in IE too… can I believe that "textarea" has "textarea" value in "type" property in all browsers?
well it dosnt work at all in the first example
not in ff either
not in mozilla or IE6
only for text node tho
are you sure div and txt aren't reserved keywords?
it removes other stuff created with createElement
i am
changed it
elem.nodeName == TEXTAREA is best bet for IE & FF.
s/TEXTAREA/'TEXTAREA'/
instead of textnodes, CTalkobt?
what happens in the first example then?
function wont do anything
or is it the second example?
hold on ill try to get a debug message
i'm confused
Yes, text nodes == 'INPUT' and then the type of text node = elem.type
what?
er, textnode.nodeName = 'INPUT' and then textnode.type = 'TEXT', 'BUTTON' etc.
anyone familiar with greybox?
pc-41-227-104-200.cm.vtr.net
er
http://gowowzers.com/ajax/test.html
which ones work and which ones don't?
dusk, wrong type of OPEN statement?
wait a sec, ajax post?
I dont know, first time using 'ajax'
found that example on the web.. once I get that working, I can write my own script around it
the first example works somewhat
it messes up sometime
i dunno how/if xmlhttprequest can post stuff, but I only know that it can GET it
the second example dosnt work at all
What about "select-one" and "select-multiple" types?
Hello !
|Razor, can you just post another example telling me which example works with which browser in the comments?
dusk, try this code…
http://pastebin.com/d153c008c (No elements are being printed).
first one works in both browsers
second one dosnt work in any
var foo = foo || {}
sorry for being unclear
well, im trying to write a script that takes info from a page, and sends it to a php hosting script waiting to receive data
if (!foo) var foo = {}
dusk, right, here is code…
"agamemnus" at 71.6.194.243 pasted "xmlhttprequest. Example: myconn1 = new XHConn(); myconn1.connect("news.txt", "GET", null); mynews = myconn1.xmlhttp.responseText.split(newline)" (46 lines) at http://erxz.com/pb/4147
razor, and by "works in both browsers" you mean in IE6 it doesn't cause an error?
(but doesn't work)
thanks let me try
it's for plaintext files though, not tags or anything.
anyway.
razor, perhaps you might want to try innerHTML = "" on the parent?
or instead of a div, use a ?'
use a , then put your textnode inside the p.
er, im trying to transfer a variable I created through javascript
and do I replace getXHTTP with XHConn ?
dusk, transfer a variable what?
dusk, what is "getXHTTP"?
IS it possible to send files through AJAX using type="file" input element?
Not through XMLHttpRequest(), I don't think.
I have: var foo = document.getstufffromstuff();
and want to transfer foo
http://www.faunadiseno.com/clientes/WEB/dg.html any ideas on how to center the pop up if i have scrolled to the left?
dusk…
the script I pasted works like this:
it's a function/object. You make a new one, call it, and then read the text part of it.
the text part will be whatever text is in the file you specify.
hi
it will be in a string
what if I dont have access to, nor can I create, a text file?
I'm looking for a way to know the length of a file i'm downloading with javascript, what should I use?
what grey box popup?
this problem is tricky
what files are we talking about then?
Agamemnus, click on the first link
the blue one
well, I am getting data from the page and serializing it as a string into a var (through javascript)
is there a way to read the content of tcp frames I'm receiving?
I then want to send that var through the tubes to a php files waiting to hear from it
or at least their headers?
the page data should be loaded in as a text file with the code I showed you
heh, well, I can't load data from files
this code will be run on servers I do not have access to
nothing happens.. what blue link?
What are you talking about?
what DO you want to do again?
do you mind if I PM you?
sure go ahead
just lemme login…
is there any other way to add text to a page then createTextNode()?
k.
Razor…
other than what I told you?
createElement
did you try ?
innerHTML?
i tried to set the div to p, yes
innerHTML
innerHTML = ''?
that removes it
someobj.innerHTML = "blah"
ic
i'll try
makes anything between that obj into "blah"
the one that says "taller de diseño 1"
inner html does not work
i just need to get a lock on the id of the textnode
innerHTML
and yes it does
yes, it didnt work
Be aware that innerHTML has some issues with either IE or FF with table cells. You then have to resort to createElement etc. I forget whether if this was with simple text or complex (ie: embedded html : bExample/b)
ah
well
it goes to a different page
if i were to use createElement, which works fine
how could simply add a text to it?
…innerHTML = …innerHTML + …
createElement( 'p', 'body content goes here' )
oh, createElement…
Ah, i see
i will try that
Anyone have thoughts on why a simple dom dump won't work (http://pastebin.com/d153c008c) ?
var AddTxt = document.createElement('p','hi'); wont add text to the tag
anyone knows how to know the size of a distant file?
why doesn't this work ? http://rafb.net/p/OHlSHm49.html - can somebody please help me ?
use createTextNode then .. (I could have sworn it did)
createTextNode is what is causing my problems
oh, you need to add the element to the parent body - merely creating it doesn't actually place it in the dom.
document.getElementById( 'parentNode' ).add( document.createElement( '', 'test123' ) )
i do that with div = document.getElementById("questions");
div.appendChild(AddTxt);
How to send 2 responses in AJAX? The first - status of action (e.g. article saved, article not saved, errors to correct, etc.) and the second - code for displaying
responses are sent by PHP (using echo)
it pop ups that page inside the old one through a overlay
why doesn't this work ? http://rafb.net/p/OHlSHm49.html - can somebody please help me ?
what i want to do is that that pop up is always centered, even if i scroll sideways and click the link again
it seems to work only the first time
Meh
i'll just remove the text then
Apologies for all my mistypes - I'm using parentElem.addChild( newElem ) in my code - can't find documentation on it but it is working for me. I do see appendChild so I'll prob. try switching to it at a later point. Do you have example of your current problem w/ current
corrections?
i removed it from the code
but hold on
http://pastebin.parentnode.org/22388
example 1 does work, but badly when u start adding and removing objects
example 2 dosnt work at all
so i just removed the text
i'll make the inputs have the text "input question" when it hasnt been clicked yet instead
If I put function's name as argument (e.g. ABC(functionName) without (), will functionName be called?
probably not
I need to know the size of a remote file to decide if I allow the client to download it or not, any idea ?
parentE = document.getElementById( "parent" ); e = parentE.ownerDocument.createElement( "td" ); e.innerHTML="TEXT"; e.id="myidnumber"; parentE.addChild( e );
the ownerDocument is redundant for your example most likely)
i am very confused
what's the concensus (if there is one) for using yui grids versus rolling your own javascript and css? wouldn't yui include a bunch of bloat?
im new to javascript and all but '//' is comments, right?
progress0r, it would.
I wonder if anyone can read what i'm writing on this chan..
thats what i thought
it wont comment stuff if i use //
../* works
progress0r, the second problem is that using YUI means you learn YUI, not learn javascript
EXACTLY i thought about that also, and looking at yui its pretty comprehensive.
progress0r, it's not that much bloat though and if you have a moderate understanding of javascript yui could lead you to some other stuff
Personally, I like small examples because I'm not that smart to grasp big ones
cool thanks
hi i have a multiple select field. how can i make it pass all the options in the select multiple field when i submit the form? meaning even if they are not selected, i would still get their values ?
basically i have two multiple select box. im doing a add button so that when i choose some field from left sellect box, it'll add to the second dropdown box. but sometimes, they won't all be selected in the second dropdown box. but when i submit the form, it only gives me values for the ones
that are selected. how can i go about this type of problem?
?????????
too many words
Hi. I know how to do a redirect to another URL with jscript..is there a way to redirect to the same page that would be accessed by clicking "Back" ?
STANY à la 1'19 minute: http://youtube.com/watch?v=LBH5CITo-Vk
ahah
javascript:history.go(-1)
hi
Mappypants, that's incorrect
you dont use the javascript-prefix
and window.history.back() would perform the same
where can i find a complete tutorial about javascript ?
alperkanat, http://w3schools.com/js
sorry for my lame but their code samples don't include ; ..? any particular reason for that ?
alperkanat, it is not neccessary
unless you group statements
how can i make that the mouse draws a circle where it is when the user clicks??
hmm my form does not want to submit
hey guys — why doesnt this attribute on the submit tag prevent the form from submitting? onclick="Poll.submit(); return false;"
while onclick="return false;" does
http://www.pastebin.ca/668515 — is that the valid way to dynamically create a form?
The paste 668515 has been copied to http://erxz.com/pb/4148
cause my form does not submit
axolx, because Poll.submit() submits the form, what else would you expect it to do?
submit() there is a function defined on the Poll object
just changed the name to submitt and still does the same
it works fine, so not sure why you say its incorrect
this form thing is driving me nuts
axolx, so Poll is not your form element?
window.location='javascript:history.go(-2)';
no . it's a class
window.history.back() is neater though
eh whatever, i don't feel like guessing what your code looks like
nothing to guess. i put all the info needed on my first question
axolx:
hey guys — why doesnt this attribute on the submit tag prevent the form from submitting? onclick="Poll.submit(); return false;"
where Poll is a custom object with a submit() function defined
oh I figured it out, I didn't append the form to document.body
I'm making a flyout menu where the submenu needs to stay within the page - even when it extends past the page contents height - this way a scrollbar wouldn't appear if a submenu is selected towards the bottom of the page
how would I do that
I'm using prototype to get the height - do I just work with that?
or can I get the "y" position of a non-absolute/fixed element?
what is the best way to make an element invisible
elementReference.style.display = 'none';
k
hi
please
how can i make that the mouse draws where it is when the user clicks??
obyone - clientX and clientY of the event object return the cursor when the event happens
best to use prototype's Event interface to do that
http://prototypejs.org/api/event
otherwise learn about the world of variety with events in different browsers http://www.javascriptkit.com/jsref/event.shtml
have fun
i am new to JS
isn't there somewhere wher someone has published allready a code like this?
I gave you two links… follow one
What is the term for the technique which allows AJAX to recieve data dynamically with the server initiating the sending of data at any given time after a client announces itself?
DigitalisAkujin - it's called comet
ty
np
hihi
is there a print_r equivalent to javascript?
I don't know. What does print_r do?
hey everyone
zfdaily - no, there isn't a print_r equiv injs
hihi rocker
isn't there somewhere wher someone has published allready a code like this?
hey Jan_ you're not hanging out in ##electronics anymore i see =P
print_r is php http://us3.php.net/manual/en/function.print-r.php
OK. What does it do?
it prints out an object
how can i make that the mouse draws where it is when the user clicks?? is there a script done allready??
You mean it returns an object's properties as a string?
yes - sorry Jan_ I was afk
but it returns debug output
like the entire contents of an array
or references to sockets
hmmm, I guess the toString() method does exactly what print_r does
ah, but it wouldn't output the contents of an associative array like print_r does… keys and values
toSource in FF
does that print out keys and values of an object and assoc array?
ok - forgot why I was here… my question!
No, I just like uttering random garbage in the hope you will just type anything into your computer
hey Woosta
that software I wrote is now in use
Excellent!
The very first person to use it was their least technically capable person, and there are a few known issues.
So I was really concerned and expecting a phone call.
I'm trying to get the bottom position of an element from the top page - not the viewport/browser window… I'm using prototype but it's a tad confusing
But it went OK!
what's the software for?
movie playback
oh cool
if anyone here knows prototype - I'm adding the cumulativeOffset to getHeight - would that do it??
how can i reset a multiple dropdown box values ? i just want to reset them all to nothing
do…form..dropbox.value = ""; doesn't seem to do the trick
i need to get them completely off of the dropdown list
If it's a select-multiple, there must be a better way: yourSelect.selectedIndex = 0; yourSelect.options[0].selected = false;
with each dropbox.defaultSelected
If it's just a regular select then yourSelect.selectedIndex = 0;
I mean it's dropbox.option[x].defaultSelected - returns boolean
zfdaily - Woosta selects the first element, mine takes more loops but selects the default selected option… depends on what you want
I wonder if selects have their own .reset() method, or if you can only call that on a form
maybe prototype offers one
dunno
?
basically, i want to remove all options in my select dropbox
how can i do so?
*remove* as in delete?
or just reset the selection the user made?
if you're using Firebug, console.log the object and click on it; if Microsoft Script Editor, use QuickWatch..
like delete it
completely from the select box
hi all
dropbox.options[x] = null;
….I think… it's been a while
basically i have 2 multiple select boxes. one on the left, user picks what he wants to add to the right box. i just have this "reset" button. i just want to know what to run on that reset function
do i loop and then just do dropbox.options[x] = null; ?
so the user is populating their own dropbox
only forms, but options have defaultSelected
yes
is there something like, selectbox2.options = "";
setting the option to null should remove it
which clears all options
no
so i have to loop them?
yes
bleh
why is javascript so ghey when it comes to these simple things
you're looking for a method for the select object that does this for you - it doesn't exist
you could make the method now, and save yourself time later
that'd be best
start small, go big
select.deleteAllOptions
whatever
either way you gotta make it
what is defaultSelected? The index? or true/false on each option?
how about, selectbox2.remove(x);
remove??
woosta - boolean
wtf??
yeah i think thats built in js function
lol, you must be a MS coder
http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109/html.html#ID-33404570
no
im using it and its working
oh, (foot in mouth)
deleteing it completely??
yeah
Is that what we're doing?
kewl, make sure it works outside of ie!
like delete it from face of this planet
I thought we were resetting it!
`empty @ zfdaily
empty: A function to empty a node of content: function empty(node){ while(node.firstChild) node.removeChild( node.firstChild ); return node }
nah, we miscommunicated
yea reset means, delete all the options in the select box
no it doesn't
well, my reset button, thats what it should do
well in bemson world - reset means, reset the selection, but I hear ya now
it's one of the move-between-two-lists things
yes thats correct
ergh .. I hate those
set to null- I never heard of "option.remove()"…
that wont remove the entry though
just get rid of the value
I don't think they should be done with two selects
the [label] would still be there
WTF?
Did you miss the bot telling you about empty above?
"remove Remove an element from the collection of OPTION elements for this SELECT."
deltab - kewl
huh
if it is a move-between-two-lists, you'll want to move them back to the first list, not remove them entirely
no, i dont have to delete it from the left list
left list, remains the same
just point and click to go to the right box
can items be selected more than once?
i am already doing a check so that cant occur
but if you moved the item, it wouldn't even be plausible
with
its not moving
its copying
a class="button" type="submit" name="submit" value="Release" href="#" onclick="this.blur(); return false;"spansometext/span/a
but only once?
yes
why?
what do you mean why?
im copying it
to the right list box
so on the left box, the list always remain the same
it will not change
what are you using this for that's different from how these things are usually used?
it's for teaching students online kind of stuff
what stuff?
thats how the clients want it, so students can always see the left box and study it i guess
if suddenly it dissappears, it will cause havoc
on the student's brains
so we have to leave it alone
only copy to the right box
what happens when something is selected twice?
it wont get added
and?
only adds if its not already in the second box
what feedback is there for why it's not added?
why are we even arguing about this
there is no feed back, just does nothing
because you're breaking a convention of how these are used
but i have no option
its like one of thsoe things, students memorize things in order
if they move from one place to other, they gonna have a hard time memorizing it
so why have two places?
its a way to say the student is comfortable enough with it, like taking notes
this function , is exactly for that purpose, taking notes
how is it used?
every day, they get a new list of vocabularies
they memorize them
at the same time, they can take notes on it, by clicking the vocab, and they get to write out what that definition is
they can keep doing this over and over
until they fully memorize them
and the words they select are copied to the other list where they can add notes to it?
er, to them
yeah
its alot of those things
its got like 5 levels deep
wow
its pretty cool, i wish i had something like this back in school
it really helps you memorize it quickly
its got these memorization study forms, from math all the way to science
now, i just need a simple reset button function that can reset all the things student clicked on
element ?
same way you would any other element
yeah but how
0) { select.remove(0); }
though i still doubt that a select is best for this I'd use a list, I expect
by including it within the element's markup or by attaching it using a loop that searches for that element
do you have more than one element that you want this handler on?
nope
hello, how to get the width of a window that was opened in iframe?
not the frame itself, but the width of the page inside it
and code is executed within this frame
from within*
`js ref
http://developer.mozilla.org/en/docs/JavaScript , http://devedge-temp.mozilla.org/central/javascript/index_en.html , http://phrogz.net/ObjJob/ , JScript@MSDN: http://tinyurl.com/9pk3l , www.crockford.com/javascript/
`js ref width
How would you go about submitting a form with javascript like a button that has a name and a value?
Hi
i want to know ho to open my main page without back buttons and so
hey
Hi
any help
how can i load my main page disabling back and forward buttons ?
You can't, obnoxious control freak.
Jafet++
;
semicolon
and…?
is there a way to reference a child window after the parent window has refreshed or browsed to a different URL?
assign it to a variable and attach an event listener to the parent window for unload or onload
blah=window.open(….);
yeah, 'blah' is what i'd want to persist. What do you mean by an event listener?
the only way i know you can make blah persist is with a hidden frame
that's what I was thinking. Going back to the oldskool frame idea would just make me sad. Seems to be the only want though
an event listener is a function which monitors for an event on an object
a hidden frame where? in the parent window?
how would that help?
onload,onclick,onhover, I get it. I didn't know that's what they were called
a hidden frame would work on browsing, but not refreshing
??attachEvent
..attachevent
What about serializing a JS object and saving it to a cookie?
you can't persist js refs
does something like that exist?
what do you mean?
that's interesting
maybe you could have like a js script that holds the reference somewhere else? i don't know
reminds me of the google maps API
Hi I'm attempting to load a PHP script as the source attribute for an image tag without causing the browser to show the page as loading. Right now I'm simply setting document.imagename.src = 'http://localhost/script.php'; is there another approach with
Javascript?
Will I have to use a XHR?
you can only serialize primitive and basic data types, not references
no, why would you do that?
if i understand you correctly, you don't need XHR
let me show you guys a pastebin
http://paste2.org/p/6336
But when I load that page it show the page as loading
I don't want the status bar to say loading or the icon to move
hmm, oh because the image is loading?
yep
and it can't preload because it's generated by php