Hi,
Ho can I popup the text box to enter the selection if the value of Select Box is 'Other'.
| SitePoint Sponsor |
Hi,
Ho can I popup the text box to enter the selection if the value of Select Box is 'Other'.
Aneal


I would have to say put an if function stating if the select box is other, pop up a new window. You can create a whole new window or use javascript to customize the size and all that. Thats if you know Javascript.
But thats my opinion... I'm just a newbie.... heh
Well , I need to use the onChange or onSelect event of java script.
I'm using the option box to select the age and when the option = other
then open up the text box to enter their age.
Aneal



suggestion.....
have two boxes, and use PHP to compare two different fields, if the other box is checked then look for the var fom the other field, if not then look for the var from the basic drop down menu.
Blamestorming: Sitting around in a group discussing why a deadline was missed or a project failed and who was responsible.
Exbabylon- Professional Internet Services
once this has taken place you waould have to do an if statement in your php to say if $age="other"{$age=$hiddenotherage;}
hope this is what you meant.
<HTML>
<HEAD>
<TITLE>Tester</TITLE>
<SCRIPT LANGUAGE="JavaScript">
<!--
function otherprompt(selectname){
if (selectname.selectedIndex==2){
var myage = prompt("What is the your age?","your age");
form1.hiddenotherage.value = myage
}
}
//-->
</SCRIPT>
</HEAD>
<BODY>
<form action="tester2.php" method=post name="form1">
<INPUT TYPE=hidden NAME="hiddenotherage" >
Age: <select name="age" onblur="otherprompt(this)">
<option value="10to15" name="10to15">10 to 15</option>
<option value="15to20" name="15to20">15 to 20</option>
<option value="other" name="other">Other...</option>
</select><br >
<INPUT TYPE=submit NAME="Submit" VALUE="Submit">
<INPUT TYPE=reset NAME="Reset" VALUE="Reset">
<INPUT TYPE=submit NAME="Cancel" VALUE="Cancel">
</form>
</BODY>
</HTML>
Da Big Cheese
--------------
I'm not entirely sure on this, but ....
[insert my post here]
I wasn't able to make this script work. It is refreshing the page, and the values being entered also losted or gone. But I just want to keep th evalue and if the selection = 'other' then open a text box to enter their own value and now if he/she submits it, it should pass to the database, and to the next page.
Thenk you
Aneal
I got that script working somewhat.
What is it doing it promt for the department, but dosen't pass the value to the next page. The codes I'm using:
function newTbox(department)
{
deptvalue = department.selectedIndex
if (department.options[deptvalue].value == "OTHER")
{
var mydept = prompt("What is the your department?","your department")
department.hiddenotherdept.value = mydept
}
}
Aneal
the value will have been passed - it is just passed to a hidden field. try changing the type of hiddenotherage to 'text' and then you will see it.
Da Big Cheese
--------------
I'm not entirely sure on this, but ....
[insert my post here]
Thanks, I got it now.
Aneal
Bookmarks