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
    Aug 2011
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Unhappy Help with Drop Down Messages?

    Hi! I was wondering if anyone could help with the code below. I think there is something wrong with the "thecontents[] part below. Could anyone have a look and possible email me with a finished version...

    Code:
    <table border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="100%"><form name="ddmessage"><table border="0" width="100%" cellspacing="0" cellpadding="0">
            <tr>
              <td width="100%"><select name="selectbox" size="1" onChange="changecontent(this)">
                <option selected value="What is JavaScript?">What is JavaScript?</option>
                <option value="Why learn JavaScript?">Why learn JavaScript?</option>
                <option value="What do you think of the site?">What do you think of the site?</option>
                <option value="I'd like to feature one of these codes on my site.">I'd like to feature one of these codes on my site.</option>
              </select><br>
              </td>
            </tr>
            <tr>
              <td width="100%"><textarea rows="8" name="contentbox" cols="35" wrap="virtual"></textarea><br>
    <font face="arial" size="-2">This free script provided by <a href="http://javascriptkit.com">JavaScript Kit</a></font>
    </td>
            </tr>
          </table>
        </form>
        </td>
      </tr>
    </table>
    
    <p>
    
    <script language="JavaScript">
    
    /*
    Drop down messages script
    By JavaScript Kit (http://javascriptkit.com)
    Over 400+ free scripts here!
    */
    
    //change contents of message box, where the first one corresponds with the first drop down box, second with second box etc
    var thecontents=new Array()
    
    thecontents[0]='Its what I used to make this :/'
    
    thecontents[1]='I wouldn't reccommend it, its rather hard. Though, I hate to blow ones own trumpet, I am learning to do it rather well.'
    
    thecontents[2]='I hope you have enjoyed it! Email support@matthewjmorris.co.uk with your comments. Also, if you have any bits to go on this page, email Support aswell with the code, instructions for installing the code and your name! Your name may appear here, along with your code!'
    
    thecontents[3]='support@matthewjmorris.co.uk'
    
    
    //don't edit pass this line
    
    function changecontent(which){
    document.ddmessage.contentbox.value=thecontents[which.selectedIndex]
    }
    
    document.ddmessage.contentbox.value=thecontents[document.ddmessage.selectbox.selectedIndex]
    </script>
    Thanks!

  • #2
    New to the CF scene
    Join Date
    Aug 2011
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Thanks!

  • #3
    Senior Coder
    Join Date
    Dec 2010
    Posts
    2,391
    Thanks
    12
    Thanked 568 Times in 561 Posts
    You'll have to watch your inner quotes in strings. You can have the following combinations
    Code:
    var myString1 = "what's up? \"nothing\"";
    var myString2 = 'what\'s up? "nothing"';
    But the following two will result in errors. You'll always have to escape (put a \ in front of) those inner quotes that are the same as the outer quotes
    Code:
    var myString1 = "what's up? "nothing"";
    var myString2 = 'what's up? "nothing"';

  • Users who have thanked devnull69 for this post:

    mattios550 (09-02-2011)

  • #4
    New to the CF scene
    Join Date
    Aug 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I would avoid using tables m8, if you truly wan't an outstanding and fast loading website use CSS only.

  • #5
    New to the CF scene
    Join Date
    Aug 2011
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Thumbs up

    Thanks!


  •  

    Posting Permissions

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