Page 1 of 1

Re: osclass PHP

Posted: Tue Oct 14, 2014 11:48 am
by Celauran
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
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.

Re: osclass PHP

Posted: Tue Oct 14, 2014 12:51 pm
by Weirdan
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
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.

Re: osclass PHP

Posted: Thu Oct 16, 2014 8:50 am
by Weirdan
Can we see the resulting html code? Ctrl+U, then post it here or on jsfiddle.net

Re: osclass PHP

Posted: Thu Oct 16, 2014 9:00 am
by Weirdan
This code generates the html the browser consumes, that's what I'd like to see.

Re: osclass PHP

Posted: Thu Oct 16, 2014 10:31 am
by Celauran

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();
}
 
});
 
});
#user_type is the wrapping div, not the select element itself. Also, the select element has no entry with the value "Hide"

Re: osclass PHP

Posted: Thu Oct 16, 2014 10:56 am
by Celauran
Is this what you're trying to achieve? http://jsfiddle.net/gp3cx0Lo/1/

Re: osclass PHP

Posted: Thu Oct 16, 2014 11:47 am
by Celauran
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.