EDIT
I'm still getting an error with repeated information on the page when I use the Direct Sctipt as outlined below.
does anyone have any idea why this might be happening?
ORIGINAL QUESTION
I have radio buttons on my site with the options of YES and NO. when set to yes it brings up a further option of the user to input.
My current code checks the Yes Button by default when the page loads, but doesn't trigger the button to take effect and bring up the further options
I'm looking for a way to trigger the Yes button automatically on page load.
I'm New to Magento and don't know anything about Jquery in order to make it work
if someone could take a look at the code and advise me on how to proceed I'd be very grateful
<script type="text/javascript">
if (typeof jQuery == 'undefined'){
document.write(unescape("%3Cscript src='//ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js' type='text/javascript'%3E%3C/script%3E"));
}
</script>
<?php
$helper=Mage::helper('marketplace');
$profile_hint_status = $helper->getProfileHintStatus();
?>
<li class="field" id="wantptr">
<label for="wantpartner" class="required"><?php echo $helper->__('Do You Want To Become A Seller / Vendor?') ?> </label>
<?php
if($profile_hint_status && Mage::getStoreConfig('marketplace/marketplace_profile/become_seller',Mage::app()->getStore())){?>
<img src="<?php echo $this->getSkinUrl('marketplace/images/quest.png'); ?>" class='questimg' title="<?php echo Mage::getStoreConfig('marketplace/marketplace_profile/become_seller',Mage::app()->getStore()) ?>"/>
<?php
} ?>
<div class="input-box">
<input type="radio" id="wantpartner" class="wantpartner" name="wantpartner" value='1' title="<?php echo $helper->__('Agree as Seller') ?>" checked /> <?php echo $helper->__("Yes"); ?>
<input type="radio" id="wantpartner" class="wantpartner" name="wantpartner" value='0' title="<?php echo $helper->__('Disagree as Seller') ?>" /> <?php echo $helper->__("No"); ?>
</div>
</li>
<script>
<?php
if($profile_hint_status && Mage::getStoreConfig('marketplace/marketplace_profile/shopurl_seller',Mage::app()->getStore())){
$shopurl_hint = '<img src="'.$this->getSkinUrl('marketplace/images/quest.png').'" class="questimg" title="'.Mage::getStoreConfig('marketplace/marketplace_profile/shopurl_seller',Mage::app()->getStore()).'"/>';
}else{
$shopurl_hint = '';
} ?>
var $wk_jq= jQuery.noConflict();
$wk_jq(function(){
$wk_jq('#email_address').parents('li').after($wk_jq('#wantptr'));
$wk_jq('#wantptr').show();
$wk_jq('.wantpartner').change(function(){
if($wk_jq(this).val()==1){
$wk_jq('.button').attr('disabled','disabled');
$username=$wk_jq('<li/>').addClass('profileurl')
.append($wk_jq('<label/>')
.addClass('required')
.text('<?php echo $helper->__('Shop URL'); ?>')
.append($wk_jq('<em/>').text('*')))
.append('<?php echo $shopurl_hint ?>')
.append($wk_jq('<div/>')
.addClass('input-box')
.append($wk_jq('<input/>').addClass('input-text')
.attr('title','<?php echo $helper->__(' Shop URL For Your Marketplace Shop ')?>')
.addClass('required-entry')
.attr('type','text')
.attr('name','profileurl'))
.append($wk_jq('<span/>')
.text('<?php echo $helper->__(" (This will be used to display your public profile) ")?>')
.addClass('required-entry')
.attr('type','text'))
)
.append($wk_jq('<div/>')
.attr('id','wk_load_conf')
.append($wk_jq('<img/>')
.attr('src','<?php echo $this->getSkinUrl('marketplace/images/ajax-loader-tr.gif'); ?>')
.attr('height','20px')
.attr('width','20px')));
//$wk_jq('#wantptr').next('li').after($username);
$wk_jq('#wantptr').after($username);
}else{
$wk_jq('.button').removeAttr('disabled');
$wk_jq('.profileurl').remove();
}
});
$wk_jq('ul').delegate('.profileurl input','keyup',function(){
$wk_jq(this).val($wk_jq(this).val().replace(/[^a-z^A-Z^0-9\.\-]/g,''));
});
$wk_jq('#form-validate').delegate('.profileurl input','change', function(){
$wk_jq('.unavailable,.available').remove();
var profileurl=$wk_jq('.profileurl input').val();
$wk_jq('.button').attr('disabled','disabled');
if(profileurl!=''){
$wk_jq('#wk_load_conf').show();
$wk_jq.ajax({
url:'<?php echo $this->getUrl("marketplace/seller/usernameverify")?>',
type:'POST',
data:{profileurl:profileurl},
dataType:'JSON',
success:function(data){
$wk_jq('#wk_load_conf').hide();
if(data==0){
$wk_jq('.button').removeAttr('disabled');
$wk_jq('.profileurl').append($wk_jq('<span/>').addClass('available success-msg').text('<?php echo $helper->__("available")?>'));
}else{
$wk_jq('.profileurl').append($wk_jq('<span/>').addClass('unavailable error-msg').text('<?php echo $helper->__("unavailable")?>'));
}
}
});
}
});
});
</script>
EDIT
We worked it out as this
<div class="input-box">
<input type="radio" id="wantpartneryes" class="wantpartner" name="wantpartner" value='1' title="<?php echo $helper->__('Agree as Seller') ?>" /> <?php echo $helper->__("Yes"); ?>
<input type="radio" id="wantpartner" class="wantpartner" name="wantpartner" value='0' title="<?php echo $helper->__('Disagree as Seller') ?>" /> <?php echo $helper->__("No"); ?>
</div>
<script>
function getdata(){
$wk_jq("#wantpartneryes").prop("checked", true);
$wk_jq("#wantpartneryes").trigger("change"); } setTimeout(getdata,700);
</script>
though it's not perfect, it works but when it triggers the additional option it repeats it's self on the page
Edit
The Direct Code posted in the answer below with the revisions work perfectly