/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] Add / subtract a form field

I have an ASP page that has a (Yes) (No) radio that I would like to use as an ONCHANGE event…

if the radio (No) is ticked I want one field (Text and an INPUT box html) added and the (Yes) fields taken away
if the radio (Yes) is ticked I want 3 fields (Text and an INPUT box html) added and the (No) field taken away

is this possible???

If it is Please help… if it is NOT… please reply so I can stop hurting my head by banging it on the wall!! :rolleyes:

to post a comment
JavaScript

6 Comments(s)

Copy linkTweet thisAlerts:
@thechasboiOct 13.2006 — Renigade

What you could do is change the display setting of the objects from none to block. Use the style elements of the objects parent tag to display it or not. The difference between display and visibility is that if invisible it still takes up space if on the same layer but with display it will seem to appear out of no where. Hope this helps
Copy linkTweet thisAlerts:
@RenigadeauthorOct 13.2006 — I can do this in a HTML/ASP page... this is not .net
Copy linkTweet thisAlerts:
@JMRKEROct 13.2006 — Consider this:
[code=php]
<html>
<head>
<title>Yes/No Fields</title>
<script type="text/javascript">
function CollectInfo(idInfo) {
document.getElementById('YesInfo').style.display = 'none';
document.getElementById('NoInfo').style.display = 'none';
document.getElementById(idInfo).style.display = 'block';
}
</script>
</head>
<body>
<form>

Do you live alone?:
<input type="radio" name='YNinfo' onChange="CollectInfo('YesInfo')">Yes
<input type="radio" name='YNinfo' onChange="CollectInfo('NoInfo')">No
<p>

<div id='YesInfo' style='display:none'>
Your Name: <input id='YourName' type="text" value="">
</div>

<div id='NoInfo' style='display:none'>
Guaridan Name: <input id='Guardian' type="text" value="">
Domicile
City: <input id='City' type="text" value="">
State: <input id='State' type="text" value="">
</div>

</form>
</body>
</html>
[/code]
Copy linkTweet thisAlerts:
@thechasboiOct 13.2006 — Renigade

First write some code to check to see if a radio button is checked or not if so then display the div that contains your objects. If I understand your question correctly this seems to be the answer. It does not need to be programmed in .NET. I am wqorking on this very large web based application that uses .net, asp, and javascript.

Hope this helps
Copy linkTweet thisAlerts:
@RenigadeauthorOct 13.2006 — Consider this:
[code=php]
<html>
<head>
<title>Yes/No Fields</title>
<script type="text/javascript">
function CollectInfo(idInfo) {
document.getElementById('YesInfo').style.display = 'none';
document.getElementById('NoInfo').style.display = 'none';
document.getElementById(idInfo).style.display = 'block';
}
</script>
</head>
<body>
<form>

Do you live alone?:
<input type="radio" name='YNinfo' onChange="CollectInfo('YesInfo')">Yes
<input type="radio" name='YNinfo' onChange="CollectInfo('NoInfo')">No
<p>

<div id='YesInfo' style='display:none'>
Your Name: <input id='YourName' type="text" value="">
</div>

<div id='NoInfo' style='display:none'>
Guaridan Name: <input id='Guardian' type="text" value="">
Domicile
City: <input id='City' type="text" value="">
State: <input id='State' type="text" value="">
</div>

</form>
</body>
</html>
[/code]
[/QUOTE]



YES!!!!!... That is it!

THANK YOU ?
Copy linkTweet thisAlerts:
@JMRKEROct 13.2006 — Your welcome. Glad I could help this time!
×

Success!

Help @Renigade 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.6,
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,
)...