Visualizzazione dei risultati da 1 a 2 su 2

Discussione: reverse da php ad asp

  1. #1

    reverse da php ad asp

    Salve ragazzi mi affido al vostro buon cuore avrei bisogno di una mano a fare un reverse da php ad asp....premetto che di php non ne so niente o quasi solo che non ho trovato uno script simile in asp....
    VI RINGRAZIO IN ANTICIPO
    vi posto il codice:

    '******************
    example.php
    '******************
    <?php


    // loads AutoFill class
    require_once "class.autofill.php";



    /**
    * starts a new AutoFill object. The parameter
    * must be the "id" attribute of the text field
    * that will display these options
    */
    $AF_Beatles = new AutoFill("beatles");

    // sets the list of options
    $AF_Beatles->addOption("Paul McCartney");
    $AF_Beatles->addOption("John Lennon");
    $AF_Beatles->addOption("George Harrison");
    $AF_Beatles->addOption("Ringo Starr");
    $AF_Beatles->addOption("Paul McDonald");
    $AF_Beatles->addOption("John Lennox");
    $AF_Beatles->addOption("Johnny Walker");
    $AF_Beatles->addOption("Ringo Star");
    $AF_Beatles->addOption("George Hairy Son");
    $AF_Beatles->addOption("Paul Macintosh");
    $AF_Beatles->addOption("George Washington");
    $AF_Beatles->addOption("Ringo Starman");

    // sets the max number of showed options (-1 to no limit)
    $AF_Beatles->setLimit(-1);

    /**
    * sets if the form should be submited if the user select
    * one auto-fill option from the text box (default: false)
    */
    $AF_Beatles->submitOnFill(false);




    $AF_Michaels = new AutoFill("michaels");
    $AF_Michaels->addOption("Michael Jordan");
    $AF_Michaels->addOption("Michael Jackson");
    $AF_Michaels->addOption("Michael Schumacher");
    $AF_Michaels->addOption("Michael Moore");
    $AF_Michaels->addOption("Michael J. Fox");
    $AF_Michaels->addOption("Michael Douglas");
    $AF_Michaels->addOption("Michael Owen");
    $AF_Michaels->addOption("Michael Collins");
    $AF_Michaels->addOption("Michael Myers");
    $AF_Michaels->addOption("Michael Nielsen");
    $AF_Michaels->addOption("Michael Keaton");
    $AF_Michaels->addOption("Michael Smith");
    $AF_Michaels->addOption("Michael Baker");
    $AF_Michaels->setLimit(10);



    $AF_Dwarfs = new AutoFill("dwarfs");
    $AF_Dwarfs->addOption("Doc");
    $AF_Dwarfs->addOption("Happy");
    $AF_Dwarfs->addOption("Bashful");
    $AF_Dwarfs->addOption("Sneezy");
    $AF_Dwarfs->addOption("Sleepy");
    $AF_Dwarfs->addOption("Grumpy");
    $AF_Dwarfs->addOption("Dopey");
    $AF_Dwarfs->submitOnFill();




    ?><html>
    <head>
    <title>Auto-fill for text fields</title>
    <?php

    // creates the javascript code between <head> and </head> tags
    $AF_Beatles->create();
    $AF_Michaels->create();
    $AF_Dwarfs->create();

    ?>
    <style type="text/css">
    body {
    font: 90% Verdana, Arial;
    }
    h1 {
    margin: 0px;
    font: 200% Tahoma, Arial;
    }
    h2 {
    margin: 0px;
    font: 170% Tahoma, Arial;
    }
    hr {
    width: 80%;
    margin: 0px;
    text-align: left;
    color: #aaa;
    }
    .credits {
    font-size: 60%;
    font-weight: normal;
    }


    .autofill-box {
    z-index: 100;
    padding: 1px;
    background: #e5e5e5;
    border: 1px dotted #000;
    text-align: left;
    font: 11px Verdana, Arial, sans-serif;
    }
    .autofill-box li {padding: 2px 7px;}
    .autofill-box .selection {
    background: #AAF;
    color: #FFF;
    }
    </style>
    </head>

    <body>
    <h1>AutoFill <span class="credits">by Carlos Reche</span></h1>
    <hr />




    This is a demonstration of AutoFill class, wich allows
    you to easily create cross-browser auto-fill options to text fields. You
    don't have to worry about the Javascript part. Only create the text field
    and give it an specified "id". Then create the PHP part, wich you can
    learn by seeing the source code of this script.
    </p>

    <form action="" method="get" style="margin: 70px 50px;">




    The name of a Beatle: <input type="text" name="textField_1" id="beatles" />
    (try one of the fab-four)
    </p>
    <hr />



    A Michael that you know: <input type="text" name="textField_2" id="michaels" />
    (this will display a maximum of 10 options)
    </p>
    <hr />



    A dwarf: <input type="text" name="textField_3" id="dwarfs" style="height: 50px;" />
    (even if the field has a custom height, the box is displayed where it should be.
    The form will be submited if the user select on option from this field)

    </p>
    </form>

    </body>
    </html>
    -----------------------------------------------------

  2. #2
    '*************************
    class.autofill.php
    '*************************

    <?php



    /**
    * @class AutoFill
    *
    * automatic fill options for text fields
    *
    * Carlos Reche
    * carlosreche@yahoo.com
    * Feb 14, 2005 - Aug 21, 2005
    */


    class AutoFill {
    var $field_id;
    var $values;
    var $limit;
    var $submit_on_fill;
    var $javascript_loaded;

    function AutoFill($field_id, $values = array(), $limit = 10, $submit_on_fill = false) {
    $this->field_id = (string)$field_id;
    $this->values = (array)$values;
    $this->limit = (int)$limit;
    $this->submit_on_fill = (bool)$submit_on_fill;
    $this->javascript_loaded = false;
    }


    function create($bool_return = false) {
    $var_name = "AutoFill_" . $this->field_id;

    $html = $this->loadJavascript(true);
    $html .= '
    <script type="text/javascript">
    ' . $var_name . ' = new AutoFill("' . $this->field_id . '");
    ' . $var_name . '.setLimit(' . (int)$this->limit . ');
    ' . $var_name . '.submitOnFill(' . ($this->submit_on_fill ? 'true' : 'false') . ');';
    foreach ($this->options as $option)
    $html .= "\n".' ' . $var_name . '.addOption("' . $option . '");';
    $html .= '
    </script>';
    return $this->printHTML($html, $bool_return);
    }


    function addOption($option) {
    $this->options[] = (string)$option;
    }

    function setLimit($limit) {
    $this->limit = (int)$limit;
    }

    function submitOnFill($bool_submit = true) {
    $this->submit_on_fill = (bool)$bool_submit;
    }



    function loadJavascript($bool_return = false) {
    if ($this->javascript_loaded) {
    return;
    }
    $this->javascript_loaded = true;

    $html = '
    <script type="text/javascript">
    /**
    * automatic fill for text fields
    *
    * Carlos Reche
    * carlosreche@yahoo.com
    * Feb 14, 2005 - Aug 21, 2005
    */
    function AutoFill(fieldId) {
    if (!document.customProperties) {
    document.customProperties = [];
    }
    if (!document.customProperties[fieldId]) {
    document.customProperties[fieldId] = {};
    }
    document.customProperties[fieldId].autoFill = {
    field: null,
    list: null,
    options: [],
    limit: 10,
    submitOnFill: false,
    currentSelection: -1
    };
    var autoFill = document.customProperties[fieldId].autoFill;
    this.id = fieldId;
    this.addOption = function(value) {
    autoFill.options.push(value);
    autoFill.options.sort();
    };
    this.setLimit = function(limit) {
    autoFill.limit = limit;
    };
    this.submitOnFill = function(boolSubmit) {
    autoFill.submitOnFill = typeof boolSubmit == "undefined" ? true : boolSubmit;
    };

    if (window.addEventListener) {
    window.addEventListener("load", function() {AutoFill.init(fieldId)}, true);
    } else if (window.attachEvent) {
    window.attachEvent("onload", function() {AutoFill.init(fieldId)});
    }
    }


    AutoFill.init = function(fieldId) {
    var field = document.getElementById(fieldId), autoFill;
    if (!field) {
    throw new Error("element not found");
    }
    field.autoFill = autoFill = document.customProperties[fieldId].autoFill;
    var cont = document.createElement("div"), box = document.createElement("div");
    var list = document.createElement("ul");

    cont.style.display = "inline";
    cont.style.position = "relative";
    field = field.parentNode.replaceChild(cont, field);
    cont.appendChild(field);
    cont.appendChild(box);
    box.appendChild(list);


    field.onkeydown = function(e) {
    if (!e) {
    e = window.event;
    }
    var keyCode = (e.keyCode ? e.keyCode : (e.which ? e.which : 0));
    var autoFill = document.customProperties[this.id].autoFill;
    var list = autoFill.list, current = autoFill.currentSelection;

    if ((keyCode == 38) || (keyCode == 40)) {
    var i = current + (keyCode == 38 ? -1 : 1);
    AutoFill.moveSelectionTo(list, i);
    } else if (keyCode == 13) {
    if ((current > -1) && (current < list.childNodes.length)) {
    var item = list.childNodes.item(current);
    field.nextSibling.hide();
    autoFill.currentSelection = -1;
    if (item.className != "") {
    field.value = item.innerHTML;
    list.clear();
    return false;
    }
    }
    }
    };
    field.onkeyup = function(e) {
    if (!e) {
    e = window.event;
    }
    var keyCode = (e.keyCode ? e.keyCode : (e.which ? e.which : 0));
    var autoFill = document.customProperties[this.id].autoFill;
    var list = autoFill.list, box = list.parentNode;

    if ((keyCode != 38) && (keyCode != 40) && (keyCode != 13)) {
    list.clear();
    if (this.value == "") {
    box.style.display = "none";
    } else {
    var p = this.value.replace(/([\\\|\.\+\*\?\[\^\(\$\)])/gi, "\\$1");
    var pattern = new RegExp(("^"+ p +".+$"), "i"), i = -1, j = 0;
    while (++i < autoFill.options.length) {
    if (autoFill.options[i].match(pattern)) {
    if ((j < autoFill.limit) || (autoFill.limit < 0)) {
    list.addItem(autoFill.options[i], j);
    }
    j++;
    }
    }
    if ((j > autoFill.limit) && (autoFill.limit > -1)) {
    var more = document.createElement("li");
    more.innerHTML = "...";
    list.appendChild(more);
    }
    if (list.childNodes.length > 0) {
    box.show();
    } else {
    box.hide();
    }
    }
    }
    };
    field.onfocus = function() {
    var autoFill = document.customProperties[this.id].autoFill;
    var list = autoFill.list, box = list.parentNode;
    if (list.childNodes.length > 0) {
    box.show();
    }
    };
    field.onblur = function() {
    var box = this.nextSibling;
    setTimeout(function() {box.hide()}, 300);
    };

    box.className = "autofill-box";
    box.style.display = "none";
    box.style.position = "absolute";
    box.style.top = (field.clientHeight + 4) + "px";
    box.style.left = "0";
    box.show = function() {box.style.display = "";};
    box.hide = function() {box.style.display = "none";};

    list.style.margin = "0";
    list.style.padding = "0";
    list.style.listStyle = "none";
    list.clear = function() {
    for (var i = list.childNodes.length - 1; i >= 0; i--) {
    list.removeChild(list.childNodes.item(i));
    }
    };
    list.addItem = function(value, index) {
    var li = document.createElement("li");
    li.className = (index == field.autoFill.currentSelection) ? "selection" : "selectable";
    li.innerHTML = value;
    li.index = index;
    li.style.cursor = "pointer";
    list.appendChild(li);
    li.onclick = function() {
    field.focus();
    field.value = value;
    if (field.autoFill.submitOnFill) {
    field.form.submit();
    }
    };
    li.onmouseover = function() {
    AutoFill.moveSelectionTo(list, li.index);
    };
    li.onmouseout = function() {
    field.autoFill.currentSelection = -1;
    li.className = "selectable";
    };
    };
    field.autoFill.field = field;
    field.autoFill.list = list;
    }


    AutoFill.moveSelectionTo = function(list, index) {
    var autoFill = list.parentNode.previousSibling.autoFill;
    var current = autoFill.currentSelection;

    if ((current > -1) && (current < list.childNodes.length)) {
    var currentItem = list.childNodes.item(current);
    if (currentItem.className != "") {
    currentItem.className = "selectable";
    }
    }
    if (index < 0) {
    autoFill.currentSelection = -1;
    } else if (index >= list.childNodes.length) {
    autoFill.currentSelection = list.childNodes.length;
    if (list.lastChild && (list.lastChild.className == "")) {
    autoFill.currentSelection--;
    }
    } else {
    autoFill.currentSelection = index;
    var item = list.childNodes.item(index);
    if (item.className != "") {
    item.className = "selection";
    }
    }
    }

    </script>';
    return $this->printHTML($html, $bool_return);
    }



    function printHTML($html, $bool_return)
    {
    if ($bool_return)
    return $html;
    echo $html;
    return true;
    }
    }



    ?>

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.