View Single Post
ישן 27-04-11, 17:05   # 6
morsrh
חבר מתקדם
 
morsrh's Avatar
 
מיני פרופיל
תאריך הצטרפות: Feb 2010
מיקום: אשקלון.
גיל: 31
הודעות: 444
שלח הודעה באמצעות MSN אל morsrh

morsrh לא מחובר  

תודה עומר אבל זה לא בדיוק מה שאני מחפש ,
הקוד שהבאתי למעלה מחליף גם מה שמסומן אם מסומן וזה כעיקרון חלק ממה שאני מחפש אבל תודה בכל מקרה.

אני עדיין לא מבין מה הבעיה פה :

ציטוט:
נכתב במקור על ידי IXCESE צפה בהודעה
תודה רבה יגאל , נחמד שאתה תמיד עוזר

מה שהבאת לי היה מצויין וזה בדיוק מה שחיפשתי רק שעשיתי לזה שינוי קטן אז זה לא כל כך עובד משום סיבה ,

זה הקוד האורגינל :
HTML קוד:
z<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
	<title>Extended functionaly for textelements</title>
	<script type="text/javascript">
		function insertAtCaret(obj, text) { 
	    if(document.selection) {
		obj.focus(); 
	        var orig = obj.value.replace(/\r\n/g, "\n"); 
	        var range = document.selection.createRange(); 
	 
	        if(range.parentElement() != obj) { 
            return false; 
        } 
	 
	        range.text = text; 
	         
        var actual = tmp = obj.value.replace(/\r\n/g, "\n"); 
	 
	        for(var diff = 0; diff < orig.length; diff++) { 
	            if(orig.charAt(diff) != actual.charAt(diff)) break; 
	        } 
	 
	        for(var index = 0, start = 0;  	         
			tmp.match(text)  
	                && (tmp = tmp.replace(text, ""))  
	                && index <= diff;  
	            index = start + text.length 
	        ) { 
			start = actual.indexOf(text, index); 
	        } 
	    } else if(obj.selectionStart) { 
	        var start = obj.selectionStart; 
	        var end   = obj.selectionEnd; 
	 
	        obj.value = obj.value.substr(0, start)  
	            + text  
	            + obj.value.substr(end, obj.value.length); 
	    } 
	     
	    if(start != null) { 
	        setCaretTo(obj, start + text.length); 
	    } else { 
	        obj.value += text; 
	    } 
	} 
	 
	function setCaretTo(obj, pos) { 
	    if(obj.createTextRange) { 
	        var range = obj.createTextRange(); 
	        range.move('character', pos); 
	        range.select(); 
	    } else if(obj.selectionStart) { 
	        obj.focus(); 
	        obj.setSelectionRange(pos, pos); 
	    } 
	} 
	</script>
</head>
<body>
	<form name="form">
		<input type="button" value="Insert text" onclick="insertAtCaret(this.form.text, this.form.string.value)">
		<input type="text" name="string"><br />		
		<textarea name="text" cols="60" rows="10"></textarea>
	</form>
</body>
</html>
וזה מש ששיניתי ממנו :
HTML קוד:
<form name="form">
		<input type="image" src="images/icons/smiley.png" onclick="insertAtCaret(this.form.textInput, this.form.smiley.value)">
		<input type="hidden" name="smiley" value="*smiley*"><br />		
		<textarea name="textInput" cols="60" rows="10"></textarea>
	</form>
בתכלס שיניתי שזה לא יקבל קלט מINPUT TEXT אלה מ input מוחבא ע"י לחיצה על input מסוג תמונה
זה עושה את העבודה אבל יש באג מוזר שאחרי שזה מוסיף את הטקסט שיש בתוך ה HIDDEN זה פשוט מוחק אותו

אם אתה רוצה לבדוק את פשוט תשים קישור תמונה אמיתי ותנסה ותראה מה הבעיה
אשמח לעזרה תודה
  Reply With Quote