Not able to get onclick working for <g:actionSubmit

Siri Y

New member
Hi,
I am not able to proceed with this issue since yesterday, Here is what i have in my gsp page

<body>
<script type="text/javascript">
function onClickCustomer(){
${'-----------------------Entered into the FUNCTION---------------------'}
document.getElementById('DeviceInfo').style.display = 'visibile';
}
</script>
<div>
<td><label> </label><g:actionSubmit value="Submit" onclick="return onClickCustomer()"/></td>

<table name="DeviceInfo" align="center" width="1200" style="border-width:1px; border-style: solid; visibility: hidden">
<tr >
<g:each in="${dateList}" var="info">
<td style="border-width:1px; border-style: solid;">${info}<br></td>
</g:each>
</tr>
<g:each in="${Details}" var="e">
<tr style="border-width:1px; border-style: solid;">
<g:each in="${e}" var="info">
<td style="border-width:1px; border-style: solid;">${info}<br></td>
</g:each>
</tr>
</g:each>
</table>
</div>
<body>

I want to dislpay the table DeviceInfo, onclick of Submit button on screen. I can see the Submit button and the table is also generated if its not hidden. Only problem is onclick for submit is not working at all and i am not sure what else should i try to replace onclick event.

Thanks,
Siri
 

dave

Administrator
Staff member
Not sure if you are actually trying to calling an action in a controller there or not.. It doesn't look like it so for a start replace

<g:actionSubmit value="Submit" onclick="return onClickCustomer()"/>

with

<button value="Submit" onClick="onClickCustomer()"/>

and rather than have visibility:hidden, change that to 'display:none" as you are changing the 'display' style not the 'visibility' style. , also in your onclick change .........style.display='visibile' to ......style.display='block'

Also perhaps 'Submit' is a misleading button caption to your user, as you aren't submitting anything, just showing the already generated table, so 'Show Device Info' might be a better phrase.
 
Top