based on a condition display gsp body content

D

Dimple15

Guest
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" %>

<html>
<head>
<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/jquery.tools.min.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;
alert("splitlength"+splitlength);

</script>
</head>
<body>
<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>
</div>
<g:link controller="outlet" action="firewall">
<img src="../../images/home-btn.png" title="Home" />
</g:link>
<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>
<div class="transfer">
<g:if test="${currentLocationId != null}">
<label for="tableTransfer">Table Transfer</label>
<g:checkBox name="tableTransfer" id="tableTransfer" onclick="transferTable()"/>
</g:if>

</div>
<input name="outlet.id" type="hidden" value="${outletInstance?.id}" />
</g:form>
<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" />
</g:if>
<div class="tablediv">
<div class="table ${currentLocationId == locationInstance.id ? '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="location.id" name="location.id" type="hidden" value="${locationInstance?.id}" />
<input id="outlet.id" name="outlet.id" type="hidden" value="${outletInstance?.id}" />
<!--<g:submitButton name="select" class="submit_button" value="Change" />-->
</g:form>
</div>

</div>
</g:each>
</div>
</div>
</div>
</body>
</html>



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.
 

dave

Administrator
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.

e.g

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