Jump to content

Recommended Posts

I know that there is a way to this with javascript, but I don't know how it would work.  I am much more familiar with php so I figured I would ask here to see if anyone might have a good php solution.

 

I'm trying to have a form text field display depending on whether or not the user checks a specific box, but I'm not sure where to start.  I've searched around but I didn't find anything that would help.  Basically I want to have a checkbox that asks if the user would like to link their account to an email address.  If the checkbox is selected, a textbox will then appear on the page for them to enter an email address.  Can anyone point me in the right direction on where to start?  Thanks for your help.

Using Javascript would be your best solution, and less time consuming on your part.

By adding an onclick property to the checkbox, you can alter the display properties of a specific input element causing it top appear.

 

The back-end of this, would be simple: if the specific checkbox is selected validate the input element - else, don't.

 

This can be done with PHP, sure. But the user will need to submit the form, and you need to validate it and generate the HTML for the input element; and then output it... again.

I can't think of any tutorials for this specific task, but I would suggest reading up on jQuery. It makes working with Javascript much easier.

Here's a guide on checkbox/radio manipulation with jQuery: http://www.techiegyan.com/2008/07/09/using-jquery-check-boxes-and-radio-buttons/

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.