close ad
Install the LAtest Updates to Work with CC 2017 and CC 2018
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

dynamic dropdown and redirecting to new page

Thread began 3/05/2010 12:47 pm by nvdhassani382788 | Last modified 3/08/2010 2:44 pm by Eric Mittman | 3059 views | 5 replies |

nvdhassani382788

dynamic dropdown and redirecting to new page

Hello,

I am trying to use my drop down menu so I can link to a new webpage.

I have created two tables in mysql, And I want the customer to be able to click a Button once the child dropdown menu is selected and go to the next page.

CREATE TABLE `categories` (
`cat_id` mediumint(8) unsigned NOT NULL auto_increment,
`cat_name` varchar(28) default NULL,
PRIMARY KEY (`cat_id`)
) ENGINE=MyISAM;

CREATE TABLE `companies` (
`comp_id` int(10) unsigned NOT NULL auto_increment,
`comp_name` varchar(48) NOT NULL,
`comp_cat_id` mediumint(8) unsigned NOT NULL,
PRIMARY KEY (`comp_id`)
) ENGINE=MyISAM;

INSERT INTO `categories` (`cat_id`, `cat_name`)
VALUES (1, 'Air Conditioning & Heating');
INSERT INTO `categories` (`cat_id`, `cat_name`)
VALUES (2, 'Alarm/Security');
INSERT INTO `categories` (`cat_id`, `cat_name`)
VALUES (3, 'Appliances');
INSERT INTO `categories` (`cat_id`, `cat_name`)
VALUES (4, 'Carpet & Upholstery Cleaning');
INSERT INTO `categories` (`cat_id`, `cat_name`)
VALUES (5, 'Day Care');
INSERT INTO `categories` (`cat_id`, `cat_name`)
VALUES (6, 'Electrical');
INSERT INTO `categories` (`cat_id`, `cat_name`)
VALUES (7, 'Energy Savers');
INSERT INTO `categories` (`cat_id`, `cat_name`)
VALUES (8, 'Fence & Deck Services');
INSERT INTO `categories` (`cat_id`, `cat_name`)
VALUES (9, 'Flooring');
INSERT INTO `categories` (`cat_id`, `cat_name`)
VALUES (10, 'Foundation Repair');
INSERT INTO `categories` (`cat_id`, `cat_name`)
VALUES (11, 'Garden & Landscaping');
INSERT INTO `categories` (`cat_id`, `cat_name`)
VALUES (12, 'Home Entertainment');
INSERT INTO `categories` (`cat_id`, `cat_name`)
VALUES (13, 'Home Furniture');


INSERT INTO `companies` (`comp_id`, `comp_name`, `comp_cat_id`)
VALUES (1, '1st Class Air Service', 1);
INSERT INTO `companies` (`comp_id`, `comp_name`, `comp_cat_id`)
VALUES (2, 'Chapman Air', 1);
INSERT INTO `companies` (`comp_id`, `comp_name`, `comp_cat_id`)
VALUES (3, 'Dallas Plumbing Company', 1);

And my dynamic dropdown script is

<div id="steps">

<div class="stepone">
<h4> Step One: </h4>
<p>Choose a Category</p>
<form id="form1" name="form1" method="post" action="">
<select name="Parent" id="Parent" onchange="WA_FilterAndPopulateSubList(Child_WAJA,MM_findObj('Parent'),MM_findObj('Child'),0,0,false,': ')">
<?php
do {
?>
<option value="<?php echo $row_Parent['cat_id']?>"><?php echo $row_Parent['cat_name']?></option>
<?php
} while ($row_Parent = mysql_fetch_assoc($Parent));
$rows = mysql_num_rows($Parent);
if($rows > 0) {
mysql_data_seek($Parent, 0);
$row_Parent = mysql_fetch_assoc($Parent);
}
?>
</select>
</form>
<p>&nbsp;</p>
</div>


<div class="stepone">
<h3> Step Two:</h3>
<p> Choose a Company (Optional) </p>
<form id="form2" name="form2" method="post" action="">
<select name="Child" id="Child">
</select>
</form>
<p>&nbsp;</p>
</div>


<div class="stepone">

<h2> Step Three:</h2>
<img class="go" src="images/global images/gobutton.png" alt="Go" />
</div>
</div>

I was wondering if I need to create another column in my table that holds the URL for all those companies and how do I make the GO button recall that column in the table and open the new page?

Sign in to reply to this post

asnw0764437428

redirect to new page

In your form tag you haven't entered the results page name eg

<form id="form1" name="form1" method="post" action="name_of_your_results_page.php">

If you want the the drop list items you selected to be remembered I would also put this in the body tag:

onLoad="WA_FilterAndPopulateSubList(Child_WAJA,M M_findObj('Parent'),MM_findObj('Child'),0,0,false, ': ')"

Sign in to reply to this post

nvdhassani382788

update

you can look at the page here to get a better idea.


mysavings.php

use username: tester
password: tester

Sign in to reply to this post

nvdhassani382788

Sql

So I don't have to put the URLs in mySQL database?

What I basically want is you select a category and then select a company and click Go to go to that companies page.

I also want to be able to use the category only to go to a page with an overview of all the companies.
In my drop down menu I'm gonna add view all.

For instance, you select Pool services and then in the child menu its going to give you the option of viewing them all or just select one company and click the submit button.

Thanks for all the help again

Sign in to reply to this post

nvdhassani382788

how do i open new page from dynamic dropdown

Can anyone please help me with this:

I have set up this script

<p>Choose a Category</p>
<form id="form1" name="form1" method="post" action="<?php echo $row_Child['comp_url']; ?>">
<select size=1 name="Parent" id="Parent" onchange="WA_FilterAndPopulateSubList(Child_WAJA,MM_findObj('Parent'),MM_findObj('Child'),0,0,false,': ')">
<option value="">Please Select Below</option>
<?php
do {
?>
<option value="<?php echo $row_Parent['cat_id']?>"><?php echo $row_Parent['cat_name']?></option>
<?php
} while ($row_Parent = mysql_fetch_assoc($Parent));
$rows = mysql_num_rows($Parent);
if($rows > 0) {
mysql_data_seek($Parent, 0);
$row_Parent = mysql_fetch_assoc($Parent);
}
?>
</select>
</form>
<p>&nbsp;</p>
</div>


<div class="stepone">
<h3> Step Two:</h3>
<p> Choose a Company <strong><em>(Optional) </em></strong></p>
<form id="form2" name="form2" method="post" action="">
<select size=1 name="Child" id="Child">
<option>Please Select a Company</option>
</select>
<input type="image" src="images/global images/gobutton.png" name="go" id="go" value="Submit" />
</form>

<form id="form1" name="form1" method="post" action="<?php echo $row_Child['comp_url']; ?>">

^^Doesn't quite work. It gives me this error

Warning: mysql_free_result(): supplied argument is not a valid MySQL result resource in /home/content/h/o/m/homepagesdfw/html/mysavings.php on line 395

Line 395 is mysql_free_result($Child);


Is there any webassist support on this?

Sign in to reply to this post

Eric Mittman

I was not able to view your sample page with the username and password provided. It seems that you have a dynamic dropdowns implementation in place and would like for the child menu to hold URL values from your table correct? If so you are mostly there, to get the page to go to the URL of the selected value in the child list you will need to use some javascript. In your js code you will have the onclick of the go button do a window.open call. In this call you will use the value of the selected index's option of this child list. So the go button's onclick event might be set like this:

onclick="window.open(getElementById('<the id of your child select list>').options[getElementById('<the id of your child select list>').selectedIndex].value)"

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...