...

View Full Version : Add HTML double quotes "" Tags To A Form Field When Clicking On a Image



jay_eire
11-07-2006, 02:13 PM
Hi Guys,
I have the following form, that allows the user to add text to a form field When they click on an image, this works fine, but I need to slightly change the text that is added to the form.

I need to user to be able to add HTML type tags to the form,

Ive already tried this onClick
<img onClick="edInsertContent(document.form2.PageContent,'<a href=\'http://www.google.com/\'><img src=\'bla.gif\' border=\'0\' /></a>');" src="images/AddText.gif" name="AddLinkText" width="20" height="20" border="2" id="AddLinkText">

which will give me....
<a href='http://www.google.com/'><img src='bla.gif' border='0' /></a>

but i need there to be double qutotes rather than single quotes I need the output to be....
<a href="http://www.google.com/"><img src="bla.gif" border="0" /></a>


heres the code.........

<html>
<title>Script Demo</title>
<head>
<script language="JavaScript">
function edInsertContent(myField, myValue) {
//IE support
if (document.selection) {
myField.focus();
sel = document.selection.createRange();
sel.text = myValue;
myField.focus();
}
//MOZILLA/NETSCAPE support
else if (myField.selectionStart || myField.selectionStart == '0') {
var startPos = myField.selectionStart;
var endPos = myField.selectionEnd;
myField.value = myField.value.substring(0, startPos)
+ myValue
+ myField.value.substring(endPos, myField.value.length);
myField.focus();
myField.selectionStart = startPos + myValue.length;
myField.selectionEnd = startPos + myValue.length;
} else {
myField.value += myValue;
myField.focus();
}
}



</script>
</head>
<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<!-- Form Start -->
<form method="POST" action="<%=MM_editAction%>" name="form2">
<table class="body">
<tr valign="baseline">
<td height="23" colspan="2" align="right" valign="top" nowrap><div align="left"><span class="editorbodybold">PageName</span>:</div></td>
</tr>
<tr valign="baseline">
<td colspan="2" align="right" valign="top" nowrap><div align="left">
<input name="PageName" type="text" class="body" id="PageName" value="<%=(RsRecordSet1.Fields.Item("PageName").Value)%>" size="32">
</div></td>
</tr>
<tr valign="baseline">
<td colspan="2" align="right" valign="top" nowrap><div align="left"><span class="editorbodybold">Page Content</span>: <img onClick="edInsertContent(document.form2.PageContent,'<a href=\'http://www.google.com/\'><img src=\'bla.gif\' border=\'0\' /></a>');" src="images/AddText.gif" name="AddLinkText" width="20" height="20" border="2" id="AddLinkText"> <img onClick="edInsertContent(document.form2.PageContent,'Teacher name is: ');" src="images/AddTextTeacher.gif" name="AddTextTeacher" width="20" height="20" border="2" id="AddTextTeacher"> <img onClick="edInsertContent(document.form2.PageContent,' Class Name: ');" src="images/AddClassText.gif" name="AddClassText" width="20" height="20" border="2" id="AddClassText"> <img src="images/AddRoomNumber.gif" name="AddRoomNumber" width="20" height="20" border="2" id="AddRoomNumber"></div>
</td>
</tr>
<tr valign="baseline">
<td colspan="2" align="right" valign="top" nowrap>
<div align="left">
<textarea name="PageContent" cols="90" rows="10" class="body" id="PageContent" onfocus="range=document.selection.createRange();"><%=(RsRecordSet1.Fields.Item("Content").Value)%></textarea>
</div>
</td>
</tr>
<tr valign="baseline">
<td colspan="2" align="right" nowrap><div align="left"><span class="editorbodybold">Notes</span>:</div></td>
</tr>
<tr valign="baseline">
<td colspan="2" align="right" nowrap>
<div align="left">
<textarea name="Notes" cols="90" rows="5" class="body" id="Notes"><%=(RsRecordSet1.Fields.Item("Notes").Value)%></textarea>
</div>
</td>
</tr>
<tr valign="baseline">
<td width="21" align="right" nowrap><div align="left"></div>
</td>
<td width="551"><div align="left"></div></td>
</tr>
<tr valign="baseline">
<td nowrap align="right"><div align="left"></div></td>
<td>
<div align="left">
<input name="submit" type="submit" value="Update Page">
</div>
</td>
</tr>
</table>
</form>
<!-- Form End -->
</td>
</tr>
</table>

</body>
</html>


Thanks
Jay

Arbitrator
11-07-2006, 02:35 PM
Use Unicode escapes. For U+0022 Quotation Mark, you would use \u0022.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum