www.webdeveloper.com
Results 1 to 4 of 4

Thread: Open up a new page based on dropdown

  1. #1
    Join Date
    Aug 2008
    Posts
    31

    Open up a new page based on dropdown

    I currently have a drop down box that has "add" "remove" and "change" as selections. The page I have doesn't have any entries for old information, like old IP address or old Hostnames. Lets say the page with the dropdown
    HTML Code:
    	<select name="action">
    	<option value="none">Please Select</option>
    	<option value="add">Add</option>
    	<option value="remove">Remove</option>
    	<option value="change">Change</option>
    	</select>
    When "change" is selected, I'd like the browser to open up a different page that has the extra fields, "change.php". I don't want to try and "unhide" rows with the extra fields because I'm using PHPRunner to generate the forms. If add or delete is selected, I don't want anything to happen, processing should be done on the existing page/form.

  2. #2
    Join Date
    Feb 2008
    Posts
    1,666
    Code:
    <select name="action" onchange="if (this.options[this.selectedIndex].value == 'change') doSomething();">

  3. #3
    Join Date
    Dec 2008
    Location
    Didim, Turkey
    Posts
    105
    Hi, The value of a select element adopts that of the current selected option, so you can simply test its value without using the options array like this...
    HTML Code:
    <select name="action" onchange="if(this.value === 'change') { location='change.php'; }">
    Mike

  4. #4
    Join Date
    Feb 2008
    Posts
    1,666
    Quote Originally Posted by mikem View Post
    The value of a select element adopts that of the current selected option...
    Not in all browsers.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles