|
| |
|
|
barking mad
Posts: 287 Joined: 12/6/2002 From: Out in the sticks, UK Status: offline
|
I want to shrink my code & make it reusable - 3/14/2009 15:16:42
I have an online questionnaire with many questions, but rather than forver typing all teh form code can it be shortened & if so how please. Here's an excerpt
<%
const qemployee1 = "did you have a company car?"
const qemployee2 = "do you receive other benefits from your employer?"
const qemployee3 = "do you contribute to a pension from your salary?"
const qemployee4 = "have you changed jobs this tax year?"
const qemployee5 = "do you have more than one job?"
const leftcol = "<tr><td class='left'>"
const midcol = "</td><td class='right'>"
const rightcol = "</td></tr>"
%>
<%
question = qemployee1
inputfield = "employee1"
response.write leftcol & question & midcol & " yes <input name='" & inputfield & "' type='radio' value='1' /> no <input name='" & inputfield & "' type='radio' value='0' checked />" & rightcol
question = qemployee2
inputfield = "employee2"
response.write leftcol & question & midcol & " yes <input name='" & inputfield & "' type='radio' value='1' /> no <input name='" & inputfield & "' type='radio' value='0' checked />" & rightcol
question = qemployee3
inputfield = "employee3"
response.write leftcol & question & midcol & " yes <input name='" & inputfield & "' type='radio' value='1' /> no <input name='" & inputfield & "' type='radio' value='0' checked />" & rightcol
question = qemployee4
inputfield = "employee4"
response.write leftcol & question & midcol & " yes <input name='" & inputfield & "' type='radio' value='1' /> no <input name='" & inputfield & "' type='radio' value='0' checked />" & rightcol
question = qemployee5
inputfield = "employee5"
response.write leftcol & question & midcol & " yes <input name='" & inputfield & "' type='radio' value='1' /> no <input name='" & inputfield & "' type='radio' value='0' checked />" & rightcol
%>
basically I want to be able to feed the parameters into a subroutine (or something) and have it display the info , so something like response.write yesnoquestion where yesnoquestion generates the code to be used. ... and if you were being really clever create a loop which changes the number fo rthe variable to be used! Any ideas?
_____________________________
The more I ask, the more I learn, the more I' m confused, therefore the more I ask ...
|
|
New Messages |
No New Messages |
Hot Topic w/ New Messages |
Hot Topic w/o New Messages |
Locked w/ New Messages |
Locked w/o New Messages |
|
Post New Thread
Reply to Message
Post New Poll
Submit Vote
Delete My Own Post
Delete My Own Thread
Rate Posts
|
|
|