Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Apr 2005
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Variable not getting established

    I have no clue about javascript, so there might be a simple problem that i just don't know about.

    this is in my HTML file:

    <SCRIPT type="Javascript">
    <!--

    picNum=1
    picNumString="01"

    //-->
    </SCRIPT>

    I dont know whats wrong, cuz when i try to run an alert telling me the value of picNum, there is an error.

    <button type="button" onClick="alert(picNum)">Current pic</button>

    Doesn't work... no alert even shows up.
    Last edited by Var_javaMasta; 04-20-2005 at 11:53 PM.

  • #2
    Regular Coder
    Join Date
    Apr 2005
    Location
    Lisbon, CT
    Posts
    339
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Try
    <input type="button" onClick="alert(picNum)" value="Current pic">

    BaldEagle

  • #3
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,042
    Thanks
    0
    Thanked 251 Times in 247 Posts
    You had the wrong script type. This is the correct type.

    <script type="text/javascript">

  • #4
    Senior Coder
    Join Date
    Apr 2005
    Posts
    1,051
    Thanks
    0
    Thanked 0 Times in 0 Posts
    <SCRIPT type="Javascript">
    <!--

    var picNum=1;
    var picNumString="01";

    //-->
    </SCRIPT>



  • #5
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,042
    Thanks
    0
    Thanked 251 Times in 247 Posts
    Quote Originally Posted by rlemon
    <SCRIPT type="Javascript">
    <!--

    var picNum=1;
    var picNumString="01";

    //-->
    </SCRIPT>


    That's optional but a good coding habit to put them. Just correcting the script type will solve the problem.


  •  

    Posting Permissions

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