Home > Elgg Only, Java Script, Logic, open source products, Web Tech Terms > How to set radiobox checked in Elgg

How to set radiobox checked in Elgg

In Normal HTML we can easily set radio box checked as like below..

<input type="radio" name="color" value="Red" />
<input type="radio" name="color" value="Green" checked="checked" />
<input type="radio" name="color" value="Yellow" />
But what we do if we use PHP & also especially in Elgg,
<?php echo elgg_view(‘input/radio’,array(‘internalid’ => ‘cur_radio’,’internalname’ => ’employer’, ‘options’=>array(elgg_echo(‘Current Employer’) => “current”), ‘value’ => $vars[‘entity’]->employer));?>
<?php echo elgg_view(‘input/radio’,array(‘class’ => ’employer’,’internalname’ => ’employer’, ‘options’=>array(elgg_echo(“Previous Employer”) => “previous”), ‘value’ => $vars[‘entity’]->employer));?>
To select one radio button as checked u can do as follows using javascript …
<script type=”text/javascript“>
$(document).ready(function(){
    $(“#cur_radio”).attr(“checked”,”checked”);
});
</script>
Similarly for pulldown use in javascript as follows..
         $(“#cur_radio”).attr(“disabled”,”disabled”);
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: