based on a condition display gsp body content



Hi I have a gsp pafe where i display 2 radio button options.

Depending on a condition on page load I need to display the radio button;

<%@ page import="operations.Outlet" %>
<%@ page import="operations.Location" %>

<g:javascript library="jquery" plugin="jquery"/>
<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<link href="../../css/emenu.css" rel="stylesheet" type="text/css" />
<script src="../../js/" type="text/javascript"></script>
<script src="../../js/commonscript.js" type="text/javascript"></script>
<script type="text/javascript">
alert('ARRcookies :' +document.cookie);
var split = document.cookie.split(';');
alert("split length" +split);

splitlength = split.length;

<div class="body">
<g:form controller="location" action="doselect">
<div class="device_top">
<span class="device_id">Device ID</span><span class="device_name">${device.title}</span>
<g:link controller="outlet" action="firewall">
<img src="../../images/home-btn.png" title="Home" />
<g:link controller="outlet" action="select" params="[outletId: outletInstance?.id]" class="selectButton tableButton">Outlets</g:link>
<div class="outletTitle">Selected outlet: <b>${outletInstance?.title}</b></div>
<div class="check">

<label for="guestMode">Guest Mode</label>
<g:radio name="modeCheck" id="guestMode" onclick="checkMode('guest')"/>
<label for="stewardMode">Steward Mode</label>
<g:radio name="modeCheck" id="stewardMode" onclick="checkMode('steward')" checked="checked"/>

<div class="transfer">
<g:if test="${currentLocationId != null}">
<label for="tableTransfer">Table Transfer</label>
<g:checkBox name="tableTransfer" id="tableTransfer" onclick="transferTable()"/>

<input name="" type="hidden" value="${outletInstance?.id}" />
<div class="table_layout_and_info" id="table_layout_and_info">
<div class="tables">
<div class="heading">Select Tables</div>
<g:each in="${locationInstanceList}" status="i" var="locationInstance">
<g:set var="locationStatus" value="${locationInstance?.status}" />
<g:if test="${locationInstance?.status == null}">
<g:set var="locationStatus" value="AVAILABLE" />
<div class="tablediv">
<div class="table ${currentLocationId == ? 'this_table' : ''} ${locationStatus == 'occupied' ? 'in_use' : locationStatus == 'vacant' ? 'available' : 'billed'}" onclick="selectTable(${outletInstance?.id}, ${locationInstance?.id}, true)" id="${locationInstance?.id}">
<g:form controller="location" action="change_table_status">
<span class="title">${locationInstance?.title}</span>
<input id="" name="" type="hidden" value="${locationInstance?.id}" />
<input id="" name="" type="hidden" value="${outletInstance?.id}" />
<!--<g:submitButton name="select" class="submit_button" value="Change" />-->


Here i get the value in splitlength.

depending on the vale of this variable i need to display the radio button.

if value is 1 display both the radio buttons and if the value is greater than 1 then display only one radio button.

Can anybody out there please help me out in this.


Staff member
Well as a start I assume you wouldn't want to show the associated labels either, so I'd wrap each label/radiobutton in their own identifiable divs.
Then just a simple bit of jquery calling .hide() in the appropriate circumstance.


if (splitlength > 1) $('#myIdentifyableDiv').hide();