<script type="text/javascript">
function search(){
  alert();
}
</script>
<input type="button" onclick="search()" name="test" value="test" />

Note that I've dropped the <!-- --> thing (that's not valid in modern
doctypes, and not necessary any longer), dropped the "language"
attribute of the script tag, and put quotes around the type attribute.

Then, if you want to use Ajax.Request, you would combine your
onSuccess and onComplete functions (you don't want to run your
onComplete code if something failed) into something along these lines:

        onSuccess: function (transport){
          new Effect.Fade('load',{duration:0.3});
          new Effect.Appear('mainBox',{duration:0.1,queue: 'end'});
          $('searchButtonRif').enable();
          $('searchButtonCity').enable();

          $('mainBox').update(transport.responseText);
        }

Element.update()[1] will automatically process the scripts in the
content for you.  Caveat: I don't know anything about
script.aculo.us's Fade and Appear effects, but I'm guessing they don't
actually remove the element in question, so I think the above would be
okay.

Instead, though, you might consider using Ajax.Updater[2].  If you do
that, your Ajax.Request gets replaced with something looking a bit
like this:

    new Ajax.Updater('mainBox', url, {
        method: 'post',
        parameters:  pars,
        evalScripts: true,
        onSuccess: function(transport) {

          new Effect.Fade('load',{duration:0.3});
          new Effect.Appear('mainBox',{duration:0.1,queue: 'end'});
          $('searchButtonRif').enable();
          $('searchButtonCity').enable();
        }
    );

...because Ajax.Updater updates the element for you and (if you say
evalScripts: true) also runs the scripts.

I haven't actually run the code above, so watch for typos, but that's
the general idea.

HTH,
--
T.J. Crowder
tj / crowder software / com

[1] http://prototypejs.org/api/element/update
[2] http://prototypejs.org/api/ajax/updater

On Oct 25, 9:33 am, trinkity <[EMAIL PROTECTED]> wrote:
> Hy all
>
> I want send from server one button and one script js
> The client must be enable at use this button.
>
> I've this function js
>
> function findCity(){
>    if ($('selectCity').value == ''){
>        $('msgCity').update("{$findError['empty']}");
>        $('msgRif').update('');
>    }
>    else{
>     var url = '{$mainurl2}/search/findCity.php';
>     var mainBox = $('mainBox');
>     var pars = 'city='+$('selectCity').value+'&Submit=Search';
>     clean();
>     new Ajax.Request(url, {
>         method: 'post',
>         parameters:  pars,
>         onSuccess: function(transport) {
>
>           new Effect.Fade('load',{duration:0.3});
>           new Effect.Appear('mainBox',{duration:0.1,queue: 'end'});
>           $('searchButtonRif').enable();
>           $('searchButtonCity').enable();
>         },
>         onComplete: function (transport){
>              var json = transport.responseText.evalJSON(true);
>               Element.insert(mainBox,{top: json[0].script});
>               mainBox.innerHTML=json[0].button;
>         }
>      });
>    }
>
> ----------------------
> findCity.php
> ----------------------
> code PHP:
>
> $scriptino[] = array('status'=>"<script language=JavaScript type=text/
> javascript>
> <!--
> function search(){
>   alert();} --> </script>
>
> ",'button'=>'
> <input type="button" onclick="search()" name="test" value="test" />');
>     header('Content-type: application/x-json');
>     echo json_encode($scriptino);
>
> why into code html i view the button but the <script>code</script> no?
>
> FireBug on firefox say that function not found
> Why?
> I need your help.
>
> p.s.
> Sorry for my english... :(
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---