[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Error copying code to an HTML element

Posted on 2012-04-04
8
Medium Priority
?
290 Views
Last Modified: 2012-04-09
I have a form with a drop down menu and an HTML element. (From DMX Zone).
ASP Classic / VBScript

The code below is for the drop down menu, when a selection is made its supposed to insert the tags into the text editor wherever the cursor is at that time.

---

<select name="s" size="1" class="bodytext" onchange="dmxedit_insertHTML('editor1',document.form1.s.options[document.form1.s.selectedIndex].value)">
                    <option value=" "></option>
                    <option value="[Alien:Title] [Alien:First] [Alien:Last]<br>[Alien:ResStr]<br>[Alien:ResCity], [Alien:ResState] [Alien:ResZip]">Contact - Block</option>
                    <option value="[Alien:Last]">Contact - Last Name</option>
                    <option value="[Alien:First]">Contact - First Name</option>
                    <option value="[Alien:MidName]">Contact - Middle Name</option>
                    <option value="[Alien:Title]">Contact - Title</option>
                    <option value="[Alien:MaidenNm]">Contact - Maiden Name</option>
                    <option value="[Alien:MailCareof]">Contact - Mail Address Care Of</option>
                    <option value="[Alien:MailStr]">Contact - Mail Address Street</option>
                    <option value="[Alien:MailApt]">Contact - Mail Address Apt.</option>
                    <option value="[Alien:MailCity]">Contact - Mail Address City</option>
                    <option value="[Alien:MailState]">Contact - Mail Address State</option>
                    <option value="[Alien:MailZip]">Contact - Mail Address Zip Code</option>
                    <option value="[Alien:MailCntry]">Contact - Mail Address Country</option>
                    <option value="[Alien:ResCareOf]">Contact - Residence Address Care Of</option>
                    <option value="[Alien:ResStr]">Contact - Residence Address Street</option>
                    <option value="[Alien:ResApt]">Contact - Residence Address Apt.</option>
                    <option value="[Alien:ResCity]">Contact - Residence Address City</option>
                    <option value="[Alien:ResState]">Contact - Residence Address State</option>
                    <option value="[Alien:ResZip]">Contact - Residence Address Zip Code</option>
                    <option value="[Alien:ResCntry]">Contact - Residence Address Country</option>
                    <option value="[Alien:AbrdCareOf]">Contact - Abroad Address Care Of</option>
                    <option value="[Alien:AbrdStr]">Contact - Abroad Address Street</option>
                    <option value="[Alien:AbrdApt]">Contact - Abroad Address Apt.</option>
                    <option value="[Alien:AbrdCity]">Contact - Abroad Address City</option>
                    <option value="[Alien:AbrdState]">Contact - Abroad Address State</option>
                    <option value="[Alien:AbrdZip]">Contact - Abroad Address Zip Code</option>
                    <option value="[Alien:AbrdCntry]">Contact - Abroad Address Country</option>
                    <option value="[Alien:Dob]">Contact - Date of birth</option>
                    <option value="[Alien:Country]">Contact - Country of birth</option>
                    <option value="[Alien:PPNum]">Contact - Passport Number</option>
                    <option value="[Alien:PPCountry]">Contact - Passport Country</option>
                    <option value="[Alien:PPExpiration]">Contact - Passport exp. Date</option>
                    <option value="[Alien:Nationality]">Contact - Nationality</option>
                    <option value="[Alien:AlienNum]">Contact - Alien Number</option>
                    <option value="[Alien:SSN]">Contact - SSN</option>
                    <option value="[Alien:Dayphone]">Contact - Dayphone</option>
                    <option value="[Alien:EvePhone]">Contact - Evening Phone</option>
                    <option value="[Alien:Fax]">Contact - Fax</option>
                    <option value="[Alien:Email]">Contact - Email</option>
                    <option value="[Alien:Arrivaldate]">Contact - Arrival date</option>
                    <option value="[Alien:Arrivalcity]">Contact - Arrival city</option>
                    <option value="[Alien:Arrivalstate]">Contact - Arrival state</option>
                    <option value="[Alien:I94]">Contact - I94 number</option>
                    <option value="[Alien:NiStatus]">Contact - Current status</option>
                    <option value="[Alien:ExpiresOn]">Contact - Status exp. Date</option>
                    <option value="[Case:CaseId]">Case - Number</option>
                    <option value="[Case:CaseName]">Case - Name</option>
                    <option value="[LawFirm:Name]">Law Firm - Name</option>
                    <option value="[Employer:AttnTo]<br>[Employer:EmpName]<br> [Employer:Street], [Employer:Suite]<br>[Employer:City], [Employer:State] [Employer:Zip]">Employer - Block</option>
                    <option value="[Employer:EmpName]">Employer - Name</option>
                    <option value="[Employer:Street]">Employer - Street</option>
                    <option value="[Employer:Suite]">Employer - Suite</option>
                    <option value="[Employer:City]">Employer - City</option>
                    <option value="[Employer:State]">Employer - State</option>
                    <option value="[Employer:Zip]">Employer - Zip code</option>
                    <option value="[Employer:Country]">Employer - Country</option>
                    <option value="[Employer:AttnTo]">Employer - Attn to</option>
                    <option value="[Employer:Phone]">Employer - Phone</option>
                    <option value="[Employer:Fax]">Employer - Fax</option>
                    <option value="[Employer:email]">Employer - Email</option>
                    <option value="[Employer:SignLastNm]">Employer - Last Name of person authorized to sign</option>
                    <option value="[Employer:SignFirstNm]">Employer - First Name of person authorized to sign</option>
                    <option value="[Employer:SignTitle]">Employer - Tile Last of person authorized to sign</option>
                    <option value="[Employer:IRS]">Employer - IRS Tax #</option>
                    <option value="[Employer:SSN]">Employer - SSN</option>
                    <option value="[Employer:BusinessType]">Employer - Business Type</option>
                    <option value="[Employer:I94]">Employer - Year established</option>
                    <option value="[Employer:Employees]">Employer - Number of Employees</option>
                    <option value="[Employer:GrossIncome]">Employer - Gross Income</option>
                    <option value="[Employer:NetIncome]">Employer - Net Income</option>
                  </select>

-----

This is the code for the HTML element

<textarea id="editor1" name="editor1" class="dmxEditor" style="width:600px;height:300px"><%=(LetterMrg.Fields.Item("LtrBody").Value)%></textarea>
                  <script type="text/javascript">
  // <![CDATA[
 jQuery(document).ready(
   function()
     {
       jQuery("#editor1").dmxEditor(
         {}
       );
     }
 );
  // ]]>
                  </script>

------

If I use any computer or browser nothing happens when the selection is made, BUT if i use an ipad the following error is displayed:

Undefined
ReferenceError:can't find variable: dmxedit_insertHTML

Hope thats a hint for what I may be missing ... help is GREATLY appreciated !!!
0
Comment
Question by:Aleks
  • 4
  • 4
8 Comments
 
LVL 18

Expert Comment

by:nap0leon
ID: 37806616
If I use any computer or browser nothing happens when the selection is made, BUT if i use an ipad the following error is displayed:

Have you checked the error console in your browsers?
In FireFox it is at "Tools"-->"Web Developer"-->"Error Console" (or [Ctrl]+[Shift]+[J])

Based on the error message you are seeing on the iPad, that function is not loaded... you should double-check your reference to the script that contains the dmxeditor.
0
 

Author Comment

by:Aleks
ID: 37806793
Like i said, this is the error:

Undefined
ReferenceError:can't find variable: dmxedit_insertHTML

I have no idea why i get this ?
0
 
LVL 18

Accepted Solution

by:
nap0leon earned 2000 total points
ID: 37806978
Like i said, this is the error:

Undefined
ReferenceError:can't find variable: dmxedit_insertHTML

The browser does not know what "dmxedit_HTML" is.
Like I said, check the reference to your dmx editor.  

Create a webpage with nothing but your drop-down, select an entry from the drop-down, and notice you receive that error.
<form name="form1">
<select name="s" size="1" class="bodytext" onchange="dmxedit_insertHTML('editor1',document.form1.s.options[document.form1.s.selectedIndex].value)">
	<option value=" "></option>
	<option value="[Alien:Title] [Alien:First] [Alien:Last]<br>[Alien:ResStr]<br>[Alien:ResCity], [Alien:ResState] [Alien:ResZip]">Contact - Block</option>
	<option value="[Alien:Last]">Contact - Last Name</option>
	<option value="[Alien:First]">Contact - First Name</option>
</select>
</form>

Open in new window


Now add a script block that contains a function named dmxedit_insertHTML, select an item from your drop-down, notice you do not receive the error:
<script>
function dmxedit_insertHTML(one,two){return true}
</script>
<form name="form1">
<select name="s" size="1" class="bodytext" onchange="dmxedit_insertHTML('editor1',document.form1.s.options[document.form1.s.selectedIndex].value)">
	<option value=" "></option>
	<option value="[Alien:Title] [Alien:First] [Alien:Last]<br>[Alien:ResStr]<br>[Alien:ResCity], [Alien:ResState] [Alien:ResZip]">Contact - Block</option>
	<option value="[Alien:Last]">Contact - Last Name</option>
	<option value="[Alien:First]">Contact - First Name</option>
</select>
</form>

Open in new window

0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Aleks
ID: 37807588
I tried the code above and unfortunately nothing happens .. no error but doesnt copy the tags either.  :(
0
 

Author Comment

by:Aleks
ID: 37807601
formcode.txtHere is the whole form code, in case I  may be missing something else.
0
 
LVL 18

Expert Comment

by:nap0leon
ID: 37808381
I tried the code above and unfortunately nothing happens .. no error but doesnt copy the tags either.  :(

There is an error in the first one, you just aren't seeing it.  Follow the instructions in my first post that tell you how to locate the "Error Console" in FireFox. (Similar are available in the other browsers as well).

The code did not copy to anywhere because a) the code that does the copy does not exist in the page (which causes the error you are trying to locate) and b) the webpage posted above does not have any section labeled with 'editor' so even if the function did exist, it would not be able to copy it there because "there" does not exist.
0
 

Author Comment

by:Aleks
ID: 37808438
I installed Firefox and there are no errors displayed in the console when i select from the drop down menu. Quite simply nothing is copied over.

The code of the form is attached above. You will see the naming is right, the element is there ...
0
 
LVL 18

Expert Comment

by:nap0leon
ID: 37808505
If you didn't get an error, then you cannot possibly be running the code I posted above or you have something set that has disabled javascript, etc.
Try the attached.  After you are able to verify the error, remove the comment lines (the \\) from the function declaration at the top, refresh the page, and see that the error goes away.

In FireFox, you will see the following error:
Timestamp: 4/4/2012 5:06:31 PM
Error: dmxedit_insertHTML is not defined
Source File: file:///C:/test/test.html
Line: 1

Open in new window

test.html
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month18 days, 8 hours left to enroll

825 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question