- Posts: 108
- Thank you received: 2
Registration Custom Fields Depend On Checkbox
After i bought my second copy i need in that website to have at registration 2 options: register as a shopper or register as a affiliate.
The affiliate box is handling that, but i need to add fields when someone is requesting to sign as affiliate (custom fields).
How can i have when the checkbox is clicked, some fields will be displayed and when is off they will be hidden and unavaliable?
Thanks in advance!
Please Log in or Create an account to join the conversation.
What you should do is to edit file "registration" of the view "user" via the menu Display->Views. There, you could add some javascript to hide/display the custom fields area based on the value of that affiliate checkbox. The only limitation you will have with this method is that your custom fields can't be required. You will also need to know PHP and javascript to do that.
Please Log in or Create an account to join the conversation.
How can i require those fields?
Please Log in or Create an account to join the conversation.
You would have to leave then not required in HikaShop and add some more customization in the file "step" of the view "checkout" so that when the user clicks on the next button, you check with some javascript that the fields are not empty.
Please Log in or Create an account to join the conversation.
I have done this:
<script language="text/javascript">
function showhidefield()
{
if (document.'hikashop_checkout_form.hikashop_affiliate_checkbox.checked)
{
document.getElementById("hideablearea").style.display = "block";
}
else
{
document.getElementById("hideablearea").style.display = "none";
}
}
</script>
this is in the header.
and i have the manual fields coverd in div hideablearea:
<div id='hideablearea' style='display:none'>
<tr class="hikashop_registration_placement_line">
...
<span class="hikashop_field_required">*</span>
</td>
</tr>
</div>
And i add the onclick for the checkbox:
<input class="hikashop_affiliate_checkbox" id="hikashop_affiliate_checkbox" type="checkbox" name="hikashop_affiliate_checkbox" onclick="showhidefield()" value="1" <?php echo $this->affiliate_checked; ?> /></span>
Do you have any idea why that wont work?
Thanks alot!
Please Log in or Create an account to join the conversation.
document.'hikashop_checkout_form.hikashop_affiliate_checkbox.checked
instead of:
document.hikashop_checkout_form.hikashop_affiliate_checkbox.checked
in your function.
Please Log in or Create an account to join the conversation.
Any suggestions?
Please Log in or Create an account to join the conversation.
Do you have a link to that page ?
Please Log in or Create an account to join the conversation.
<script type="text/javascript">
function showhidefield()
{
if (document.hikashop_registration_form.hikashop_affiliate_checkbox.checked)
{
alert("Checked True");
document.getElementById("hideablearea").style.display = "block";
}
else
{
document.getElementById("hideablearea").style.display = "none";
}
}
</script>
and now i get in the alert but nothing happens..
Here is a link: **** .
EDIT: Never mind, i fixed it. Apprently the div was not displayed right, so the function couldnt hide the non-exsisting div.
Thank you for you help!
Please Log in or Create an account to join the conversation.
Once i complete the registration the address is not been saved..
I added 2 inputs as it appear in the front page (<tr><td><lable>....)
and added a visible/invisible divs.
OnClick disable all the hideableareaX divs.
the 2 inputs are not required in Hikashop config.
When i remove my custom part, the registration is working fine.
Could you tell me what made Hikashop not save the address?
Code:
<tr class="hikashop_registration_placement_line">
<?php
$lang =& JFactory::getLanguage();
?>
<td class="key">
<div id='hideablearea0' >
<label for="user_placement"><?php if($lang->getName() == 'Hebrew'){echo "מקום";}else{echo "Placement";}?></label>
</div>
</td>
<td>
<div id='hideablearea1'>
<input id="user_placement" class="inputbox" type="text" value="" name="data[user][user_placement]">
<span class="hikashop_field_required">*</span>
</div>
</td>
</tr> <tr><td colspan="2"><div id='hideablearea2' ><?php echo '<br />' . JText::_('HIKA_PLACEMENT_EXPLAIN');?></div></td> </tr>
<tr class="hikashop_registration_position_line">
<td class="key">
<div id='hideablearea3'>
<label for="position"><?php if($lang->getName() == 'Hebrew'){echo "עמדה";}else{echo "Position";}?></label>
</div>
</td>
<td>
<div id='hideablearea4' >
<select id="position" size="1" name="data[user][position]">
<option id="position_Left" selected="selected" value="Left"><?php if($lang->getName() == 'Hebrew'){echo "שמאל";}else{echo "Left";}?></option>
<option id="position_Right" value="Right"><?php if($lang->getName() == 'Hebrew'){echo "ימין";}else{echo "Right";}?></option>
</select>
<span class="hikashop_field_required">*</span>
</div>
</td>
</tr>
<tr><td colspan="2"><div id='hideablearea5' > <?php echo '<br />' . JText::_('HIKA_POSITION_EXPLAIN');?></div></td></tr>
Please Log in or Create an account to join the conversation.
But you're talking about the address not being saved.
If your custom fields are address custom fields, you should have the name data[address][position] instead.
Please Log in or Create an account to join the conversation.
Both costum fields are user fields.
The bug is that somehow the address is not been saved..
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
When i remove the code above, it's working again, but when i add it back it's not saving the address.
I can't find the connection..
EDIT: I just found out it does save nothing but the email, full name and user name.. maybe that can help.
Please Log in or Create an account to join the conversation.
You say you didn't add anything else, but I suppose that you added some JS code right ? Maybe it comes from the js ?
Please Log in or Create an account to join the conversation.
<script type="text/javascript">
function showhidefield()
{
if (document.hikashop_checkout_form.hikashop_affiliate_checkbox.checked)
{
document.getElementById("hideablearea0").style.display = "block";
document.getElementById("hideablearea1").style.display = "block";
document.getElementById("hideablearea2").style.display = "block";
document.getElementById("hideablearea3").style.display = "block";
document.getElementById("hideablearea4").style.display = "block";
document.getElementById("hideablearea5").style.display = "block";
}
else
{
document.getElementById("hideablearea0").style.display = "none";
document.getElementById("hideablearea1").style.display = "none";
document.getElementById("hideablearea2").style.display = "none";
document.getElementById("hideablearea3").style.display = "none";
document.getElementById("hideablearea4").style.display = "none";
document.getElementById("hideablearea5").style.display = "none";
}
}
</script>
I don't think it might me the problem..
Please Log in or Create an account to join the conversation.
Otherwise, that might create such problem as the field data would be missing.
Please Log in or Create an account to join the conversation.
I dont know why did it displayed with [user] before when i copied it..
Thanks again
Please Log in or Create an account to join the conversation.