?
Solved

Call javascript function gives type mismatch ?

Posted on 2005-04-25
10
Medium Priority
?
931 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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…

649 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