Here's the scenario, below is a JavaScript function and some Form HTML. What I need to do is pass the code labelled in red (or *** code I want to pass ***) to the innerHTML of the DIV (box1) so that it produces some dropdown date selector boxes.
The problem I am having depending on what I do is that:-
1] either the code executes within the JavaScript messing up the JavaScript (as the tag contains loads of HTML and JS) OR
2] I pass text to the DIV and it does not parse it as CF and does not display the drop down date boxes at all.
What should happen is when you click the "Show Date Dropdowns" link only the dropdowns should appear and when you click the "Show Textbox" link only the text box should appear.
Does anyone have any idea how I could achieve this? would hail you as the guru of all guru's if you could give me.
Puc. ( Code follows NB - custom tag CF_DROPDOWNS can be obtained from
*******************************************************
<script language ="javascript>
function swapem(item)
{
var contents='';
if (item == 'date')
{
contents=' *** code I want to pass *** <cf_datedropdowns aname="adate" startyear="2001" endyear="2007" formname="searchform">';
}
else
{
contents+='<span>contains</span><input name="searchtype" type="radio" value="contains" <cfif isdefined("search"><cfif searchtype is "contains">checked</cfif><cfelse>checked</cfif>>' ;
contents+='<span> starts with</span><input type="radio" name="searchtype" value="starts" <cfif isdefined("search"><cfif searchtype is "starts">checked</cfif></cfif>>';
contents+='<input type="text" name="searchtext" size="26" value="<cfif isdefined('search')>#searchvalue#</cfif>"></span>';
}
eval("document.all['box1'].innerHTML = contents"
}
</script>
---------------------------------------------------------
<a href="javascript:swapem('date')">Show Date Dropdowns</a> <a href="javascript:swapem('text')">Show Textbox</a><br><br>
<form action="htmltest2.cfm" name="searchform" method="post">
<table border="1">
<tr><td>This is the text above</td></tr>
<tr>
<td>
<div id="box1">
<!-- this is the DIV I want to put the contents into --->
</div>
</td>
</tr>
<tr><td>This is the text below</td></tr>
<tr><td><input type="Submit" value="submit it"></td></tr>
</table>
</form>
The problem I am having depending on what I do is that:-
1] either the code executes within the JavaScript messing up the JavaScript (as the tag contains loads of HTML and JS) OR
2] I pass text to the DIV and it does not parse it as CF and does not display the drop down date boxes at all.
What should happen is when you click the "Show Date Dropdowns" link only the dropdowns should appear and when you click the "Show Textbox" link only the text box should appear.
Does anyone have any idea how I could achieve this? would hail you as the guru of all guru's if you could give me.
Puc. ( Code follows NB - custom tag CF_DROPDOWNS can be obtained from
*******************************************************
<script language ="javascript>
function swapem(item)
{
var contents='';
if (item == 'date')
{
contents=' *** code I want to pass *** <cf_datedropdowns aname="adate" startyear="2001" endyear="2007" formname="searchform">';
}
else
{
contents+='<span>contains</span><input name="searchtype" type="radio" value="contains" <cfif isdefined("search"><cfif searchtype is "contains">checked</cfif><cfelse>checked</cfif>>' ;
contents+='<span> starts with</span><input type="radio" name="searchtype" value="starts" <cfif isdefined("search"><cfif searchtype is "starts">checked</cfif></cfif>>';
contents+='<input type="text" name="searchtext" size="26" value="<cfif isdefined('search')>#searchvalue#</cfif>"></span>';
}
eval("document.all['box1'].innerHTML = contents"
}
</script>
---------------------------------------------------------
<a href="javascript:swapem('date')">Show Date Dropdowns</a> <a href="javascript:swapem('text')">Show Textbox</a><br><br>
<form action="htmltest2.cfm" name="searchform" method="post">
<table border="1">
<tr><td>This is the text above</td></tr>
<tr>
<td>
<div id="box1">
<!-- this is the DIV I want to put the contents into --->
</div>
</td>
</tr>
<tr><td>This is the text below</td></tr>
<tr><td><input type="Submit" value="submit it"></td></tr>
</table>
</form>