Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Twisted Variable formatting

Status
Not open for further replies.

ma701sd

IS-IT--Management
Dec 15, 2000
94
GB
Hi,
This is a really twisted one, but any help would be greatly appreciated!!!

Ok, heres what I'm trying to do...

I have a select drop down box on page 1. The code is as follows:

<SELECT NAME =&quot;headings&quot;>
<OPTION VALUE=&quot;&quot;>Select your heading size
<OPTION VALUE=&quot;<H1>&quot;><<H1>H1>

The &quot;Value&quot; is what I want passed as a variable and the &quot;<<H>H1> displays the tag as &quot;<H1>&quot; (with the angle brackets in the drop down box).

Ok, on the Action page, I want to use these variables as an opening and closing tag for H1.
It works when I open the Tag but it doesn't work when I close the Tag i.e. the rest of the document is formated as H1

This is the code to open and close the tag:
#Headings# <font Face=&quot;#Fonts#&quot; COLOR=&quot;#Colours#&quot;> #heading# </font> /#Headings#

I know that the variable is used as a generic tag and so Putting the &quot;/&quot; before the Variable is not correct as this is outside the Angle brackets, but I can't put it inside either coz then its not recognised as a variable!
I cant even use CFSET coz I cant Set a Sariable that begins with &quot;/&quot;.

I guess one way is to make this available in the the select box also but I dont want to go down that route coz this will be user driven and makes things messy..

Does any1 have any ideas????

Regards

Sam
 
How about this?

#headings# .... #replace(Headings,&quot;<&quot;,&quot;</&quot;)#

You might also consider just making your values &quot;h1&quot;,&quot;h2&quot;, etc.. and then displaying them as <#headings#>.....</#headings#>

Hope this helps,
GJ
 
Hey GJ,
I tried the second method but it got complicated because I needed complicated IF statements because I am applying the same principal for Fonts and Colours.

I will try the 1st option when I get a chance later on but I also thought about using Hidden variables on the first page...That should also address the prob..

Thanx :)

Sam
 
