SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Enthusiast
    Join Date
    May 2001
    Location
    Atlanta
    Posts
    48
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    if the value is other then open a text box

    Hi,

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

  2. #2
    SitePoint Addict manipura's Avatar
    Join Date
    Apr 2001
    Location
    Calgary,AB
    Posts
    345
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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

  3. #3
    SitePoint Enthusiast
    Join Date
    May 2001
    Location
    Atlanta
    Posts
    48
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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

  4. #4
    imagine no limitations exbabylon's Avatar
    Join Date
    Dec 2000
    Location
    Idaho, USA
    Posts
    452
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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

  5. #5
    SitePoint Enthusiast alnixon's Avatar
    Join Date
    May 2001
    Location
    Preston (UK)
    Posts
    62
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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]

  6. #6
    SitePoint Enthusiast
    Join Date
    May 2001
    Location
    Atlanta
    Posts
    48
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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

  7. #7
    SitePoint Enthusiast
    Join Date
    May 2001
    Location
    Atlanta
    Posts
    48
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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

  8. #8
    SitePoint Enthusiast alnixon's Avatar
    Join Date
    May 2001
    Location
    Preston (UK)
    Posts
    62
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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]

  9. #9
    SitePoint Enthusiast
    Join Date
    May 2001
    Location
    Atlanta
    Posts
    48
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks, I got it now.
    Aneal


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •