View Full Version : Help with Drop Down Messages?

08-30-2011, 04:51 PM
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...:rolleyes:

<table border="0" cellspacing="0" cellpadding="0">
<td width="100%"><form name="ddmessage"><table border="0" width="100%" cellspacing="0" cellpadding="0">
<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>
<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>


<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!'


//don't edit pass this line

function changecontent(which){


Thanks! :) :thumbsup:

08-30-2011, 04:52 PM

08-30-2011, 04:57 PM
You'll have to watch your inner quotes in strings. You can have the following combinations

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

var myString1 = "what's up? "nothing"";
var myString2 = 'what's up? "nothing"';

08-30-2011, 06:33 PM
I would avoid using tables m8, if you truly wan't an outstanding and fast loading website use CSS only.

09-02-2011, 11:40 AM
Thanks! :)