943,583 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 10795
  • PHP RSS
Dec 5th, 2008
0

get the value of radio button and save into database

Expand Post »
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.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
mm2409 is offline Offline
6 posts
since Dec 2008
Dec 5th, 2008
0

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

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 :-

html Syntax (Toggle Plain Text)
  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.
Featured Poster
Reputation Points: 653
Solved Threads: 151
Nearly a Posting Virtuoso
stephen84s is offline Offline
1,316 posts
since Jul 2007
Dec 5th, 2008
0

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

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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
mm2409 is offline Offline
6 posts
since Dec 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: code will not subtract negative number in mysql field? :( pls help!
Next Thread in PHP Forum Timeline: if statement help





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC