No idea if this could be done by just javascript but don't know where else to post it...
I have a contact forum where i want the visitor to select if they're a member of not, if they select no, nothing happens but if they select yes a new text field pops up where they have to fill out their username.
thing is, i've researched a lot and just cannot find out how to do it...
Anybody know how to?

\\ Vic

Recommended Answers

All 7 Replies

<script type="text/javascript">
(document.getElementById) ? dom = true : dom = false;
function hideIt() {
if (dom) {document.getElementById("layerm1").style.visibility='hidden';}
if (document.layers) {document.layers["layerm1"].visibility='hide';} }
function showIt() {
if (dom) {document.getElementById("layerm1").style.visibility='visible';}
if (document.layers) {document.layers["layerm1"].visibility='show';} }
--></script>

<input type='radio' id='radiono'name='radioone' value='no' ><label for='radiono'>NO</label> 
<input type='radio' id='radioyes' value='yes' onClick="showIt();"><label for='radioyes'>YES</label>

<div id="layerm1" style="position:fixed; width:50%; visibility:hidden; padding:10px; margin:10px; background:#ececec; border: 1px solid;">
<center><font size="+1"><input><br><input>
<button onClick="hideIt();">Close</button></div>

I'm fairly sure you can do it with only a few lines of php.

something like

if($member='yes'){
echo"<label>Please Enter your Username</label><br><input type='username' name='username'>";
}else{
echo"the rest of the form";
}

member of not, if they select no, nothing happens

Why not just have a username box which may be left blank?
Personally I find popups annoying, and clicking in one box solely for the purpose of causing another one to pop up would be doubly so.
Besides, users who have popups blocked (as I do) will never see it.

Why not just have a username box which may be left blank?
Personally I find popups annoying, and clicking in one box solely for the purpose of causing another one to pop up would be doubly so.
Besides, users who have popups blocked (as I do) will never see it.

the code sample is not a popup, so you will see it, its the same as the descriptive text used in this page
Flush

the code sample is not a popup

Sorry, my general comments to the original poster had nothing to do with your code sample.

deefensive little bugger aint I,
the op asked for a text field to popup not a page
dos vdanye

I was remiss, what a mess, functional but UGLY

  • used <font> tag(for no real reason I can see)
  • didnt close <font>
  • didnt explain that the two versions of each function hideit showit were to ensure the script worked in most browsers >ie5 and >ff1 who have different DOM
  • didnt put any explanation at the hidden layer

headslap moment

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.