/    Sign up×
Community /Pin to ProfileBookmark

Toggle with a raio/checkbox button

HI All,

I would like to create a page which has two radio buttons.(which is fairly easy ? ) But I would like to get three text fields when I checked on one of the buttons or two when I click the other.

Any suggestions/ideas how to build on would be of great help.

Thanks
Revz?

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@JMRKERFeb 01.2010 — HI All,

I would like to create a page which has two radio buttons.(which is fairly easy ? ) But I would like to get three text fields when I checked on one of the buttons or two when I click the other.

Any suggestions/ideas how to build on would be of great help.

Thanks

Revz?[/QUOTE]


Which 2 text fields and which 3 text fields (of how many text fields total)?

What do you wish to do with the values in the text fields once acquired?

Do you have a start of any existing code?
Copy linkTweet thisAlerts:
@revzauthorFeb 02.2010 — HI,

For an Example,I have two radio buttons like Exercise and Pilates.If I selected Exercise I should see three text-fields each should take input and has to update the database behind. And if I selected Pilates then it should show two text fields.

As of now, I have just created a web-page with just two radio-buttons. Any suggestions on how to hide/show or toggle would be of great help.

Thanks
Copy linkTweet thisAlerts:
@JMRKERFeb 02.2010 — Do my suggestions here (especially post #2)

help in solving your current problem?

See: http://www.webdeveloper.com/forum/showthread.php?t=223897
Copy linkTweet thisAlerts:
@revzauthorFeb 03.2010 — Do my suggestions here (especially post #2)

help in solving your current problem?

See: http://www.webdeveloper.com/forum/showthread.php?t=223897[/QUOTE]


Hi,

Thanks for pointing me to that!! That was helpful!! butI get the result in a diferent way.

Instead of masking the third text-filed, it disables the the check-boxes that I click.

Here is wat I have done.
<i>
</i>print $dw-&gt;header({'menu' =&gt; 1,
'script' =&gt;"function toggle(value){
for (var i= 1;i&lt;=2;i++){document.getElementById('grp'+i).style.display = 'none';}
var temp = info.split(',')
for (var i = 0;i&lt;temp.length;i++) {document.getElementById('grp'+tmp[i]).style.display = 'block';}}"});


print $additional_html;
print $cgi-&gt;br();
print $cgi-&gt;h4('Assay Registeration');
print $cgi-&gt;br();
print $cgi-&gt;start_form({-name =&gt;'main'});

<i> </i>print $cgi-&gt;start_table({-align =&gt;'centre'});

<i> </i>print $cgi-&gt;th('Select Assay to register');

#This is the options that I should select any one of the two. If I selected the #Taqman then I should see just the grp 1, and grp2 but if I select the other #one then it should show all the three grps
print $cgi-&gt;td($cgi-&gt;checkbox(-name=&gt;'taqman',
-value=&gt;'1,2',
-label=&gt;'TaqMan',
-id=&gt;'taq',
-onclick=&gt;'toggle(this.value)'));

<i> </i>print $cgi-&gt;td($cgi-&gt;checkbox(-name =&gt;'kaspar',
<i> </i> -value=&gt;'1,2,3',
<i> </i> -label=&gt;'KASPAR',
<i> </i> -id=&gt;'kas',
<i> </i> -onclick=&gt;'toggle(this.value)'));

<i> </i>print $cgi-&gt;Tr();
<i> </i>print $cgi-&gt;Tr();
<i> </i>print $cgi-&gt;start_div({-id=&gt;"grp1"});
<i> </i>print $cgi-&gt;th('Allele1');
<i> </i>print $cgi-&gt;td($cgi-&gt;textfield(-name=&gt;'allele1',
<i> </i> -size=&gt;50));
<i> </i>print $cgi-&gt;Tr();
<i> </i>print $cgi-&gt;end_div;
<i> </i>print $cgi-&gt;Tr();
<i> </i>print $cgi-&gt;Tr();
<i> </i>print $cgi-&gt;start_div({-id=&gt;"grp2"});
<i> </i>print $cgi-&gt;th('Allele2');
<i> </i>print $cgi-&gt;td($cgi-&gt;textfield(-name=&gt;'allele2',
<i> </i> -size=&gt;50));

<i> </i>print $cgi-&gt;Tr();

<i> </i>print $cgi-&gt;end_div;
<i> </i>print $cgi-&gt;Tr();
<i> </i>print $cgi-&gt;Tr();

<i> </i>print $cgi-&gt;start_div({-id=&gt;"grp3"});
<i> </i>print $cgi-&gt;Tr();
<i> </i>print $cgi-&gt;th('Common');
<i> </i>print $cgi-&gt;td($cgi-&gt;textfield(-name=&gt;'common',
<i> </i> -size=&gt;50
<i> </i> -id=&gt;'com1',
<i> </i> -onclick=&gt;'toggle()',
<i> </i> -style=&gt;'display: none'
<i> </i> ));


<i> </i>print $cgi-&gt;end_div;
<i> </i>print $cgi-&gt;Tr();
<i> </i>print $cgi-&gt;Tr();
<i> </i>print $cgi-&gt;Tr();

<i> </i>print $cgi-&gt;td($cgi-&gt;submit(-name =&gt;'create',
<i> </i> -value =&gt;'Register',
<i> </i> -onclick=&gt;'return submitForm(this.form)',
<i> </i> ));

<i> </i>print $cgi-&gt;td($cgi-&gt;reset());
<i> </i>print $cgi-&gt;end_form();
<i> </i>print $cgi-&gt;end_table();
<i> </i>print $dw-&gt;footer();
<i> </i>exit;



I couldn't figure where out where I have made mistake ?

Thanks
Copy linkTweet thisAlerts:
@JMRKERFeb 03.2010 — Sorry, I'm not sure I know what programming language you are trying to use.

Is that some dialect of JS?
×

Success!

Help @revz 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.18,
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,
)...