Solved

Call javascript function gives type mismatch ?

Posted on 2005-04-25
10
925 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
  • 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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Today I would like to talk about localizing (Internationalization) JavaScript applications. Introduction When creating an application that is going to be used by many people around the globe, it is important to remember that not everyone speak…
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 …
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…

832 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