/    Sign up×
Community /Pin to ProfileBookmark

SuperN00B, help please.

I have a form with 2 radio button at the beginning. It is so the user can choose what program they want. We’ll call them program 1 and program 2. Down below that, there is some field with user info. (Name, client_id, etc…)
All the required fields are bold.

My question is, is there way that if they choose program 1, certain fields are required and if they choose program 2, certain other fields are required? I can do that with PHP, but as far as making the required fields bold, I need help with. I have been frustrated by this forever and can’t seem to find an answer anywhere. I searched the documentation, 5 different forums, tutorials, pre made scripts, you name it, i tried it. PLEASE HELP. Thank you in advance.

to post a comment
JavaScript

6 Comments(s)

Copy linkTweet thisAlerts:
@konithomimoMay 05.2005 — There are many ways. One of the easiest is to just have the form load in a div or frame and then have two seperate forms. Doing that is mainly just copying and pasting.
Copy linkTweet thisAlerts:
@fivehandgangauthorMay 05.2005 — That's what i did, thanks. However, for future reference if anyone can tell me how to do that without using different forms, please post. If I find out, I will post as well.
Copy linkTweet thisAlerts:
@UltimaterMay 05.2005 — You can use an onsubmit event handler on the FORM and see if the user filled out all of the required fields in their case.

As far as showing bold text for each required field and updating it, you can use a SPAN tag.

<span id="address_text" style="font-weight: none;">Address</span><input type="text" name="address">

Then you can dynamicly make the text bold and back again.

document.getElementById("address_text").style.fontWeight="bold"

I'll write a working example for you.
Copy linkTweet thisAlerts:
@UltimaterMay 05.2005 — [code=html]
<span id="address_text" style="font-weight: none;">Address</span><input type="text" name="address">
<input type="button" onclick="emp()" value="EMP"><input type="button" onclick="usr()" value="USR">
<script type="text/javascript">
function emp(){
document.getElementById("address_text").style.fontWeight="bold"
}
function usr(){
document.getElementById("address_text").style.fontWeight=""
}
</script>
[/code]
Copy linkTweet thisAlerts:
@fivehandgangauthorMay 06.2005 — That works great for a single field. How do you change 2 or more fields with the click of just the one button? I tried giving all the fields I want bolded the same span id, that didn't work. I tried copying the bolding finction and renaming it and stuff and then using to onClick statements on the button, that didn't work. Not sure how to do it.
Copy linkTweet thisAlerts:
@UltimaterMay 06.2005 — Here's how to swap two at once:
<i>
</i>&lt;span id="address_text" style="font-weight: none;"&gt;Address&lt;/span&gt;&lt;input type="text" name="address"&gt;
&lt;span id="id_text" style="font-weight: none;"&gt;Id&lt;/span&gt;&lt;input type="text" name="id"&gt;
&lt;input type="button" onclick="emp()" value="EMP"&gt;&lt;input type="button" onclick="usr()" value="USR"&gt;
&lt;script type="text/javascript"&gt;
function emp(){
document.getElementById("address_text").style.fontWeight="bold"
document.getElementById("id_text").style.fontWeight="bold"
}
function usr(){
document.getElementById("address_text").style.fontWeight=""
document.getElementById("id_text").style.fontWeight=""
}
&lt;/script&gt;
×

Success!

Help @fivehandgang 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.16,
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,
)...