Autor | Zpráva | ||
---|---|---|---|
fmedic Profil * |
#1 · Zasláno: 30. 3. 2010, 20:43:55
Zdravím,
tady v diskuzi jsem našel tento kód: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html lang="cs"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <meta name="description" content="doplnit"> <meta name="keywords" content="doplnit"> <meta name="author" content="Ondřej Záruba"> <link rel="stylesheet" type="text/css" href="style.css"> <script type="text/javascript" src="js/js_insert.js"></script> <title>doplnit</title> </head> <body> <div id="tu"></div> <form name="frm" onsubmit="return false"> <a href="#" onClick="bbCode('b', true)">B</a> | <a href="#" onClick="bbCode('i', true)">I</a> | <a href="#" onClick="bbCode('u', true)">U</a> | <a href="#" onClick="bbCode('h1', true)">H1</a> | <a href="#" onClick="bbCode('h2', true)">H2</a> | <a href="#" onClick="bbCode('h3', true)">H3</a> | <a href="#" onClick="bbCode('h4', true)">H4</a> | <a href="#" onClick="bbCode('h5', true)">H5</a> | <a href="#" onClick="bbCode('h6', true)">H6</a> | <a href="#" onClick="bbCode('hr', false)">HR</a> | <a href="#" onClick="bbCode('url', true)">URL</a> | <a href="#" onClick="bbCode('img', true)">IMG</a> | <br> <textarea name="text" cols="100" rows="15" tabindex="2"></textarea> <button onclick="document.getElementById('tu').innerHTML = document.frm.text.value;">POšli</button> </form> </body> </html> /* ============================= * * === Definování proměnných === * * ============================= */ var startTag; var endTag; var bb; var inText; var predText; var zaText; var enter; /* ======================= * * === vložení BB kódu === * * ======================= */ function bbCode(tag, parovy){ var textarea = document.frm.text; if (typeof textarea.selectionStart != 'undefined') { //vse mimo IE var selection = textarea.value.substring(textarea.selectionStart, textarea.selectionEnd); var stringStart = textarea.selectionStart; var stringEnd = textarea.selectionEnd; predText = textarea.value.substring(0,stringStart); var konec = document.frm.text.value.length; zaText = textarea.value.substring(stringEnd, konec); } else if (typeof document.selection != 'undefined') { //IE var selection = document.selection.createRange().text; } else { //alert('Bug!'); } if(parovy == true){ startTag = '<' + tag + '>'; endTag = '</' + tag + '>'; inText = selection; bb = predText + startTag + inText + endTag + zaText; }else if(parovy == false){ startTag = '<' + tag + '>'; endTag = ''; enter = '\n' textarea.focus(); } /* === Nastavení speciálních tagů === */ if(tag == 'url'){ if(inText == false){ inText = 'Odkaz'; }else{ inText = selection; } startTag = '<a href="http://www.example.com">'; endTag = '</a>'; } if(tag == 'img'){ if(inText == false){ inText = 'http://www.adresa-obrazku.cz/obrazek.jpg'; }else{ inText = selection; } startTag = '<img src="'; endTag = '">'; } bb = predText + startTag + inText + endTag + zaText; document.frm.text.value = bb; } ale mám problém s odesíláním obsahu textarey "text". "To", co tam je, funguje (obsah se upravený odešle do <div id='tu'>, ale já potřebuju, aby se normálně poslal metodou "post", aby s ním mohlo dále fungovat PHP... Prosím o rady, díky... |
||
_es Profil |
#2 · Zasláno: 30. 3. 2010, 21:44:20
fmedic:
„potřebuju, aby se normálně poslal metodou "post"“ Atribút onsubmit je nastavený tak, aby pri zapnutom JS nešlo formulár odoslať, takže potrebuješ, okrem iných vecí, ten atribút vymazať. |
||
fmedic Profil * |
#3 · Zasláno: 31. 3. 2010, 11:35:25
Mohl by mi teda někdo poradit, jak to upravit tak, aby to fungovalo?
|
||
_es Profil |
#4 · Zasláno: 31. 3. 2010, 13:57:19
|
||
Časová prodleva: 14 let
|
0