Jump to content

why my mouse cursor does not sit in the position of the leftmost and topmost of a bbcode form


xbl1
 Share

Recommended Posts

Hi;I'd like to ask you a question;why my mouse cursor does not sit in the position of the leftmost and topmost of a bbcode form. Thanks.my form as following;bbcode form

<form action="story_verify1.php" method="post" name="editform" onsubmit="return checkForm(this)"><table id="editform"><tr>		<td id="story">My story</td></tr> <tr>		<td>				<input type="button" class="button" value="bold" name="bold" onclick="javascript:tag('b', '[b]', 'bold*', '[/b]', 'bold', 'bold');" onmouseover="helpline('bold')" />				<input type="button" class="button" value="italic" name="italic" onclick="javascript:tag('i', '[i]', 'italic*', '[/i]', 'italic', 'italic');" onmouseover="helpline('italic')" />				<input type="button" class="button" value="underline" name="underline" onclick="javascript:tag('u', '[u]', 'underline*', '[/u]', 'underline', 'underline');" onmouseover="helpline('underline')" />				<input type="button" class="button" value="quote" name="quote" onclick="javascript:tag('q', '[quote]', 'quote*', '[/quote]', 'quote', 'quote');" onmouseover="helpline('quote')" />				<input type="button" class="button" value="code" name="code" onclick="javascript:tag('c', '', 'code', 'code');" onmouseover="helpline('code')" />				<input type="button" class="button" value="url" name="url" onclick="javascript:tag('url', '[url]', 'url*', '[/url]', 'url', 'url');" onmouseover="helpline('url')" />				<input type="button" class="button" value="img" name="img" onclick="javascript:tag('img', '', 'img', 'img');" onmouseover="helpline('img')" />				<br />				Font size: <select name="fontsize" onchange="font('[size=' + this.form.fontsize.options[this.form.fontsize.selectedIndex].value + ']', '[/size]'); this.selectedIndex=2;" onmouseover="helpline('fontsize')" class="form_elements_dropdown">								<option value="50%" >Tiny</option>								<option value="75%" >Small</option>								<option value="100%" selected="selected" >Normal</option>								<option value="150%" >Large</option>								<option  value="200%" >Huge</option>						</select> 				Font color: <select name="fontcolor" onchange="font('[color=' + this.form.fontcolor.options[this.form.fontcolor.selectedIndex].value + ']', '[/color]'); this.selectedIndex=0;" onmouseover="helpline('fontcolor')" class="form_elements_dropdown"  >								<option value="black" style="color:black">Black</option>								<option value="silver" style="color:silver">Silver</option>								<option value="gray" style="color:gray">Gray</option>								<option value="maroon" style="color:maroon">Maroon</option>								<option value="red" style="color:red">Red</option>																				<option value="purple" style="color:purple">Purple</option>								<option value="fuchsia" style="color:fuchsia">Fuchsia</option>								<option value="navy" style="color:navy">Navy</option>								<option value="blue" style="color:blue">Blue</option>								<option value="aqua" style="color:aqua">Aqua</option>								<option value="teal" style="color:teal">Teal</option>								<option value="lime" style="color:lime">Lime</option>								<option value="green" style="color:green">Green</option>								<option value="olive" style="color:olive">Olive</option>								<option value="yellow" style="color:yellow">Yellow</option>								<option value="white" style="color:white">White</option>												</select>								<br />				<input type="text" name="helpbox" size="75" class="helpbox" readonly="readonly"/>				</td></tr><tr>				<td>				Post:***<br />				<textarea rows="10" cols="50" name="Content" class="form_elements_text" id="thread">					<?php echo trim(stripslashes($_SESSION['story_content'])); ?>				</textarea>				</td></tr> <tr>				<td colspan="2" class="security_check">				<?php $_SESSION['fvalue']=rand(0,9); echo $_SESSION['fvalue'];  ?>  +				<?php $_SESSION['svalue']=rand(0,9); echo $_SESSION['svalue'];   ?> = <input type="text" name="result" /> **			   </td></tr><tr>				<td colspan="2" id="post">				<input type="submit" name="Post" value="Post" class="button" />				<input type="submit" name="preview" value="Preview" class="button"/>				<input type="reset" value="Reset" class="button" onclick="javascript:confirm_reset();"/>				</td></tr></table></form>

