Solved

Need help creating a form dropdown menu with URL Links that works with Joomla

Posted on 2012-03-28
22
392 Views
Last Modified: 2012-06-22
I am trying to get the following sample code to work on an Article in Joomla 1.5.9.   The code below works just fine on a standard HTML Page, but if I use this exact same code in a Joomla Article it does nothing.  I can press the "Take me there!" button and nothing happens.

Does anyone know how to make this simple code work on a Joomla Article?


SAMPLE CODE:

<form name="hop">
<p align="center">
<select name="choose">
<option selected>Choose One</option>
<option value="http://mousetrax.com">Mousetrax</option>
<option value="http://yahoo.com">Yahoo</option>
<option value="http://microsoft.com">Microsoft</option>
<option value="http://personal-computer-tutor.com">Linda's Computer Stop</option>
<option value="http://personal-computer-tutor.com/abc">ABC Newsletter</option>
</select>
<input type="button" onClick="location=document.hop.choose.options[document.hop.choose.selectedIndex].value;" value="Take me there!"></p>
</form>
0
Comment
Question by:anctech
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 12
  • 8
22 Comments
 
LVL 75

Assisted Solution

by:Michel Plungjan
Michel Plungjan earned 500 total points
ID: 37780677
try

<form name="hop" onsubmit="var val = this.choose.value; if (val) location=val; return false">
<p align="center">
<select name="choose">
<option value="" selected>Choose One</option>
<option value="http://mousetrax.com">Mousetrax</option>
<option value="http://yahoo.com">Yahoo</option>
<option value="http://microsoft.com">Microsoft</option>
<option value="http://personal-computer-tutor.com">Linda's Computer Stop</option>
<option value="http://personal-computer-tutor.com/abc">ABC Newsletter</option>
</select>
<input type="submit" value="Take me there!"></p>
</form>

Open in new window

0
 
LVL 7

Expert Comment

by:rashgang
ID: 37780682
have u checked the code inside the article after saving. Because sometimes in joomla it will clear the code.
0
 

Author Comment

by:anctech
ID: 37781714
yes I checked the code in Joomla.  I use the EDIT CODE feature that way I don't have to deal with the GUI editor which does mess up code sometimes.   I am going to try the suggestion by: mplungjan an will post whether or not that worked.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:anctech
ID: 37782573
I just tried the code from mplungjan and it doesn't work either, BUT it does do more than the original code I had.     Please see the attached screenshot file.    Instead of just going to the URL address in the form, it is including the acrticle URL address in front which of course doesn't work.    

Does anyone know how to update the code so when clicking on the "Take Me There" Button, then the ONLY the URL from the drop down form will be used.

Also note that I need several of these drop down menus on the same page, so I am assuming all I would have to do is change the form name to accomplish this.  Is that correct?

Thank you.
screen-shot---form-drop-down-men.jpg
0
 

Author Comment

by:anctech
ID: 37782583
Is there a way to update the code so it forces the URL in the form to open on a NEW Page such as someone incorporating  target="_blank" for each of the URLS in the drop down menu?
0
 
LVL 75

Assisted Solution

by:Michel Plungjan
Michel Plungjan earned 500 total points
ID: 37783641
try

<a href="#" target="_blank" onclick="var loc =document.forms[0].choose.value; if (val)  this.href=val; else return false">Take me there</a>
0
 

Author Comment

by:anctech
ID: 37783850
Where exactly would that go in relation to your original code?     I tried adding that line at the bottom but it doesn't do anything.
0
 
LVL 75

Assisted Solution

by:Michel Plungjan
Michel Plungjan earned 500 total points
ID: 37785811
Sorry, wrote val where  I meant loc
<form>
<p align="center">
<select name="choose">
<option value="" selected>Choose One</option>
<option value="http://mousetrax.com">Mousetrax</option>
<option value="http://yahoo.com">Yahoo</option>
<option value="http://microsoft.com">Microsoft</option>
<option value="http://personal-computer-tutor.com">Linda's Computer Stop</option>
<option value="http://personal-computer-tutor.com/abc">ABC Newsletter</option>
</select>
</form>
<a href="#" target="_blank" 
onclick="var loc =document.forms[0].choose.value;  // assuming first form on page
if (loc)  this.href=loc; else return false">Take me there</a>

Open in new window

0
 

Author Comment

by:anctech
ID: 37787483
sorry, just tested this new code and still doesn't work.
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 37787502
Can you show the view-source of your browser?
0
 

Author Comment

by:anctech
ID: 37787584
Yes I can view the page source in my browser.   What would you like me to look for?
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 37787686
Paste the form and script please
0
 

Author Comment

by:anctech
ID: 37787750
0
 

Author Comment

by:anctech
ID: 37787756
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 37787966
I do not see my link there - only a button
0
 

Author Comment

by:anctech
ID: 37788028
I posted two snips of the page source.  Yours is the first one that is 76kb in size.  Is that the one you looked at.
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 37788050
Ah, sorry missed that on my phone

I see

onclick="function onclick() { function onclick() { .... }}"

that is of course completely wrong
0
 

Author Comment

by:anctech
ID: 37788273
I'm about ready to just say screw it and just put standard HREF text links that I know work for sure.   I was just trying to save to realestate by using the drop down menus since I have quite  a few links thta I want on the page.

Any other suggestions?
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 37788314
I clicked "Request attention" for you
0
 

Accepted Solution

by:
anctech earned 0 total points
ID: 37797366
Many thanks to mplungjan for trying to help figure out the code problem.

I am thinking plan B might be in order which is to just find a whole new different solution.  Does anyone have another solution that works in Joomla 1.5 that I could use to create several drop down lists that would have Links.     I want the website user to be able to use a drop down box to choose links to various user company manuals.   The basic code that works on a standard HTML page doesn't work in a Joomla article.  

Thank You.
0
 

Author Closing Comment

by:anctech
ID: 38073266
Gave up trying to find a solution.     Expert Comments from mplungjan were very much appreciated, however even after following the expert suggestions exactly the code still did not work correctly in Joomla 1.5.  

I resorted to just using standard Href tags which worked fine.
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Boolean 13 44
PDF Turn Look 7 27
Can't Find the Homepage on my site 4 42
Changing the format from a text box to a drop-down menu 9 33
Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question