...

View Full Version : Help with Drop Down Messages?



mattios550
08-30-2011, 03: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">
<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! :) :thumbsup:

mattios550
08-30-2011, 03:52 PM
Thanks!

devnull69
08-30-2011, 03: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"';

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

mattios550
09-02-2011, 10:40 AM
Thanks! :)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum