Forums

An javasctript problem

xan917 09 Feb, 2012
Hey everyone, i have got a strange problem. How i can use javascript with a combobox onchange event?
Here is a code part with combo box:
<select class="cf_inputbox validate-selection" id="select_5" size="1" title="you must select something from here"  name="select_5" onchange="getcomobo1(this);">

and getcombo1(lb) is described in javascript section as following:
function getcombo1(lb){
  var frm=document.ChronoContacts_myform;
  frm.alert("This is an alert from");
}

But when i select an combobox item, nothing happens. Why? My form trully has got a name "myform", everything should work fine, as in tutorials, but it is not.
xan917 09 Feb, 2012
I did some progress, but now is next question. How to change the text of cf_text field? I tierd innerHTML, but it was not working.
GreyHead 10 Feb, 2012
Hi xan917,

I would leave this unchanged so that you don't need to edit the Form HTML
<select class="cf_inputbox validate-selection" id="select_5" size="1" title="you must select something from here" >
and use this in the Form JS box
window.addEvent('domready', function() {
  var select_5 = $('select_5');
  select_5.addEvent('change', function() {
      alert('This is an alert from');
    }
  });
});

Inner HTML will work if you have the tag correctly identified.

What exacty are you trying to do here?

Bob
This topic is locked and no more replies can be posted.