/    Sign up×
Community /Pin to ProfileBookmark

dynamic checkbox show and hide

Hi Folks
It would appear i am a complete JS dipstick %$%$##&
i have a dynamically produced table that list business names and their telephone numbers (code below):

[code]
<cfset rowcounter = 0>
<cfloop query=”freelist” startrow=”#URL.offset#” endrow=”#limit#”>
<cfif isDefined(“rowcounter”)>
<cfset rowcounter = rowcounter+1>
</cfif>
<cfoutput>
<form name=”form#rowcounter#” method=”post” action=””>
<tr bgcolor=”###iif(currentrow MOD 2,DE(‘ebebeb’),DE(‘ffffff’))#” class=”smalltext11light”>
<td width=”76%”>&nbsp;#freelist.busname# </td>
<td width=”4%”>
<input type=”checkbox” name=”chk#rowcounter#” onclick=”showhidefield()”> </td>
<td width=”20%”><div id=’hide’ style=’display:none’> #freelist.busphone#</div></td>
</tr>
</form>
</cfoutput>
</cfloop>
[/code]

as you can see i have included a checkbox in each individual for that will display the telephone number for that business when clicked and as you can see when the page loads the telephone is blank.

I have a js function (below)

[code]
<script language=”JavaScript”>
function showhidefield(){
if (document.form.chk.checked)
{document.getElementById(“hide”).style.display = “block”;}
else
{document.getElementById(“hide”).style.display= “none”;}
}
</script>
[/code]

What (i think) i need to do is populate that function with the correct variables to show the correct phone number when the appropriate checkbox is clicked.

Can someone please help me
cheers and thanks in advance
Grabit

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @grabit spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...