Re: php to generate java-script

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



i agree with brian.
i still need to enhance my skills w/ javascirpt, but i think in the case of
validation, a simple
solution is to write generic validation components in javascript.  then
simply dynamically
include the ones you need for a particular form.
as far as the javascript knowing how to locate the form fields i think its a
matter of defining
a naming convention w/in your system.

-nathan

On 8/21/07, brian <phplist@xxxxxxxxxxxxxxx> wrote:
>
> Jas wrote:
> > Anyone have a good method of grabbing the current page and reading data
> > from it?
> >
> > For example:
> > <?PHP
> >  // find all form fields for current page
> >  function FindFormFields( $page ) {
> >   if( empty( $page ) ) {
> >    $data = -1;
> >   } else {
> >    if( ( $fh = @fopen( $page, "r" ) ) === FALSE ) {
> >     $data = -1;
> >    } else {
> >     while( !feof( $fh ) ) {
> >      $line = fgets( $fh, 512 );
> >      if( eregi( "<input type=\"", $line ) ) {
> >       $data[] = $line;
> >      }
> >     }
> >     fclose( $fh );
> >    }
> >   }
> >   return $data;
> >  }
> >
> >  echo FindFormFields( "http://php.net"; );
> > ?>
> >
> > The above code would output the following:
> > Array
> > (
> >     [0] =>    <input type="text" name="pattern" value="" size="30"
> > accesskey="s" />
> >
> >     [1] =>    <input type="image"
> >
> > )
> >
> > Now for the problem I am having and a description of what I am trying to
> > accomplish:
> >
> > I want to dynamically generate a form and in doing so I would like to
> > dynamically generate the following javascript features for said page
> >   - javascript form validation
> >   - javascript form field focus
> >
> > The problem is if I call the current page that is being generated such
> as
> > <?PHP
> > echo FindFormFields( "http://"; . $_SERVER['SERVER_NAME'] .
> > $_SERVER['REQUEST_URI'] );
> > ?>
> >
> > Not only does it take a helluva long time to load the page but it also
> > creates a nested array with duplicate values.
> >
>
> I'm not surprised it's taking a while to load in your browser. I think
> you have a serious nested loop issue there. What you're doing is telling
> the PHP engine to load the same page again. When it does that it's going
> to call your function *again* on the same page. Rinse and repeat.
>
> But i don't understand what putting those tags in an array is going to
> accomplish. Perhaps there's a lot more to this, but i'd be inclined to
> set up my validation in a more targetted manner.
>
> brian
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux