Jump to content
zimnicki1127

creating radio buttons through an array in php(need to hide text box)

Recommended Posts

I am working on a project for my job. I have php that creates multiple radio button lists through an array. There are 6 categories that that a list of radio buttons for each of the categories. I am trying to add an onclick javascript function to just one of the radio buttons. There is a text box on the very bottom, I want that to only show up if a certain radio button is clicked.

 

I have the code attached below

 

 

 

<?php
$form_fields
= array(
"id" => array(
"bsc_id",
"fname",
"mname",
"lname",
"email",
"grad_id",
"major_id",
"grad_date",
"deg_id",
"age_id",
"ethn_id",
"res_id",
"assist_id",
"assist_other"
) ,
"name" => array(
"Banner ID",
"First Name",
"Middle Name",
"Last Name",
"E-mail Address",
"Status",
"Major",
"Graduation Date<br/>(mm-yyyy)",
"Degree",
"Age Group",
"Ethnicity",
"Residency",
"Greatest Assistance",
"If Assistance Other"
) ,
"type" => array(
"age_id" => "radio",
"grad_id" => "radio",
"major_id" => "select",
"deg_id" => "radio",
"ethn_id" => "radio",
"grad_date" => "date",
"res_id" => "checkbox",
"assist_id" => "radio"
) ,
"option" => array(
"age_id" => "sql:select * from age_code",
"grad_id" => "sql:select * from grad_code",
"major_id" => "sql:select * from major_code ORDER BY major_text",
"deg_id" => "sql:select * from deg_code",
"ethn_id" => "sql:select * from ethn_code",
"grad_date" => "fields:m-Y",
"res_id" => "sql:select * from res_code",
"assist_id" => "sql:select * from assist_code"
)
);

Share this post


Link to post
Share on other sites

You should not need to add onclick javascript event to radio button using PHP, you should just add a identifier such as id or maybe a class, then use unobtrusive JavaScript to assign the required event to that identifier, its more practical manageable this way.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...