|
Anonymní Profil * |
#1 · Zasláno: 3. 11. 2004, 16:16:34
ahoj all
ako urobit, ked chcem aby sa po kliknuti na obrazok ahoj.jpg ktory je vedla textarea vlozil do textarea name="meno" text "AHOJ" ??? diky
|
|
|
habendorf Profil |
#2 · Zasláno: 3. 11. 2004, 17:54:50
Tohle by mělo fungovat:
<textarea name="meno" id="idecko" value=""></textarea>
<a href="#" onclick="document.getElementById('idecko').value='ahoj'"><IMG SRC="ahoj.jpg"></a>
|
|
|
habendorf Profil |
#3 · Zasláno: 3. 11. 2004, 18:00:39 · Upravil/a: habendorf
A takhle to bude ještě lepší, hned to dá focus:
<textarea name="meno" id="idecko" value=""></textarea>
<a href="#" onclick="document.getElementById('idecko').focus(); document.getElementById('idecko').value='ahoj'">
<IMG SRC="ahoj.jpg">
</a>
|
|
|
Anonymní Profil * |
#4 · Zasláno: 3. 11. 2004, 21:00:29
ale mne to potom vymaže text !? a chcel som, aby sa to vkladalo normalne za text
|
|
|
pyty Profil |
#5 · Zasláno: 3. 11. 2004, 21:08:32
<script type="text/javascript">
<!--
function insert(what)
{
if (document.forms['form_name'].elements['textarea_name'].createTextRange )
{
document.forms['form_name'].elements['textarea_name'].focus();
document.selection.createRange().duplicate().text = what;
}
else if ((typeof document.forms['form_name'].elements['textarea_name'].selectionStart) != 'undefined') // for Mozilla
{
var tarea = document.forms['form_name'].elements['textarea_name'];
var selEnd = tarea.selectionEnd;
var txtLen = tarea.value.length;
var txtbefore = tarea.value.substring(0,selEnd);
var txtafter = tarea.value.substring(selEnd, txtLen);
var oldScrollTop = tarea.scrollTop;
tarea.value = txtbefore + what + txtafter;
tarea.selectionStart = txtbefore.length + what.length;
tarea.selectionEnd = txtbefore.length + what.length;
tarea.scrollTop = oldScrollTop;
tarea.focus();
}
else
{
document.forms['form_name'].elements['textarea_name'].value += what;
document.forms['form_name'].elements['textarea_name'].focus();
}
}
//-->
</script>
<form id="form_name" .....>
<textarea id="textarea_name">
</textarea>
</form>
<img src="img/21.gif" alt="" width="12" height="12" onclick="insert('**21');" style="cursor: hand; cursor: pointer" />
|
|
|
habendorf Profil |
#6 · Zasláno: 3. 11. 2004, 22:20:42
Pyty: Zdá se mi to trochu zbytečně složitý.
Anonymní: Myslel jsem, že tím ahoj se bude začínat. Stačí ale dopsat jedno plus:
<textarea name="meno" id="idecko" value=""></textarea>
<a href="#" onclick="document.getElementById('idecko').value+='ahoj'"><IMG SRC="ahoj.jpg"></a>
|
|
|
pyty Profil |
#7 · Zasláno: 4. 11. 2004, 19:36:03
a ked to chces pre viac veci jednoduchsie posluzi funkcia v hlavicke :
<script type="text/javascript">
<!--
function vloz(co)
{ document.getElementById('idecko').value += co; }
//-->
</script>
a obsah:
<textarea id="idecko"></textarea>
<input type="button" value="ahoj" onclick="vloz('Ahoj');">
<input type="button" value="Iny text" onclick="vloz('Iny text');">
<input type="button" value="Uplne iny text" onclick="vloz('Uplne iny text');">
|
|