|  | Posted by Randy Webb on 08/15/06 22:59 
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>...
 >> Well, if you're having a problem with the javascript, post in
 >> comp.lang.javascript,
 >> js has absolutely nothing to do with the PHP which created it. Judging by
 >> your code:
 >
 > 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.
 
 > 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.
 
 > 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.
 
 >  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.
 
 > 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.
 
 > 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.
 
 <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.
 
 > 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.
 
 > //check that form has been submitted
 > if (isset($_POST['uploadfile'])) { //begin check for submission
 > Validate form elements and show js alerts here (how to redirect user back to
 > form and elements for revisions? Maybe I should keep the processing on the
 > same page as the code.
 > //check if file uploaded
 > if (isset($_FILES['fileupload']['name'])) { // begin check for uploaded file
 > What to do if form is valid:
 > 1.create path and move temp file to permanent location
 > 2.insert data into db
 > 3.display success page
 > }else{
 > File not uploaded - try again!
 > }
 > } else { //end submission and validation check
 > Show form
 > }
 > Does this look like reasonable workable logic?
 
 Not even close.
 
 --
 Randy
 comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
 Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
  Navigation: [Reply to this message] |