this, or use the chr(??) [where ?? is the code to get > or > !!], or try the &amp;gt; and &amp;lt; [as far as i remember, maybe you should check for the correct htmlcode for these elements], or even better, you could htmlencode (it's a cf function) your #headers#
 
In the end, I opted not to use the angle brackets and insert them in manually myself on the action page. On the action page Ive got a series of IF statements to check if a an element of the form is blank etc, but the problem Im having is that on the first page I have one main form which, within it contains all the form elements, I pass this onto the next page to display (according the formatting the user has chosen) but for some reason each input variable is not according to the formatting instructions selected i.e. the second input has exactly the same formatting as the first...
Ive included the code snippet :

1st Page:
<FORM ACTION=&quot;DynamicViewsite.cfm?cfid=#cfid#&amp;cftoken=#cftoken#&quot; METHOD=&quot;POST&quot; ENCTYPE=&quot;MultiPart/Form-Data&quot;>
<B> Heading </b><BR>
<INPUT TYPE=&quot;Text&quot; NAME=&quot;Heading&quot; VALUE=&quot;My First Home Page&quot;>
<BR>
<SELECT NAME =&quot;headings&quot;>
<OPTION VALUE=&quot;&quot;>Select your heading size
<OPTION VALUE=&quot;H1&quot;> H1
<OPTION VALUE=&quot;H2&quot;> H2
<OPTION VALUE=&quot;H3&quot;> H3
<OPTION VALUE=&quot;H4&quot;> H4
<OPTION VALUE=&quot;H5&quot;> H5
<OPTION VALUE=&quot;H6&quot;> H6
<INPUT TYPE=&quot;submit&quot; VALUE=&quot;process&quot;>
<INPUT TYPE=&quot;reset&quot; VALUE=&quot;Clear&quot;>
</SELECT>
<BR>
<SELECT NAME =&quot;Fonts&quot;>
<OPTION VALUE=&quot;Times New Roman&quot;>Times New Roman
<INPUT TYPE=&quot;submit&quot; VALUE=&quot;process&quot;>
<INPUT TYPE=&quot;reset&quot; VALUE=&quot;Clear&quot;>
</SELECT>
<BR>
<SELECT NAME =&quot;Colours&quot;>
<OPTION VALUE=&quot;&quot;>Select type colour
<OPTION VALUE=&quot;Cyan&quot;>Cyan
<INPUT TYPE=&quot;submit&quot; VALUE=&quot;process&quot;>
<INPUT TYPE=&quot;reset&quot; VALUE=&quot;Clear&quot;>
<BR>
<!--- End Of HEADING Input --->



<!--- Start of SECTION1 HEADING1 Input --->
<B> Heading for section 1 </b><BR>
<INPUT TYPE=&quot;Text&quot; NAME=&quot;Section1Heading1&quot; VALUE=&quot;Heading for first Paragraph&quot;>
<SELECT NAME =&quot;headings&quot;>
<OPTION VALUE=&quot;&quot;>Select your heading size
<OPTION VALUE=&quot;H1&quot;> H1
<OPTION VALUE=&quot;H2&quot;> H2
<OPTION VALUE=&quot;H3&quot;> H3
<OPTION VALUE=&quot;H4&quot;> H4
<OPTION VALUE=&quot;H5&quot;> H5
<OPTION VALUE=&quot;H6&quot;> H6
<INPUT TYPE=&quot;submit&quot; VALUE=&quot;process&quot;>
<INPUT TYPE=&quot;reset&quot; VALUE=&quot;Clear&quot;>
</SELECT>
<BR>
<SELECT NAME =&quot;Fonts&quot;>
<OPTION VALUE=&quot;&quot;>Select type of Font
<OPTION VALUE=&quot;Times New Roman&quot;>Times New Roman
<INPUT TYPE=&quot;submit&quot; VALUE=&quot;process&quot;>
<INPUT TYPE=&quot;reset&quot; VALUE=&quot;Clear&quot;>
</SELECT>
<BR>
<SELECT NAME =&quot;Colours&quot;>
<OPTION VALUE=&quot;&quot;>Select type colour
<OPTION VALUE=&quot;Cyan&quot;>Cyan
<INPUT TYPE=&quot;submit&quot; VALUE=&quot;process&quot;>
<INPUT TYPE=&quot;reset&quot; VALUE=&quot;Clear&quot;>
<BR>
<BR>
<P>

<!--- End of SECTION1 HEADING1 Input --->

And then on the Action page I Output the variables by
referencing its corresponding variable name from the first page:
<CFOUTPUT>
<CFIF #headings# is &quot;&quot; AND #Fonts# is &quot;&quot; AND #Colours# is &quot;&quot;>
#Heading#

<CFELSEIF #Headings# IS NOT &quot;&quot; AND #Fonts# IS &quot;&quot; AND #Colours# IS &quot;&quot;>
<#Headings#> #Heading# </#Headings#>

<CFELSEIF #Headings# IS &quot;&quot; AND #Fonts# IS NOT &quot;&quot; AND #Colours# IS &quot;&quot;>
<font Face=&quot;#Fonts#&quot;> #Heading# </Font>

<CFELSEIF #Headings# IS &quot;&quot; AND #Fonts# IS &quot;&quot; AND #Colours# IS NOT &quot;&quot;>
<FONT COLOR=&quot;#Colours#&quot;> #Heading# </Font>

<CFELSEIF #Headings# IS NOT &quot;&quot; AND #Fonts# IS NOT &quot;&quot; AND #Colours# IS &quot;&quot;>
<#Headings#> <Font Face=&quot;#Fonts#&quot;> #Heading# </font> </#Headings#>

<CFELSEIF #Headings# IS NOT &quot;&quot; AND #Fonts# IS &quot;&quot; AND #Colours# IS NOT &quot;&quot;>
<#Headings#> <FONT COLOR=&quot;#Colours#&quot;> #Heading# </Font> </#Headings#>

<CFELSEIF #Headings# IS &quot;&quot; AND #Fonts# IS NOT &quot;&quot; AND #Colours# IS NOT &quot;&quot;>
<Font Face=&quot;#Fonts#&quot;> <FONT COLOR=&quot;#Colours#&quot;> #Heading# </Font> </Font>

<CFELSEIF #Headings# IS NOT &quot;&quot; AND #Fonts# IS NOT &quot;&quot; AND #Colours# IS NOT &quot;&quot;>
<#Headings#> <Font Face=&quot;#Fonts#&quot;> <FONT COLOR=&quot;#Colours#&quot;> #Heading# </Font> </Font> </#Headings#>
</cfif>
</CFOUTPUT>
<BR>
<CFOUTPUT>
<CFIF #headings# is &quot;&quot; AND #Fonts# is &quot;&quot; AND #Colours# is &quot;&quot;>
#Section1Heading1#

<CFELSEIF #Headings# IS NOT &quot;&quot; AND #Fonts# IS &quot;&quot; AND #Colours# IS &quot;&quot;>
<#Headings#> #Section1Heading1# </#Headings#>

<CFELSEIF #Headings# IS &quot;&quot; AND #Fonts# IS NOT &quot;&quot; AND #Colours# IS &quot;&quot;>
<font Face=&quot;#Fonts#&quot;> #Section1Heading1# </Font>

<CFELSEIF #Headings# IS &quot;&quot; AND #Fonts# IS &quot;&quot; AND #Colours# IS NOT &quot;&quot;>
<FONT COLOR=&quot;#Colours#&quot;> #Section1Heading1# </Font>

<CFELSEIF #Headings# IS NOT &quot;&quot; AND #Fonts# IS NOT &quot;&quot; AND #Colours# IS &quot;&quot;>
<#Headings#> <Font Face=&quot;#Fonts#&quot;> #Section1Heading1# </font> </#Headings#>

<CFELSEIF #Headings# IS NOT &quot;&quot; AND #Fonts# IS &quot;&quot; AND #Colours# IS NOT &quot;&quot;>
<#Headings#> <FONT COLOR=&quot;#Colours#&quot;> #Section1Heading1# </Font> </#Headings#>

<CFELSEIF #Headings# IS &quot;&quot; AND #Fonts# IS NOT &quot;&quot; AND #Colours# IS NOT &quot;&quot;>
<Font Face=&quot;#Fonts#&quot;> <FONT COLOR=&quot;#Colours#&quot;> #Section1Heading1# </Font> </Font>

<CFELSEIF #Headings# IS NOT &quot;&quot; AND #Fonts# IS NOT &quot;&quot; AND #Colours# IS NOT &quot;&quot;>
<#Headings#> <Font Face=&quot;#Fonts#&quot;> <FONT COLOR=&quot;#Colours#&quot;> #Section1Heading1# </Font> </Font> </#Headings#>
</cfif>
</CFOUTPUT>

But as mentioned, a formatting choice for the variable #heading# is also being used for the variable #section1heading1#. The are not distinct?

Am I missing something here?

Thanx for simply taking the time to read through, let alone attempt a reply :)

