Re: [PHP] Re: How to re-order an array
At 07:53 PM 6/11/2006, jekillen wrote: I force the user to have javascript enabled Oops. Unless you're working IT in a penal colony, I suspect that what you really mean is that you choose to serve broken pages or no content at all to users who don't have JavaScript enabled, whether by choice or network requirement or software availability. It's an interesting decision, excluding browsers with JavaScript turned off. I can see making it in cases of specialty audiences, such as the aforementioned penal colony, customized intranets, and others where all of the user agents are not only predictable but legislatable. For public websites, I feel we need to set barriers to entrance only when necessary -- and when is that? -- consciously and deliberately, focusing not so much on Look at the cool things we can do with JavaScript! but Whom shall we exclude from this site? Look a user in the eye, say, You can't come in, and reflect on how cool that is. Although I still love to write client-side script, most of the energy I used to expend on JavaScript I now devote to PHP. The server is the great leveler of the playing field, rendering our pages accessible to all user agents *if* our designs are sufficiently clever. These days I mostly add JavaScript to perform functions that are already performed server-side by PHP, purely for the advantage of speed, but my best pages perform perfectly with JavaScript turned off. Aside, the whole client-side/server-side debate depends on today's internet connection response time being as slow as it is. In a few years a seemingly sexy technology like Ajax, which appears useful today in pages so heavy with content that whole-page reloads seem onerous, will be one of the unbelievable jokes of yesteryear, like RAM measured in kilobytes, 8 floppy discs, and punch cards. Regards, Paul -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: How to re-order an array
At 11:26 PM -0700 6/12/06, Paul Novitski wrote: Aside, the whole client-side/server-side debate depends on today's internet connection response time being as slow as it is. In a few years a seemingly sexy technology like Ajax, which appears useful today in pages so heavy with content that whole-page reloads seem onerous, will be one of the unbelievable jokes of yesteryear, like RAM measured in kilobytes, 8 floppy discs, and punch cards. Now, there's the way to think ! Don't confine yourself to the limitations of today, but rather open to the expectations of tomorrow. tedd -- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: How to re-order an array
jekillen wrote: [···] Well, I asked you for the actual (JS) code you're using (the one that didn't work in all the intended browsers), that way someone might be able to help you (I will if I can) Array.push(), Array.pop(), Array.shift(), Array.unshift(). Ok, so what are your intended browsers? According to what I found, these functions are part of ECMAS 3 standard, and are available in FF 1.0, Netscape 4, e IE 5.5 (unshift until IE 6) --as always, M$ gives the problems. You might try to implement them yourself, such as... // object detection for shift function if ( undefined == Array.prototype.shift ) { Array.prototype.shift = function( ) { var val = this[0]; for ( var i = 0; i this.length - 1; i ++ ) { this[i] = this[i + 1]; } this.length --; return val; } // shift() } // object detection for unshift function if ( undefined == Array.prototype.unshift ) { Array.prototype.unshift = function( ) { var args = arguments, len = this.length + args.length; this.length = len; for ( var i = len - 1; i = args.length; i -- ) { this[i] = this[i - args.length]; } for ( i = 0; i args.length; i ++ ) { this[i] = args[i]; } } // unshift() } var x = new Array( 'z', 'b', 'c', 'd' ), y = null; document.write(rarr; + x.toString() +br /\n); y = x.shift(); x.unshift('A', 'a'); document.write(rArr; + y + rArr; [+ x.toString() +]); Note: tested only in Fx 1.5.0.3 (as _shift _unshift) with secuential arrays (and not associative/hash arrays) I thought that if I used Ajax, php could use its push and pop, shift and unshift functions, but not all browsers support the asymetric requests. Well, that seems too complex to solve your problem, but if you want to try it, you may use the same object detection above and implement those methods with PHP (e.g. unshift in IE 5.5, or all of the functions you mentioned in IE 5.0) I do screen in the server. But I force the user to have javascript enabled and force the form to submit using javascipt, and have a unique id as a javascript variable that is sent along with the form in a hidden field to identify the source of the form data. I never use get requests unless they are appended to anchor tags, even in forms that are not processed by the server (I.E. running javascript code with user supplied arguments to functions via form fields, in which case an action attribute isn't even necessary, and like wise a post or get method). It's basically the same problem, you shouldn't rely on javascript for your page to actually do something. If I don't have JS enabled (for whatever the reason) I won't be able to do anything on it. JS should be used only to _add or complement_ functionality. -- Atentamente / Sincerely, J. Rafael Salazar Magaña -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: How to re-order an array
jekillen wrote: [···] You misunderstand my question. I know the limitations of javascript. The server won't respond to events registered in the browser. I write tons of forms that are all processed by the client with javascript. I have written ferocious regex filters that hack apart form submissions before they even leave the client. I have set it up so if the client doesn't have javascript enabled, the form won't submit if it is going to the server. That is why as much as possible I shift form processing to the client as much as possible, for security and to off load work to the client. I use php to dynamically write js files when necessary, anticipating what data will be requested. I didn't (misunderstood), what I told you is that you cannot rely on javascript (actually, that would be anything coming from the client) You need to do validate on the server, and it doesn't matter if you already did it on the client or not (simply because you cannot know that for sure) This is a problem that is more a matter of programming theory. I have posted to javascript forums and lists and have never got a response. I will be applying this to dhtml which the server won't and can't do but may help things along with Ajax. Just a simple suggestion about how to reorder arrays if you have a few words and suggestions. I'm not looking for free training. I have been learning and using php and javascript for some five years and have developed my own approach to testing and debugging and such. So I am not really a newby. I have made the dumb mistakes of asking for help from forums and lists when it was just a dumb syntax error that I couldn't expect anyone but my self to find, which i have in 99.9% of the cases. Some times it is nice to get some quick help from a list and I will try to return the favor when ever possible to the next person looking for help that I have some answers for. Well, I asked you for the actual (JS) code you're using (the one that didn't work in all the intended browsers), that way someone might be able to help you (I will if I can) -- Atentamente / Sincerely, J. Rafael Salazar Magaña -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: How to re-order an array
On Jun 11, 2006, at 1:21 PM, Rafael wrote: jekillen wrote: [···] You misunderstand my question. I know the limitations of javascript. The server won't respond to events registered in the browser. I write tons of forms that are all processed by the client with javascript. I have written ferocious regex filters that hack apart form submissions before they even leave the client. I have set it up so if the client doesn't have javascript enabled, the form won't submit if it is going to the server. That is why as much as possible I shift form processing to the client as much as possible, for security and to off load work to the client. I use php to dynamically write js files when necessary, anticipating what data will be requested. I didn't (misunderstood), what I told you is that you cannot rely on javascript (actually, that would be anything coming from the client) You need to do validate on the server, and it doesn't matter if you already did it on the client or not (simply because you cannot know that for sure) This is a problem that is more a matter of programming theory. I have posted to javascript forums and lists and have never got a response. I will be applying this to dhtml which the server won't and can't do but may help things along with Ajax. Just a simple suggestion about how to reorder arrays if you have a few words and suggestions. I'm not looking for free training. I have been learning and using php and javascript for some five years and have developed my own approach to testing and debugging and such. So I am not really a newby. I have made the dumb mistakes of asking for help from forums and lists when it was just a dumb syntax error that I couldn't expect anyone but my self to find, which i have in 99.9% of the cases. Some times it is nice to get some quick help from a list and I will try to return the favor when ever possible to the next person looking for help that I have some answers for. Well, I asked you for the actual (JS) code you're using (the one that didn't work in all the intended browsers), that way someone might be able to help you (I will if I can) Array.push(), Array.pop(), Array.shift(), Array.unshift(). I thought that if I used Ajax, php could use its push and pop, shift and unshift functions, but not all browsers support the asymetric requests. I do screen in the server. But I force the user to have javascript enabled and force the form to submit using javascipt, and have a unique id as a javascript variable that is sent along with the form in a hidden field to identify the source of the form data. I never use get requests unless they are appended to anchor tags, even in forms that are not processed by the server (I.E. running javascript code with user supplied arguments to functions via form fields, in which case an action attribute isn't even necessary, and like wise a post or get method). JK -- Atentamente / Sincerely, J. Rafael Salazar Magaña -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: How to re-order an array
On Jun 10, 2006, at 5:32 PM, Rafael wrote: Since you asked for some theory... theorically, you won't rely on javascript to prepare/validate/whatever some data to the server, that's what server-side scripts are for. Note: you may use JS to make things quicker if possible, or to pre-digest the data, but you shall not rely entirely on JS. You misunderstand my question. I know the limitations of javascript. The server won't respond to events registered in the browser. I write tons of forms that are all processed by the client with javascript. I have written ferocious regex filters that hack apart form submissions before they even leave the client. I have set it up so if the client doesn't have javascript enabled, the form won't submit if it is going to the server. That is why as much as possible I shift form processing to the client as much as possible, for security and to off load work to the client. I use php to dynamically write js files when necessary, anticipating what data will be requested. This is a problem that is more a matter of programming theory. I have posted to javascript forums and lists and have never got a response. I will be applying this to dhtml which the server won't and can't do but may help things along with Ajax. Just a simple suggestion about how to reorder arrays if you have a few words and suggestions. I'm not looking for free training. I have been learning and using php and javascript for some five years and have developed my own approach to testing and debugging and such. So I am not really a newby. I have made the dumb mistakes of asking for help from forums and lists when it was just a dumb syntax error that I couldn't expect anyone but my self to find, which i have in 99.9% of the cases. Some times it is nice to get some quick help from a list and I will try to return the favor when ever possible to the next person looking for help that I have some answers for. You say that not all browsers support the javascript functions you pretend 'scuse me, did i pretend to use something?? to use, and that not all them support Ajax either. That sounds just like saying that not all browser will have javascript enabled --that's why you shouldn't rely on javascript Although, this isn't a javascript list, why don't you send whatever you were trying to solve this issue? the code that uses JS functions not supported for all the browsers that will potentially run the script (as well as what these browsers are) Most likely someone will be able to help you this way. Thanks for the attitude. jk jekillen wrote: Hello; i'm scratching my head with a difficulty. The situation is this. A script begins with one indexed array (not associative) and one other indexed array with the same values in a different order, the final order. I want to create an interim array and progressively re order the array until it matches slot for slot one of the original arrays. At this point the script is considered completed. One important factor is that I'm looking to write this in javascript and the interim array will be altered by the actions of a web page user. Why am I asking the php list? Because I have a better chance of getting an answer here. I'm not looking for help with javascript, specifically, just how one would go about this task. Answer with php code and some theory if you wish and I will try to translate it into javascript. Some javascript functions I might use aren't supported in all the browsers that will potentially run the script. I might resort to using Ajax and let php keep track for me. But, then again not all browsers will do the Ajax either (as I understand it). -- Atentamente / Sincerely, J. Rafael Salazar Magaña -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: How to re-order an array
On Saturday 10 June 2006 21:08, jekillen wrote: You misunderstand my question. I know the limitations of javascript. The server won't respond to events registered in the browser. I write tons of forms that are all processed by the client with javascript. I have written ferocious regex filters that hack apart form submissions before they even leave the client. I have set it up so if the client doesn't have javascript enabled, the form won't submit if it is going to the server. That is why as much as possible I shift form processing to the client as much as possible, for security and to off load work to the client. I use php to dynamically write js files when necessary, anticipating what data will be requested. ...shift form processing to the client as much as possible, for security... Client-side security isn't. Your server has no way of telling if the data it's receiving is from a properly setup client that did the correct JS filtering, or if it's from someone writing as simple bot/script/program that's just sending GET and POST requests to you. Your PHP should never trust the client to be benign. -- Larry Garfield AIM: LOLG42 [EMAIL PROTECTED] ICQ: 6817012 If nature has made any one thing less susceptible than all others of exclusive property, it is the action of the thinking power called an idea, which an individual may exclusively possess as long as he keeps it to himself; but the moment it is divulged, it forces itself into the possession of every one, and the receiver cannot dispossess himself of it. -- Thomas Jefferson -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php