www.webdeveloper.com
Results 1 to 8 of 8

Thread: How to invoke JS functions "in-line"

  1. #1
    Join Date
    Nov 2013
    Posts
    15

    How to invoke JS functions "in-line"

    I am a beginner at JS so please bear with me.
    I need t invoke a JS function based one in-line logic - not associated with click.
    In my attempts to do so, it says "Undefined Function".
    The same function invoked from "href=" works fine.
    Is there some secret about how to call functions from in-line code?

    Also - how do access a JS console or monitor that shows what errors I'm getting - from firefox? There used to be one built in but now I can't find it.

  2. #2
    Join Date
    Dec 2005
    Location
    FL
    Posts
    7,410
    Quote Originally Posted by zron View Post
    I am a beginner at JS so please bear with me.
    I need t invoke a JS function based one in-line logic - not associated with click.
    In my attempts to do so, it says "Undefined Function".
    The same function invoked from "href=" works fine.
    Is there some secret about how to call functions from in-line code?

    Also - how do access a JS console or monitor that shows what errors I'm getting - from firefox? There used to be one built in but now I can't find it.
    Show your attempts.

    Also: Ctrl-Shift-J displays the error console in FF and Chrome.

  3. #3
    Join Date
    Nov 2013
    Posts
    15
    [QUOTE=JMRKER;1295251]Show your attempts.

    Ok, my attempts look something like this:

    <script language="Javascript" type="text/javascript">
    function opWbigzz(prog) {
    newWindow=window.open(prog,"big","width=1000,height=1000,toolbar=yes,
    menubar=1,scrollbars=yes,resizable=yes,top=100,left=100");
    newWindow.focus(); }
    </script>

    I tried invoking the functions like this (simplified):

    opWbigzz("K9shows.php?code=");
    javascriptpWbigzz("K9shows.php?code=");

    It says "function not defined",
    but if I invoke like this: print('<a href=javascriptpWbigzz("K9shows.php?code=") >test</a>); it works fine

    (also - I thought I could generate JS code from php (like html) but that doesn't seem to work.)

  4. #4
    Join Date
    Nov 2013
    Posts
    15
    I get these errors. do I need to specify character encoding? How do I do that?

    [18:14:09.048] A form was submitted in the windows-1252 encoding which cannot encode all Unicode characters, so user input may get corrupted. To avoid this problem, the page should be changed so that the form is submitted in the UTF-8 encoding either by changing the encoding of the page itself to UTF-8 or by specifying accept-charset=utf-8 on the form element. @ http://caninechronicleshowcalendar.c...popx.php?state[]=NY&brno=614&code=A&jno=17190
    [18:14:09.349] The character encoding of the HTML document was not declared. The document will render with garbled text in some browser configurations if the document contains characters from outside the US-ASCII range. The character encoding of the page must be declared in the document or in the transfer protocol. @ http://caninechronicleshowcalendar.c...&submit=Future

  5. #5
    Join Date
    Dec 2005
    Location
    FL
    Posts
    7,410
    Are you trying to open a new window with a K9shows.php?code script?

    Or are you trying to run the program K9shows.php from JS?

    Are you trying to pass a query string from the command line with ?code=
    at the end of the command line?

    I'm not sure I understand what you are trying to accomplish.


  6. #6
    Join Date
    Nov 2013
    Posts
    15
    As I have tried to explain twice, what the function does doesn't matter. (It opens a new window) I'm trying to call the function from "inline" php code and getting "function not defined". The same function works fine when invoked from <a href=javascript:function name> so the function is defined. The question is why is it saying the function isn't defined? How do I call a function from simple in-line code? I've tried everything I can think of.
    You know what I mean by "inline code"? I mean just a statement in a logic sequence, not part of a click-oriented event. I don't know how to be clearer. Please re-read my first post.

  7. #7
    Join Date
    May 2006
    Location
    Somewhere behind your screen
    Posts
    1,653
    Quote Originally Posted by zron View Post
    ... why is it saying the function isn't defined? ...
    most likely because it's not defined

  8. #8
    Join Date
    Dec 2005
    Location
    FL
    Posts
    7,410
    Quote Originally Posted by zron View Post
    As I have tried to explain twice, what the function does doesn't matter. (It opens a new window) I'm trying to call the function from "inline" php code and getting "function not defined". The same function works fine when invoked from <a href=javascript:function name> so the function is defined. The question is why is it saying the function isn't defined? How do I call a function from simple in-line code? I've tried everything I can think of.
    You know what I mean by "inline code"? I mean just a statement in a logic sequence, not part of a click-oriented event. I don't know how to be clearer. Please re-read my first post.
    We are just guessing as to your problem because you have yet to provide the entire test code.
    *Where* you call the function is important. If it is not yet defined within the HTML, then it becomes 'undefined' at the time of execution.

    It does not need to be your entire code, but at least provide any JS, HTML and CSS that demonstrates the problem encountered.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles