|
|
|
สอบถามเรื่องคลุมข้อความใน textarea หลังจากกด submit ครับ |
|
|
|
|
|
|
|
Code (PHP)
<!doctype html>
<html lang="en">
<head>
<title>calculate number</title>
<meta charset="utf-8">
<div class="container">
<textarea name="text2" id="text2" rows="4" cols="100" onClick="return fieldtoclipboard.copyfield(event, this)">TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST </textarea>
<br/><a href="#" class="control-copytextarea" onClick="return fieldtoclipboard.copyfield(event, 'text2')">Select All & Copy</a>
</div>
<script type="text/javascript">
var fieldtoclipboard = {
tooltipobj: null,
hidetooltiptimer: null,
createtooltip:function(){
var tooltip = document.createElement('div')
tooltip.style.cssText =
'position:absolute; background:black; color:white; padding:4px;z-index:10000;'
+ 'border-radius:3px; font-size:12px;box-shadow:3px 3px 3px rgba(0,0,0,.4);'
+ 'opacity:0;transition:opacity 0.3s'
tooltip.innerHTML = 'Copied!'
this.tooltipobj = tooltip
document.body.appendChild(tooltip)
},
showtooltip:function(e){
var evt = e || event
clearTimeout(this.hidetooltiptimer)
this.tooltipobj.style.left = evt.pageX - 10 + 'px'
this.tooltipobj.style.top = evt.pageY + 15 + 'px'
this.tooltipobj.style.opacity = 1
this.hidetooltiptimer = setTimeout(function(){
fieldtoclipboard.tooltipobj.style.opacity = 0
}, 700)
},
selectelement:function(el){
var range = document.createRange()
range.selectNodeContents(el)
var selection = window.getSelection()
selection.removeAllRanges()
selection.addRange(range)
},
copyfield:function(e, fieldref, callback){
var field = (typeof fieldref == 'string')? document.getElementById(fieldref) : fieldref
callbackref = callback || function(){}
if (/(textarea)|(input)/i.test(field) && field.setSelectionRange){
field.focus()
field.setSelectionRange(0, field.value.length)
}
else if (field && document.createRange){
this.selectelement(field)
}
else if (field == null){
field = {value:null}
}
var copysuccess
try{
copysuccess = document.execCommand("copy")
}catch(e){
copysuccess = false
}
if (copysuccess){
if (e){
this.showtooltip(e)
}
callbackref(field.value || window.getSelection().toString())
}
return false
},
init:function(){
this.createtooltip()
}
}
fieldtoclipboard.init()
</script>
</body>
</html>
|
|
|
|
|
Date :
2016-08-09 17:58:48 |
By :
fossil31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Thanks คร๊าบ
|
|
|
|
|
Date :
2016-08-09 21:21:43 |
By :
sabaitip |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 00
|