Jump to content

Recommended Posts

hello again all,

 

I'm creating a simple dropdown form for a site i'm working on and ran into a wall:

 

I'd like to have a simple form that shows a few products, lets the user select a product and hit a submit button that will lead them to a static page that talks about that particular product.

 

I know that i could use one products page and populate different content based on the selected option, but i'd like to try out using multiple static pages... what do you all think?

 

here's what i have so far....

 

<html>
<head></head>
<body>
     <form name="myForm" action="" method="post">
          <select name="product">
               <option value="Product 1">Product 1</option>
               <option value="Product 1">Product 1</option>
               <option value="Product 1">Product 1</option>
          </select>
          <input type="submit" name="submit" value="Go!" />
     </form>
</body>
</html>

 

Pretty simple stuff.... as you can see I don't have anything in the action as of yet... i'm a little confused how to make this work but the idea would be that in my site's folder i would have static pages made for each of the products in the list.

 

So in my newbish mind i would have to do something to change the action to match whichever selection has been made... Is that logic correct? redundant? just plain fail? haha

 

thanks in advance!

J

well, I guess you could use javascript, and use the onChange event to dynamically change the action of the form, and you could also have the submit button go to a certain page based on the value of the form. But that is javascript and not really PHP. If you wanted to do it with pure PHP you would probably have to have a page that gets the value of the form, and then redirects the user to the specific page, but that option is kind of... well... slow and pointless since there are much faster ways of doing what you want.

 

I would go with javascript, something like

 

<html>
<head></head>
<body>
     <form name="myForm" action="" method="post">
          <select name="product" id="product">
               <option value="/product1.html">Product 1</option>
               <option value="product2.html">Product 2</option>
               <option value="product3.html">Product 3</option>
          </select>
          <input type="button" name="submit" value="Go!" onClick='window.location.href=document.getElementById("product").value/>
     </form>
</body>
</html>

 

I didn't test that though, so the syntax may be slightly off. But thats the basic Idea of how I would go about it

 

Awesome bro! thanks...

 

i'll play around with it...

 

to be honest, the only reason i was hoping to serve the static pages was to see if search engines would like it more... have you had any experience with static vs dynamic pages in terms of SEO? Don't give away any secrets but if i can avoid javascript and use a single php page with no detrimental effects, i'd be loving life right now :-)

 

thanks again!

J

I believe that static pages are more search engine friendly (Don't quote me on that, Im not SEO expert) but regardless of how you serve the static pages (whether its via javascript, like my example, or PHP) they are still static pages so web crawlers (in theory) will still index those pages, thus using javascript vs. php won't really cause any detrimental effects as far as your ranking in a search engine goes.

 

Besides, as long as you site has a site map and all those other search engine friendly tricks then you should be fine. But again, I'm not SEO expert, so you may want to consult someone in the SEO forums on this topic (I think there is a SEO section on these forums EDIT: yes there is =) )

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.