If you want to capture the output of your current script, toss ob_start() at the top and $data = ob_get_content() at the bottom and then munge it as you will. Though I also think you'd be better off putting the JS validation in-line with the <input tags. On Tue, August 21, 2007 1:32 pm, 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. > > My best guess is that the order in which the page is being generated > has > something to do with the lag as well as the nested array with > duplicate > values. > > Could anyone help me or point me in a better direction for performing > these actions? > > Thanks in advance, > Jas > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php