Easiest way to do that is to attach a jQuery listener to its change event and display the hidden field if the currently selected value is company.ianhaney wrote:On the registration form, I have a drop down with User and Company inside it and if the user selects Company I would like the website input field to appear below it
osclass PHP
Moderator: General Moderators
Re: osclass PHP
Re: osclass PHP
You probably don't have to. 'for' attribute of a label tag usually contain the value of id attribute of the field it serves as a description for. So in your case, $('#user_type') will likely return the dropdown you need.to add a id and class to it for the jquery/javascript to work to make it show the hidden input field if Company is selected
Re: osclass PHP
Can we see the resulting html code? Ctrl+U, then post it here or on jsfiddle.net
Re: osclass PHP
This code generates the html the browser consumes, that's what I'd like to see.
Re: osclass PHP
#user_type is the wrapping div, not the select element itself. Also, the select element has no entry with the value "Hide"Code: Select all
<div class="control-group" id="user_type"> <label for="user_type" class="control-label">User type</label> <div class="controls"> <select name="b_company" id="b_company"><option value="0">Private</option><option value="1">Dealer</option></select></div> </div>Code: Select all
$(document).ready(function () { $('#website').hide(); $("#user_type").change(function () { if ($(this).val() == "Hide") { $('#website').hide(); } else { $('#website').show(); } }); });
Re: osclass PHP
Is this what you're trying to achieve? http://jsfiddle.net/gp3cx0Lo/1/
Re: osclass PHP
I don't know the first thing about OSClass; I just based the jQuery on the markup provided. Your JS should be separate anyhow, so you should be able to just copy/paste the JS from the fiddle into a file you have that runs on DOM ready.