Jump to content

  • Log in with Facebook Log in with Twitter Log In with Google      Sign In   
  • Create Account

Subscribe to HRA Now!


Are you a Google Analytics enthusiast?

Share and download Custom Google Analytics Reports, dashboards and advanced segments--for FREE! 




From the folks who brought you High Rankings!

- - - - -

Js For Dynamically Generated Form Select

  • Please log in to reply
1 reply to this topic

#1 seo_bright


    HR 5

  • Active Members
  • PipPipPipPipPip
  • 292 posts

Posted 29 July 2009 - 05:33 AM

I got a piece of code But this works only when a refresh occurs and disappears.
the variable divid is the variable for the dynamic link which should be displayed only when user selects a value from drop down.

<script type="text/javascript">
function dss_addLoadEvent(fn) {
  var tempFunc=window.onload;
  window.onload=function() {

dss_addLoadEvent(function() {
  var f = document.getElementById('request');
var b1 = document.getElementById("cat1");
var b2 = document.getElementById("cat2");
var b3 = document.getElementById("cat3");
  // to prevent the form from submitting in this demo
  //f.onsubmit = function(){ return false; }
  // hide the textarea and its parent label
  document.getElementById('broch').style.display = 'none';
// get a reference to the select button group
  var sel = document.getElementById('category');
  for(var i=1;i<sel.length;i++) {
    // we add the event handler to each button in the group
      if(sel.options[i].value=='None') return;
      var el = document.getElementById('divid');
      if((sel.options[i].value=='cat1')|| (sel.options[i].value=='cat2') || (sel.options[i].value=='cat3'))
      el.style.display = '';



How do I make this visible and remain in page?

#2 seo_bright


    HR 5

  • Active Members
  • PipPipPipPipPip
  • 292 posts

Posted 31 July 2009 - 03:40 AM

The idea behind the code was to display a text link based on selection from drop down. Sorry if that was not clear to you. Actually I had found an easy method of using case in javascript and writing a function On change in the select tag. And it worked.

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

We are now a read-only forum.
No new posts or registrations allowed.