bbcode.js

//Variables for controlling opening and closing tags (function tag)var b = 2;var i = 2;var u = 2;var q = 2;var mail = 2;var url = 2;var img = 2;//Function for creating non-font tagsfunction tag(v, tagadd, newbut, tagclose, oldbut, name){ var r = document.selection.createRange().text;rr = tagadd + r + tagclose;if(r){document.selection.createRange().text = rr;}else{if (eval(v)%2 == 0){eval("window.document.editform."+name+".value = newbut;");var content = window.document.editform.content.value;window.document.editform.content.value =  content + tagadd;window.document.editform.content.focus();}else{eval("window.document.editform."+name+".value = oldbut;");var content = window.document.editform.content.value;window.document.editform.content.value = content + tagclose;window.document.editform.content.focus();}eval(v+"++;");}}//Function for adding font color and size tagsfunction font(bbopen, bbclose) {		var r = document.selection.createRange().text;		rr = bbopen + r + bbclose;		if(r)		{		  document.selection.createRange().text = rr;		}else{		  var post = document.editform.post;		  post.value += bbopen +r+ bbclose;		  post.focus();		}		return;} function smilie (tag) {	   var myField;		tag = ' ' + tag + ' ';		if (document.getElementById('thread') && document.getElementById('thread').type == 'textarea') {				  myField = document.getElementById('thread');		} else {				return false;		}		if (document.selection) {				 myField.focus();				sel = document.selection.createRange();				sel.text = tag;				myField.focus();		}		else if (myField.selectionStart || myField.selectionStart == '0') {				var startPos = myField.selectionStart;				var endPos = myField.selectionEnd;				var cursorPos = endPos;				myField.value = myField.value.substring(0, startPos) + tag + myField.value.substring(endPos, myField.value.length);				cursorPos += tag.length;				myField.focus();				myField.selectionStart = cursorPos;				myField.selectionEnd = cursorPos;		}		else {				myField.value += tag;				myField.focus();		} }  //Helpbox messagesbold_help = "Bold text: [b]text[/b]";italic_help = "Italic text: [i]text[/i]";underline_help = "Underline text: [u]text[/u]";quote_help = "Quote text: [quote]text[/quote] or [quote=name]text[/quote]";code_help = "Code display: ";img_help = "Insert image: ";url_help = "Insert URL: [url]http://url[/url] or [url=http://url]URL text[/url]";fontcolor_help = "Font color: [color=red]text[/color]  Tip: you can also use color=#FF0000";fontsize_help = "Font size: [size=50%]small text[/size]";//Function for displaying help information// Shows the help messages in the helpline windowfunction helpline(help) {		var helpbox = document.editform.helpbox;		helpbox.value = eval(help + "_help");}//Function to confirm resetfunction confirm_reset () {		if(confirm("If you continue you will loose everything you have entered so far. \n \n" +				"Click OK to proceed and start again.  \n \n Alternatively click cancel to continue " +				"working on your post.")) {						return true;								}				else {						return false;								}}//Check the form submission for errorsfunction checkForm() {		var subject = document.editform.subject;		var post = document.editform.post;		//Check to make sure post lengths are sensible		if (subject.value.length < 2 && post.value.length < 2) {				alert("This is a short post!" + " \n \n " +								"We require that each post (and subject) \n" +								"be at least 2 characters long. \n \n" +								"Go back and try again.");				return false;		}		else { if (subject.value.length < 2) {						alert("We require that the subject  \n" +								"be at least 2 characters long. \n \n" +								"Go back and try again.");								return false;								}						else { if (post.value.length < 2) {						alert("We require that each post  \n" +								"be at least 2 characters long. \n \n" +								"Go back and try again.");								return false;								}								else {										return true;								}						}		}}

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...