Regards
Sam...
 
Hey Sam,

I may be missing something but your select boxes are named the same for both sections. I would think you would want them distinct. If inputs have the same value, I think the browser will put the two values together separated by a comma. If I understand your problem, I think you need to rename the select boxes in the second section.

Also, I think you can condense your cfif statements like this

<cfif headings neq &quot;&quot;><#Headings#></cfif>
<cfif fonts neq &quot;&quot;> <Font Face=&quot;#Fonts#&quot;></cfif>
<cfif clours neq &quot;&quot;><FONT COLOR=&quot;#Colours#&quot;></cfif>
#Heading#
<cfif headings neq &quot;&quot;></Font></cfif>
<cfif fonts neq &quot;&quot;> </Font></cfif>
<cfif clours neq &quot;&quot;> </#Headings#></cfif>

Hope this helps,
GJ
 
oops,

<cfif headings neq &quot;&quot;></Font></cfif>
<cfif fonts neq &quot;&quot;> </Font></cfif>
<cfif clours neq &quot;&quot;> </#Headings#></cfif>

should be

<cfif headings neq &quot;&quot;></#Headings#></cfif>
<cfif colours neq &quot;&quot;></Font></cfif>
<cfif fonts neq &quot;&quot;></Font></cfif>

GJ
 
Thanx GJ,
Invaluable help once again :)

Ive got another problem that maybe you could help with?
Ive posted a fresh one...maybe you can help

Thanx once again

Sam
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top