Solved

Radiobuttonlist

Posted on 2006-10-20
10
202 Views
Last Modified: 2010-04-16
Hi there,

      I have the following program to do and I have no idea. I hope I will get some help.
The client will follow the survey and based on what they select, they will get points and the points are laid out as follows:


Answers:               ROP   FSI    Cable   BTV    Radio    Direct Mail

Lead Gen               4         4         1        1         3                4

New Cust               3         3         3        3         3                3

For, eg if they select lead gen, they will get the scores for ROP, FSI, Cable, BTV, Radio and Direct Mail. There are 11 questions and at the end, the scores will add like this:

Answers:               ROP   FSI    Cable   BTV    Radio    Direct Mail

Lead Gen               4         4         1        1         3                4

New Cust               3         3         3        3         3                3

…….

…….

Total                     Total   Total    Total   Total    Total          Total

based on the total they will get two suggestions to go, the highest total followed by the second highest.

I hope this makes clear.

Thank you all in advance.

 





0
Comment
Question by:siddhuoops
  • 6
  • 4
10 Comments
 

Author Comment

by:siddhuoops
ID: 17777348
I really need help. Could somebody help??
0
 
LVL 1

Accepted Solution

by:
pascalprob earned 500 total points
ID: 17791789
I am assuming you are attempting a web-based solution, and as your topic suggests, you are planning on using a radiobuttonlist.
You will need a seperate radiobuttonlist for each question.

Initialize a variable for each of your "columns". (One for ROP, one for RSI etc);

When the user clicks submit, set a variable with the selected item's value property. The value property will simply be a list of the points for each column. Then add the points for each column to the variable for each column, as I've shown below. If you have any questions, feel free to ask. This will work as long as the points you can gain for each column per question are smaller than or equal to 9 - in other words, no double figures.

<%@ Page Language="C#" %>
<script runat="server">

    int var1 = 0; // column1 eg: ROP
    int var2 = 0; // column 2 eg: FSI
    int var3 = 0; // column 3 eg: Cable
   
    void Button1_Click(object sender, EventArgs e) // Submit button click
    {
        string q1AllCols = RadioButtonList1.SelectedItem.Value; // This will be set to "156" OR "213" OR "355"
        string q2AllCols = RadioButtonList2.SelectedItem.Value; // This will be set to "472" OR "590" OR "627"
   
        var1 += int.Parse(q1AllCols[0].ToString());
        var1 += int.Parse(q2AllCols[0].ToString());
   
        var2 += int.Parse(q1AllCols[1].ToString());
        var2 += int.Parse(q2AllCols[1].ToString());
   
        var3 += int.Parse(q1AllCols[2].ToString());
        var3 += int.Parse(q2AllCols[2].ToString());
   
        Label1.Text = "Col 1 adds to: " + var1;
        Label2.Text = "Col 2 adds to: " + var2;
        Label3.Text = "Col 3 adds to: " + var3;
    }

</script>
<html>
<head>
</head>
<body>
    <form runat="server">
        <asp:RadioButtonList id="RadioButtonList1" runat="server">
            <asp:ListItem Value="156">Always</asp:ListItem>
            <asp:ListItem Value="213">Sometimes</asp:ListItem>
            <asp:ListItem Value="355">Never</asp:ListItem>
        </asp:RadioButtonList>
        <br />
        <br />
        <asp:RadioButtonList id="RadioButtonList2" runat="server">
            <asp:ListItem Value="473">Always</asp:ListItem>
            <asp:ListItem Value="590">Sometimes</asp:ListItem>
            <asp:ListItem Value="627">Never</asp:ListItem>
        </asp:RadioButtonList>
        <br />
        <br />
        <asp:Button id="Button1" onclick="Button1_Click" runat="server" Text="Submit"></asp:Button>
        <br />
        <br />
        <asp:Label id="Label1" runat="server"></asp:Label>
        <br />
        <asp:Label id="Label2" runat="server"></asp:Label>
        <br />
        <asp:Label id="Label3" runat="server"></asp:Label>
    </form>
</body>
</html>


0
 

Author Comment

by:siddhuoops
ID: 17796806
Thanks a lot. It worked out great.
0
 

Author Comment

by:siddhuoops
ID: 17796876
Ok! now I have to do this. Once, I have the total for each column, on the next page I have to display just the two totals depending which column got the highest followed by the second highest. For eg. if ROP = 36, FSI=45, Cable=25, BTV=29, Radio=28 and Direct Mail=40 then I would have to show or in other words give the client a recommendation to use just the two options. In this case, FSI has the highest point followed by the Direct Mail. Then, the last page would say "based on your campaign objectives, we would recommend the following in the order they appear:
1) FSI
2) Direct Mail

Let me know if you didn't understand what I really want.
0
 
LVL 1

Expert Comment

by:pascalprob
ID: 17797652
Pleasure.

For your second question you will need to put all your column values into an array, and then you can simply sort the array.
See the following code:

int[] cols = {col1Var, col2Var, col3Var, col4Var, col5Var, col6Var};
Array.Sort(cols);

someLabel.Text = "Highest points: " + cols[0];
someLabel2.Text = "Second highest points: " + cols[1];
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:siddhuoops
ID: 17797759
I tried doing it but instead of giving me FSI and Direct Mail since those have the highest point, it gave me the ones that are lowest. For example, in this case, it would be Cable and BTV. Please look at the post above to see what I have assigned the values for all six options.
0
 
LVL 1

Expert Comment

by:pascalprob
ID: 17798068
That is odd. Either way, the array has 6 possible index values, from 0 to 5. If you're finding the lowest values at index 0 and 1, you'll find the highest at index 5 and 4, once you've done the sort. :)

someLabel.Text = "Highest points: " + cols[5];
someLabel2.Text = "Second highest points: " + cols[4];
0
 

Author Comment

by:siddhuoops
ID: 17798103
Hi pascalprob, I modified your above code and was able to get the points for the highest and the second highest. Since, in my case there are 5 columns, so I changed this code to;

someLabel.Text = "Highest points: " + cols[5];
someLabel2.Text = "Second highest points: " + cols[4];

This would give me the highest point followed by the second highest. But instead of showing the points, I want to show them the actual column name. If FSI= 45, the highest and Cable=40 the second highest, then the result would be
1) FSI
2)Cable

How should I do this?

Thank You in advance.
0
 
LVL 1

Expert Comment

by:pascalprob
ID: 17798412
What you need to do is compare the highest and second highest values (45 and 40 as per your example) to each of your column variables.
The most effective way to do this would be to use loops, but for simplicity's sake I will show you how to do it with if statements:

int first = cols[5];
int second = cols[4];

if (first == col1Var)
{
    someLabel.Text = "1) ROP";
}
else if (first == col2Var)
{
    someLabel.Text = "1) FSI";
}
.
. // repeat as necessary
.
else
{
    someLabel.Text = "1) Direct Mail"; // for your last column you don't need to compare the variables - if it's not equal to col1, 2, 3, 4 or 5 then it must be 6
}

Repeat all of the above for the "second" variable.
0
 

Author Comment

by:siddhuoops
ID: 17798526
That worked great. Thanks a lot expert.
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Bit flags and bit flag manipulation is perhaps one of the most underrated strategies in programming, likely because most programmers developing in high-level languages rely too much on the high-level features, and forget about the low-level ones. Th…
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now