Visualizzazione dei risultati da 1 a 3 su 3
  1. #1

    [php+javascript] vbcode in array

    ciao a tutti sto realizzando questo file php:

    Codice PHP:
                    <script language="Javascript" src="vbcode.js"></script>
                    <script language="Javascript" src="vbcode_language.js"></script>
                <?php
                    
    for( $i=1$i<=10$i++){
                    
    ?>
                        <fieldset>
                            <legend>Paragrafo <?php echo $i?></legend>
                            <div class="vbcode_btn">
                                <input class="bginput" value="B" onclick="vbcode(this.form,'B','')" onmouseover="stat('b')" title="BOLD (alt+b)" accesskey="b" type="button">
                                <input class="bginput" value="http://" title="inserisci un link" onclick="namedlink(this.form,'URL')" onmouseover="stat('url')" type="button">
                                <input class="bginput" value="@" title="inserisci un indirizzo mail" onclick="namedlink(this.form,'EMAIL')" onmouseover="stat('email')" type="button">
                                <input class="bginput" value="List" title="inserisci un elenco" accesskey="l" onclick="dolist(this.form)" onmouseover="stat('list')" type="button">
                                <label for="testo_it[<?php echo $i?>">testo it:</label><textarea name="testo_it[<?php echo $i?>]"></textarea>
                            </div>
                            <div class="vbcode_btn">
                                <input class="bginput" value="B" onclick="vbcode(this.form,'B','')" onmouseover="stat('b')" title="BOLD (alt+b)" accesskey="b" type="button">
                                <input class="bginput" value="http://" title="inserisci un link" onclick="namedlink(this.form,'URL')" onmouseover="stat('url')" type="button">
                                <input class="bginput" value="@" title="inserisci un indirizzo mail" onclick="namedlink(this.form,'EMAIL')" onmouseover="stat('email')" type="button">
                                <input class="bginput" value="List" title="inserisci un elenco" accesskey="l" onclick="dolist(this.form)" onmouseover="stat('list')" type="button">
                                <label for="testo_en[<?php echo $i?>">testo en:</label><textarea name="testo_en[<?php echo $i?>]"></textarea>
                            </div>
                        </fieldset>
                    <?php
                    
    }
                
    ?>
    praticamente creo dinamicamente per 10 un 2 textarea (testo in ITALIANO e INGLESE).

    il mio problema è però nel javascript. Già ho avuto problemi con le 2 sole lingue (ho replicato nel file i comandi javacript cambiando il focus (da testo_it a testo_en)...

    vorrei una soluzione (se possibile, ovvio...) un po' più dinamica... è possibile?

    il javascript è questo (metto solo la parte in inglese, se serve posto tutto il codice)
    codice:
    AddTxt_en = "";
    function getActiveText(selectedtext) {
            text = (document.all) ? document.selection.createRange().text : document.getSelection();
            if (selectedtext.createTextRange) {
                selectedtext.caretPos = document.selection.createRange().duplicate();
            }
            return true;
    }
    
    function AddText_en(NewCode,theform) {
            if (theform.testo_it.createTextRange && theform.testo_en.caretPos) {
                    var caretPos = theform.testo_en.caretPos;
                    caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? NewCode + ' ' : NewCode;
            } else {
                    theform.testo_en.value+=NewCode;
            }
            setfocus(theform);
            AddTxt_en = "";
    }
    
    function vbcode_en(theform,vbcode,prompttext) {
            if ((normalmode(theform)) || (vbcode=="IMG")) {
                    if (text) { var dtext=text; } else { var dtext=prompttext; }
                    inserttext = prompt(tag_prompt+"\n["+vbcode+"]xxx[/"+vbcode+"]",dtext);
                    if ((inserttext != null) && (inserttext != ""))
                            AddTxt_en = "["+vbcode+"]"+inserttext+"[/"+vbcode+"] ";
                            AddText_en(AddTxt_en,theform);
    
                    }
            else {
                    donotinsert = false;
                    for (i = 0; i < tags.length; i++) {
                            if (tags[i] == vbcode)
                                    donotinsert = true;
                            }
                    if (donotinsert)
                            stat("already_open");
                    else {
                            arraypush(tags,vbcode);
                            AddTxt_en = "["+vbcode+"]";
                            AddText_en(AddTxt_en,theform);
                            }
                    }
            theform.testo_en.focus();
    }
    function namedlink_en(theform,thetype) {
            if (text) { var dtext=text; } else { var dtext=""; }
            linktext = prompt(link_text_prompt,dtext);
                    var prompttext;
                    if (thetype == "URL") {
                            prompt_text = link_url_prompt;
                            prompt_contents = "http://";
                            }
                    else {
                            prompt_text = link_email_prompt;
                            prompt_contents = "";
                            }
            linkurl = prompt(prompt_text,prompt_contents);
            if ((linkurl != null) && (linkurl != "")) {
                    if ((linktext != null) && (linktext != "")) {
                            AddTxt_en = "["+thetype+"="+linkurl+"]"+linktext+"[/"+thetype+"] ";
                            AddText_en(AddTxt_en,theform);
    
                            }
                    else{
                            AddTxt_en = "["+thetype+"]"+linkurl+"[/"+thetype+"] ";
                            AddText_en(AddTxt_en,theform);
    
                    }
            }
    }
    
    // *******************************************************
    
    function dolist_en(theform) {
            listtype = prompt(list_type_prompt, "");
            if ((listtype == "a") || (listtype == "1")) {
                    thelist = "[list="+listtype+"]";
                    listend = "[/list="+listtype+"] ";
                    }
            else {
                    thelist = "
    • "; listend = "
    "; } listentry = "initial"; while ((listentry != "") && (listentry != null)) { listentry = prompt(list_item_prompt, ""); if ((listentry != "") && (listentry != null)) thelist = thelist+"[*]"+listentry+""; } AddTxt_en = thelist+listend; AddText_en(AddTxt_en,theform); } // *******************************************************
    hasta siempre comandante Guevara!

    bisogna prendere la vita come viene...sperando che la vita non "prenda" te!!!

  2. #2
    up?? nessuno?
    hasta siempre comandante Guevara!

    bisogna prendere la vita come viene...sperando che la vita non "prenda" te!!!

  3. #3
    up...
    hasta siempre comandante Guevara!

    bisogna prendere la vita come viene...sperando che la vita non "prenda" te!!!

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.