Also, don't say you don't know ColdFusion because this is a JavaScript question.
It is, but it's heavily tied in with ColdFusion, so is difficult for me to work with with no knowledge of ColdFusion. I'm going to make some assumptions:- That #SomeObject.SomeValue# is a ColdFusion-inserted value;
- that <cfoutput> causes the code to be looped over some unknown value; and that
- GetElementById() is a (poorly-named) ColdFusion-generated client-side function.
Code:
<head>
<title>Some Title</title>
<script type="text/javascript">
function populateFromMe(el, frm) {
frm = frm.elements;
for(var i = 0, e; e = frm.elements[i]; ++i)
if(e.name.indexOf("Announcement") !== 0)
continue;
else
frm[e.name].value = GetElementByID('#GetAnnouncements.' + e.name + '#');
}
</script>
</head>
<body>
<form action="AnnounceEditor.cfm" id="RecurringAnnouncements" method="post">
<select name="Announcement" id="Announcement" onchange="populateFromMe(this, this.form);">
<cfoutput query="GetAnnouncements">
<option value="#AnnouncementID#">#AnnouncementTitle#</option>
</cfoutput>
</select>
<cfoutput>
<input type="text" name="Title" value="#GetAnnouncements.AnnouncementTitle#">
<input type="text" name="Body" value="#GetAnnouncements.AnnouncementBody#">
<input type="text" name="Link" value="#GetAnnouncements.AnnouncementLink#">
<input type="text" name="LinkText" value="#GetAnnouncements.AnnouncementLinkText#">
<input type="text" name="PostDate" value="#GetAnnouncements.AnnouncementPostDate#">
<input type="text" name="ExpiresDate" value="#GetAnnouncements.AnnouncementExpiresDate#>
</cfoutput>
</form>
</body>
This is the way I'd do it, ignoring the ColdFusion as much as possible. If it doesn't work, it's most likely ColdFusion to blame, and you should get someone versed in ColdFusion to look at it.
Bookmarks