/    Sign up×
Community /Pin to ProfileBookmark

Show other form objects if <option> is selected

I have a <select> that is pre-populated with names from a MySQL database via PHP. Now, I want the user to select a name and have no effect on the page, nor form data, BUT within the <select> other than the pre-populated data i have a “New Name” <option>, i would like if this <option> is selected that additional <form> objects would be displayed so that the user can easily add their information to the DB…

how is it possible to write a script to add additional form objects only when the “New Name” option is selected by the user?

I can code all the php/mysql… but I’m not the greatest with JavaScript, so I ask if anyone is willing to help me write this java script. Thank-you!

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@sciguyryanNov 09.2004 — I've set up a VERY basid demo here:

http://ryanj.xignahosting.com/Tests/Web_Dev/phence/

Hope that helps,

RyanJ
Copy linkTweet thisAlerts:
@phenceauthorNov 10.2004 — Thanks, hmm... looks like that might work...

What effect does the CSS have on the script, im not too fimiliar with CSS... when i remove it, the script doesn't work properly.

I am going to be displaying multiple form objects when the selection is made to "New Name". When the user selects an actual name (e.g. John Doe), nothing has to change. The actual names are going to be what is pre-populated by the Mysql database.. again, they will not need to change anything... Only when "New Name" is selected, then additional form objects will appear.

If possible i'd like to be able to run the script without using CSS..

Thank-you for your help.
Copy linkTweet thisAlerts:
@phenceauthorDec 13.2004 — can anyone help me out on this, still can't figure it out...
Copy linkTweet thisAlerts:
@phenceauthorDec 13.2004 — Below is the code i have now...

Can anyone show me from here how i can accomplish what i would like to do?
[code=php]<select name="author" size=1>
<option value="none">New Author</option>
<?php
$query = "SELECT * FROM author";
$result = mysql_query($query);
while ($row=mysql_fetch_assoc($result)){
echo "<option value="".$row['id']."">";
echo $row['lastname'] .", ". $row['firstname'];
echo "</option>n";

}
?>
</select>[/code]
×

Success!

Help @phence 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 6.17,
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: @nearjob,
tipped: article
amount: 1000 SATS,

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

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...