Results 1 to 2 of 2

Thread: Call a function in another file

  1. #1
    Join Date
    May 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Call a function in another file

    I'm trying to call a function located in another file. Than use the return value in the original file. I'm new to java scripting any help is appreciated.

    // This is the content of page.html
    <input type="text" name="text_filed" id="text_field_id" onClick="return false;" onBlur="isit('text_field_id');return true;"/>

    <script type="text/javascript">
    function isit(id){
    inputval=document.getElementById(id).value;
    expectedval=compare(inputval).src='/check.js';
    alert(expectedval);
    </script>

    //This is the content of check.js page
    function compare(inputvalue)
    {
    //do some calculation and return value

    return value;
    }

    I know there is a problem with how I'm calling the compare() function. Can someone advise the right syntax to do this. Thanks!
    Last edited by piratpl; 05-18-2010 at 07:04 PM.

  2. #2
    Join Date
    May 2010
    Posts
    9
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    try this
    Code:
    <input type="text" name="text_filed" id="text_field_id" onClick="return false;" onBlur="isit('text_field_id');return true;"/>
    
    <script type="text/javascript">
    function isit(id){
    inputval=document.getElementById(id).value;
    expectedval=eval(compare(inputval)).src='/check.js';
    alert(expectedval);
    </script>
    
    //This is the content of check.js page
    function compare(inputvalue)
    {
    //do some calculation and return value
    
    return value;
    }

    about function eval()
    http://blog.shoessm.com/Content.Asp?id=19

Bookmarks

Posting Permissions

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