Site name

Welcome, Guest
Username Password: Remember me

Get URL hash tag to select dropdown
(1 viewing) (1) Guest
  • Page:
  • 1

TOPIC: Get URL hash tag to select dropdown

Get URL hash tag to select dropdown 26 Jun 2012 19:05 #5732

  • remp
  • OFFLINE
  • Fresh Boarder
  • Posts: 3
  • Karma: 0
Hello, Thanks for this awesome extension. i would like to add a feature so that whenever i click a link (e. http:///www.mysite.com/incoming#option1 ) i already have the dropdown option1 selected... is it possible to do something like that? and is so how can i do it?

So far i have tried
<script type="text/javascript">
var val = window.location.hash.replace('#', '');
var opts = document.getElementByid('dropdown').getElementsByTagName('option');
for(var i=0; i<opts.length; i++) {
  if(opts[i].value == val) {
    opts[i].selected = true;
    break;
  }
}
--></script>


But since the select element does not have an ID, it does not work. and i find my self unable to add an id to it.

Thanks vey much in advance.
Last Edit: 26 Jun 2012 19:08 by remp.

Re: Get URL hash tag to select dropdown 29 Jun 2012 15:53 #5745

I used to do this on an old site that was not Joomla. I used PHP and it went something like this. . .

<?php
$sel="";
$gen="";
$art="";
$cla="";
$mar="";
$spo="";
$check=$_GET["select"];
if ($check=="") $sel="selected=\"selected\"";
elseif ($check=="gen") $gen="selected=\"selected\"";
elseif ($check=="art") $art="selected=\"selected\"";
elseif ($check=="cla") $cla="selected=\"selected\"";
elseif ($check=="mar") $mar="selected=\"selected\"";
elseif ($check=="spo") $spo="selected=\"selected\"";
else $sel="selected=\"selected\"";
?>

							<select name="select" size="1" id="select">
                  <option value="" rel="none" <?php print $sel ?>>Please Select</option>
                  <option value="general" rel="general" <?php print $gen ?>>General Information</option>
                  <option value="article" rel="article" <?php print $art ?>>Article Submissions</option>
                  <option value="classified" rel="classified" <?php print $cla ?>>Classifieds Submission</option>
                  <option value="marketplace" rel="marketplace" <?php print $mar ?>>Marketplace Request</option>
                  <option value="advertising" rel="advertising" <?php print $spo ?>>Advertising &amp; Sponsorship </option>
                </select>



Don't know if that will be of any help.
The following user(s) said Thank You: remp

Re: Get URL hash tag to select dropdown 29 Jun 2012 16:34 #5747

  • remp
  • OFFLINE
  • Fresh Boarder
  • Posts: 3
  • Karma: 0
Thanks! appreciate your help.

But one of my problems has been that i can't figure out what is generating the
							<select name="select" size="1" id="select">
                  <option value="" rel="none" <?php print $sel ?>>Please Select</option>
                  <option value="general" rel="general" <?php print $gen ?>>General Information</option>
                  <option value="article" rel="article" <?php print $art ?>>Article Submissions</option>
                  <option value="classified" rel="classified" <?php print $cla ?>>Classifieds Submission</option>
                  <option value="marketplace" rel="marketplace" <?php print $mar ?>>Marketplace Request</option>
                  <option value="advertising" rel="advertising" <?php print $spo ?>>Advertising &amp; Sponsorship </option>
                </select>



What page contains what i need to change?

Thanks.

Re: Get URL hash tag to select dropdown 01 Jul 2012 08:13 #5762

  • Fox
  • OFFLINE
  • Administrator
  • Posts: 2408
  • Karma: 72
components/com_foxcontact/helpers/fieldsbuilder.php
If you use this extension, please post a rating and a review at the Joomla! Extensions Directory.
If a problem has been solved please let everybody know, it could be important for other people.
  • Page:
  • 1
Moderators: gyroglm
Time to create page: 0.92 seconds