Solved

Call javascript function gives type mismatch ?

Posted on 2005-04-25
10
926 Views
Last Modified: 2012-08-14
Please help me asap.  Why Am I getting this ?

Please help if you can see any error.

<%For i = 1 To nMoreRows1%>
                    <TR>
                              <TD height="22"><INPUT type="text" ID="Task<%=i %>" NAME="Task<%=i %>"></TD>
                              <TD height="22">
                         <%For j = 1 To nMoreRes1%>
                               <div id = "Task<%=i %>Res<%=j%>"></div>
                         <%
                         call cmdAddRes(i,j) <---------------TYPE MSMATCH ERROR
                         next%>
                         
                         
                              <a href="#top" name="lnkAddresource" OnClick="cmdAddRes(task<%=i %>, <%=j%>)">+ add resources</a>
                         
                              </TD>
                         
                              <TD height="22">
                         <%For j = 1 To nMoreRes1%>
                               <div id = "Task<%=i %>Hr<%=j%>"></div>
                         <%next%>
                         </TD>
                    </TR>
                         
                    <%
                    next%>

function cmdAddRes(obj,obj2)
{
var resname;
var el = document.createElement('input')
el.type = "text";
el.name = "Task" + obj + "Res" + obj2
resname = "Task" + obj + "Res" + obj2
document.getElementById(resname).appendChild(el);
var br = document.createElement('br')
document.getElementById(resname).appendChild(br);
var hrname;
var el2 = document.createElement('input')
el2.type = "text";
el2.name = "Task" + obj + "Hr" + obj2
hrname =  "Task" + obj + "Hr" + obj2
document.getElementById(hrname).appendChild(el2);
var br2 = document.createElement('br')
document.getElementById(hrname).appendChild(br2);
}
0
Comment
Question by:suran78
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
  • 2
10 Comments
 
LVL 15

Expert Comment

by:justinbillig
ID: 13861618
you can't set the type attribute of an html element, it is read only
0
 
LVL 25

Expert Comment

by:archrajan
ID: 13861686
call cmdAddRes(i,j)
shud be
cmdAddRes('i','j')
0
 
LVL 25

Expert Comment

by:archrajan
ID: 13861694
justinbillig,
But in this case we r creating elements dynamically, and hence u can set the type and it wud work
0
Independent Software Vendors: 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!

 
LVL 15

Expert Comment

by:justinbillig
ID: 13861719
I have a question, instead of creating the elements in javascript, why not create them in ASP?
0
 

Author Comment

by:suran78
ID: 13861799
How ? Please give me the code in ASP to do the same.

call cmdaddres('i','j') is not working.  ' is a comment symbol in asp/vb
0
 
LVL 25

Expert Comment

by:archrajan
ID: 13861822
to call javascript u shud put them between the <script></script> tags. anyways.
0
 

Author Comment

by:suran78
ID: 13861879
please help me in constructing the javasript tag in asp, I tried and I think I missed quotes:

<%For j = 1 To nMoreRes1%>
                                     <div id = "Task<%=i %>Res<%=j%>"></div>
                              <%
                              

                              call cmdAddRes("i","j") ----->   "<script type=" & "text/javascript">
cmdAddRes(i,j) ;
</script> ???

                              next%>

0
 
LVL 25

Accepted Solution

by:
archrajan earned 125 total points
ID: 13862040
TAKE THE call keyword out


u dont need the <% %> at all

just where u want to call you can call it like this

<script>
cmdAddRes("i","j");
</script>

or u shud call it with some event handler like this onload or onclick = "cmdAddRes('i','j');"
0
 

Author Comment

by:suran78
ID: 13862127
I am getting this error now, object expected for teh javasript function

This is teh code.  I have to call it in, i cannot use it anywhere else for onload or onclick

<%For j = 1 To nMoreRes1%>
                                     <div id = "Task<%=i %>Res<%=j%>"></div>
                                     <script>
                                          cmdAddRes("i","j");
                                    </script>

                              <%next%>
                              
0
 
LVL 25

Expert Comment

by:archrajan
ID: 13862662
post the generated code for this
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Timer on div 5 24
converting document.write() to innerHTML 7 48
replacing inline javascript with jquery 4 45
javascript and jquery question 4 24
In this article, we'll look how to sort an Array in JavaScript, including the more advanced techniques of sorting a collection of records either ascending or descending on two or more fields. Basic Sorting of Arrays First, let's look at the …
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

749 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