how to get combobox value in chronoform..

thirupathy 28 Feb, 2009
hi all,
I have problem while getting value of combobox in chronoform. here my code ....
<select id="status" name="status" >
<option value="new">--New--</option>
<option value="in progress">--In progress--</option>
<option value="delivered">--Delivered--</option>
</select>

javascript:
var w = document.ChronoContact_myform.status.selectedIndex;  // myform is the name of chrono form.
var selected_text = document.ChronoContact_myform.status.options[w].text;   // status is the name of dropdown box.

alert(selected_text);

its working in normal html page. but inside of chronoform only not able to get value....
can any one help.....?

thanks in advance...

regards,

THIRUPATHY.M
GreyHead 28 Feb, 2009
Hi Thirupathy,

I don't see anything wrong except that there's no event trigger to execute the JavaScript.

Bob
thirupathy 28 Feb, 2009
yes everything correct,but am not able to get combobox value...

here my confusion.

regards,

THIRUPATHY.M
thirupathy 28 Feb, 2009
Any idea........................GreyHead....?



thanks in advance.

regards,

THIRUPATHY.M
Max_admin 28 Feb, 2009
Hi Thirupathy,

do you get something when you use .value in the 2nd line ?

Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
GreyHead 01 Mar, 2009
Hi Thirupathy,

Here's how I would do this using MooTools syntax (you may need to turn Validation on to make sure that the library is loaded).
<?php
$script = "
window.addEvent('domready', function() {
  var status = $('status');
  status.addEvent('change', function(event) {
    var w = status.selectedIndex;
    var selected_text = status.options[w].text;

    alert(selected_text);
  });
});
";
$doc =& JFactory::getDocument();
$doc->addScriptDeclaration($script);
?>
<select id="status" name="status" >
  <option value="new">--New--</option>
  <option value="in progress">--In progress--</option>
  <option value="delivered">--Delivered--</option>
</select>
All this goes in the Form HTML box.

window.AddEvent makes sure the code isn't run until the page is loaded (this is part of the problem with the existing code).

status.addEvent attaches the code to the select box to make sure it runs whenever the selection changes.

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