?
Solved

Call javascript function gives type mismatch ?

Posted on 2005-04-25
10
Medium Priority
?
930 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 500 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
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…
Suggested Courses

764 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