/    Sign up×
Community /Pin to ProfileBookmark

Change page content depending on chosen option in forms

Hi,
I have a form with several types of input (2 dropdown-menus, a radio-button selection and text inputs).

What I want is that the content of the first dropdown-menu changes depending on which radio-button I have chosen. Also, the options of the second dropdown-menu depend on the first one.
In the end I need all the values write the data correctly.

Is there any easy way to solve this without using a new webpage so that the user just sees the content changing?
For example, selecting the first option in the dropdown-menu shows the numbers 1-5 in the second one, but the second option only shows the numbers 1-3 (depending on how many values it gets from the database).

I would like to avoid having to load up a new webpage in case the user already wrote something in the text boxes.

Thank you in advance!

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@NogDogAug 25.2006 — If you don't want to reload the page, then you'll have to use a client-side solution. You could use JavaScript, either with arrays of values populated by your PHP or else by using an AJAX implementation. (And then of course to be thorough you'll need a means to handle user requests when they don't have JavaScript enabled.)
Copy linkTweet thisAlerts:
@MarkstarauthorAug 26.2006 — Thank you for your reply!

How would I do that with JavaScript?

Actually I wouldn't even know how to do it with reloading the page. If I just select the other radio button or make a selection from the dropdown menu, how do I get it to change without the need to press a 'submit' button?

I see it working everywhere on the net (especially webshops), I just have no idea how it works. ?

Plus I would like to keep any text that was already entered, of course.
×

Success!

Help @Markstar 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.24,
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,
)...