Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Nov 2006
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Add HTML double quotes "" Tags To A Form Field When Clicking On a Image

    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

  • #2
    Senior Coder Arbitrator's Avatar
    Join Date
    Mar 2006
    Location
    Splendora, Texas, United States of America
    Posts
    3,387
    Thanks
    32
    Thanked 288 Times in 282 Posts
    Use Unicode escapes. For U+0022 Quotation Mark, you would use \u0022.
    For every complex problem, there is an answer that is clear, simple, and wrong.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •