Jump to content

Inserting checkbox values into one field

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
8 replies to this topic

#1
ebosysindia

ebosysindia

    Newbie

  • Members
  • PipPip
  • 25 posts
Hi,

I have a checkboxes on my page (.aspx) like

checkbox1 - item1
checkbox2 - item2
checkbox3 - item3
etc

what i want is that when a user selects certain checkboxes
they should be inserted into a table called
customer which has fields (customer id and actions)

the data should be inserted as

customerid actions
1 item1,item2,item3
2 item1,item3
3 etc..

i.e all the values should be inserted into database into one field separated by commas.

Thanks

#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,822 posts
What code do you have so far for inserting the data?
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
ebosysindia

ebosysindia

    Newbie

  • Members
  • PipPip
  • 25 posts
I want text code inserting in the data

#4
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,822 posts
No, what ASP code do you have written already?
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#5
ebosysindia

ebosysindia

    Newbie

  • Members
  • PipPip
  • 25 posts
still, i am not coding for that, before coding i want some help about it.

#6
hkp

hkp

    Learning Programmer

  • Members
  • PipPipPip
  • 37 posts
I am not sure about it. But according to me use of Ajax or javascript onclick or onselect event can make it.

_______________
Design a website

#7
ebosysindia

ebosysindia

    Newbie

  • Members
  • PipPip
  • 25 posts

hkp said:

I am not sure about it. But according to me use of Ajax or javascript onclick or onselect event can make it.

Thanks for suggestion :)

#8
cdg10620

cdg10620

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 389 posts

hkp said:

I am not sure about it. But according to me use of Ajax or javascript onclick or onselect event can make it.

It depends on if you would like to do this on the Client or the server side. If on the client Javascript is fine. If you would like to do this on the server side you need to put the code in the code behind and have it fire on the event.

-C

#9
gokuajmes

gokuajmes

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 518 posts
well as per what i could get from your question is
1.You have 3 check boxes and after the user has checked the boxes ..

2.Clicks the done button

3.The values selected are entered into the SQl Database

here is what you have to carry on from now:

1.Add 3 checkboxes by best bet would we to have a CheckedList box

2.Now add a Button. [Note: buttons always have the AutoPostBack property set to True ]

3.Now double click the Button. [ you will be taken to the Code Behind file ]

4.add this code to the file:[on the Button1_Onclick event handler ]

string box1, box2, box3;
        if (CheckBox1.Checked == true)
        {
            box1 = CheckBox1.Text;
        }
        else if (CheckBox2.Checked==true)
        {
            box2 = CheckBox2.Text;
        }
        else if (CheckBox3.Checked==true)
        {
            box3 = CheckBox3.Text;
        }