|
Posted by Randy Webb on 08/17/06 03:54
Chris said the following on 8/16/2006 1:48 PM:
> "Randy Webb" <HikksNotAtHome@aol.com> wrote in message
> news:OPidnYDZHIUQzH_ZnZ2dnUVZ_v6dnZ2d@comcast.com...
>> Chris said the following on 8/15/2006 6:12 PM:
>>> "Rik" <luiheidsgoeroe@hotmail.com> wrote in message
>>> news:<8e84e$44e23d2f$8259c69c$14497@news1.tudelft.nl>...
>
>>> I don't understand your statement - "js has absolutely nothing to do with
>>> the PHP which created it".
>> If you don't understand that statement, you need to take a good class on
>> HTTP.
>
> That may be so, but I haven't seen any such classes available at my college,
> and even if there were, I don't have the time to take one now.
It makes no difference to me, but if you knew how it worked you wouldn't
be asking the questions you are asking.
>>> My problem isn't the js - it works okay on a non-php generated form -
>> Yes, your problem is the js. If it works on a "non-php generated form"
>> then it will work on a PHP generated form providing PHP doesn't change the
>> names/ID's.
>>
>
> There may have been an error in it - but if you visit a few sites regarding
> form validation with PHP and JS they show the same essential layout - in
> fact, what I had included was a copy & paste from a tutorial - only changing
> the name of the form element itself.
My point was that whether the HTML file is PHP generated or hard-coded
makes no difference. Open a PHP page, right click>View Source, save it
locally and then you have a static page. The only way that can change is
if PHP dynamically creates ID's or Names.
>>> I have used js to validate html forms in the past with no problem.
>> With just the snippet quoted in the previous post, I find that a dubious
>> claim that I don't believe.
>
> You are just being rude here.
No, that wasn't rude. I can show you what is rude but I would rather
not. It might ruin my image as a nice guy.
>>> The question is how to work with PHP and js together - a commonly asked
>>> question in forums.
>> And you will get two replies to that question:
>>
>> 1) They are unrelated other than being on the opposite ends of a stateless
>> HTTP Connection.
>> 2) Some utter garbage that doesn't resemble the truth.
>>
>
> Please see the following sites:
> http://www.phpdebutant.com/articles/PHP-form-validation.phphttp://www.php-mysql-tutorial.com/form-validation-with-php.phphttp://www.onlamp.com/pub/a/php/2004/04/22/php_css_forms.htmlThese
> are all slightly different approaches, but they all refer to the use of both
> PHP and js being used together to validate forms.I was looking for advice
> for what approach has proven to work best when much of the data in the
> initial form is php-generated (such as populating the list boxes).
And I told you, it doesn't matter if PHP generated the page or not (with
the ID/NAME issue aside) to Javascript. It's irrelevant. You can
validate on the client using Javascript, and then validate again on the
server with PHP but as far as them "working together" that is the only
way they work together is that PHP insures that the JS got it right.
Other than that, it's irrelevant whether PHP "populates a list box"
(whatever a list box is to you, probably a SELECT element) or whether it
was hard coded by hand. You can't seem to get over that.
>>> There are ways to pass the variables back and forth, etc. which I have
>>> used elsewhere in my application.
>> Really? And you don't understand form validation using JS and that PHP has
>> nothing to do with it? Impressive.
>>
>
> Again - very rude. I never said that PHP had anything to do with JS or
> vice-versa - I simply wanted to
> know the best way to use both together to validate a form.
You don't use them together in the sense that they work together. You
use them "together" in the sense of double validation. Nothing more,
nothing less.
>>> But I haven't seen anything regarding form validation when the form is
>>> PHP and the validation is js.
>> That is because JS doesn't know, and doesn't care, what server side
>> language generated it. It's irrelevant.
> Rude again
No, Rude would be me telling you that you are a blithering idiot that
doesn't have a clue.
> <snip>
>>> That's my concern as I know that PHP is server-side and processes before
>>> data goes to the browser. So - how to intercept the data as it goes from
>>> the browser to the server?
>> You use JS and the onsubmit event handler. Once it is submitted, JS can't
>> touch it.
>>
>
> correct - because js is client-side, but I noted that the onsubmit event
> handler didn't find the js function.
Then your JS function wasn't defined properly.
> That is why I even posted my question in the first place.
Nothing wrong with that.
> Our site has a header automatically prepended, therefore, it's very likely
> didn't have the js in the correct spot so that it can be called from the
> very top of the page (within the initial head tags) - perhaps as an
> external js file.
You can't validate a form that doesn't exist yet. And if the validation
is done in a function then it doesn't matter if it is defined first in
the HEAD section or the last thing in the page before the </body> tag.
>>> I'm sure this is a fairly simple process, since there are tons of PHP
>>> forms out there that get validated. Perhaps incorporate the js into the
>>> processing page at the very beginning?
>> Nope.
>>
>>> Does this look like reasonable workable logic?
>> Not even close.
>>
>
> See the above-referenced sites.
And wade through all that crap to try to make your point for you? No thanks.
> It surprises me that some of the people in newsgroups are so rude to those
> of us who are simply asking questions because we don't understand or would
> like further clarification on how to approach something. If we were all php
> or js gurus, we wouldn't be posting questions here. Perhaps I don't
> understand the purpose of a newsgroup - I thought it was to share
> information, not belittle people.
I didn't belittle you, I said I didn't believe you. And, I didn't even
say you were wrong, I said I didn't believe you. Nothing more, nothing
less. And for the record, I still think you are wrong.
Learn to trim/quote properly!
--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Navigation:
[Reply to this message]
|