get the value of radio button and save into database

Reply

Join Date: Dec 2008
Posts: 6
Reputation: mm2409 is an unknown quantity at this point 
Solved Threads: 0
mm2409 mm2409 is offline Offline
Newbie Poster

get the value of radio button and save into database

 
0
  #1
Dec 5th, 2008
Hi,

i have a html form for questionnaire whr i have few question.

each one has 2 radio button (yes/no). if value for radio button 'yes' is selected then activate text box to write the comment.

if radio button is selected for 'No' then text box should be disable.

similarly for rest questions (8 question)

now the problem is i m facing how to save the values for each question into table.
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 1,175
Reputation: stephen84s is a glorious beacon of light stephen84s is a glorious beacon of light stephen84s is a glorious beacon of light stephen84s is a glorious beacon of light stephen84s is a glorious beacon of light stephen84s is a glorious beacon of light 
Solved Threads: 125
Featured Poster
stephen84s's Avatar
stephen84s stephen84s is offline Offline
Veteran Poster

Re: get the value of radio button and save into database

 
0
  #2
Dec 5th, 2008
This sounds more like a Javascript question as opposed to a PHP question.
Well all you have to do is on the radio button you have to define an "onclick" (or onchange but it doesn't work with IE) event on the two radio buttons like below :-

  1. <form>
  2. <input type="radio" id="radio1" name="radio2" onclick="document.getElementById('txt1').disabled=true"/>Beta <br />
  3. <input type="radio" id="radio1" name="radio2" onclick="document.getElementById('txt1').disabled=false"/>Gamma<br />
  4. <input type="text" name="txt1" id="txt1" /><br />
  5. </form>

Note onclick has been assigned the Javascript code that we wish to execute when someone clicks on the radio button.
Last edited by stephen84s; Dec 5th, 2008 at 11:26 am.
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand."

"How to ask questions the smart way ?"
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 6
Reputation: mm2409 is an unknown quantity at this point 
Solved Threads: 0
mm2409 mm2409 is offline Offline
Newbie Poster

Re: get the value of radio button and save into database

 
0
  #3
Dec 5th, 2008
hi stephen84s,
thx for your response.

well my problem starts from here only. i have done the text box enable/disable but find problem in php/mysql code part to get the values and insert into db for all of the questions based upon the radio button option.

table structure:
1. Question_ID int (11)
*auto increment
2. Questionnaire_ID varchar(50)
*random generated by using uniquid()
3. Question_Words longtext
*value in text box
4. Answer_Type enum('Text', 'List', 'YesNo')
*What type of response? Yes/No
5. Question_Order int (11)
*Order in list of questions
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the PHP Forum


Views: 3748 | Replies: 2
Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC