Welcome guest, is this your first visit? Create Account now to join.
Results 1 to 5 of 5

This is a discussion on Dropdown menu with raiseevent not working within the Chrome Troubleshooting section, part of the Google Chrome category: I am having problems getting a dropdown menu which uses javascript onchange to fire raiseevent, though it works fine on ...


  1. #1
    Skibrowse is offline Junior Member
    Join Date
    Apr 2009
    Posts
    5

    Default Dropdown menu with raiseevent not working

    I am having problems getting a dropdown menu which uses javascript onchange to fire raiseevent, though it works fine on firefox and IE. I am having trouble isolating the code to describe fully on this forum, but I have proven that it is something to do with raiseevent (because you can substitute a call to alert, and there is no problem). The code below illustrates the problem, but I have not included the raiseevent code or the switch statement (for which one of the case statements is SelectProject) as its rather involved. If contributors need to know more, I will try and include snippets of code.
    .
    .
    .
    .
    .
    <form action="projects.php?" method="post" name="mainForm">
    <select name="dllSelectedProject" id="dllSelectedProject" onchange="raiseEvent('SelectProject','0',this);">
    <option value="0"> Select a Project </option>
    <option value="185">jljkljkl</option>
    <option value="184">tyutyu</option>
    <option value="183">werwe</option>
    <option value="177">ffg2</option>
    <option value="178">ouy</option>
    </select>
    </body>
    </html>
    .
    .
    Any help will be appreciated.

  2. #2
    Skibrowse is offline Junior Member
    Join Date
    Apr 2009
    Posts
    5

    Default

    Sorry. I omitted the </form>. The problem persists i.e. it was just an error in my description of the problem

  3. #3
    Kyrax is offline Senior Member
    Join Date
    Apr 2009
    Location
    Qc, Canada
    Posts
    495

    Default

    Ok i just tried this :

    Code:
    <html>
    <head>
    
    
    <script>
    
    function raiseEvent(arg1,arg2,arg3){
    
    alert(arg1 + " - " + arg2 + " - " + arg3);
    
    }
    
    </script>
    
    
    <body>
    
    <form action="projects.php?" method="post" name="mainForm"> 
    <select name="dllSelectedProject" id="dllSelectedProject" onchange="raiseEvent('SelectProject','0',this);"> 
    <option value="0"> Select a Project </option> 
    <option value="185">jljkljkl</option>
    <option value="184">tyutyu</option>
    <option value="183">werwe</option>
    <option value="177">ffg2</option>
    <option value="178">ouy</option>
    
    </body>
    </html>
    And i did get a popup saying "SelectProject - 0 - [ElementType]"..
    So it seems to work on my side.

    I also tried with other things inside the raiseEvent and everything worked.

    Of course projects.php doesn't exist on my side.

  4. #4
    Skibrowse is offline Junior Member
    Join Date
    Apr 2009
    Posts
    5

    Default I've fixed it

    A belated thanks to Kyrax for the contribution. I have now solved it. It was nothing to do with the onchange call. It's hard to explain but there was some javascript dynamically constructed and written into the page to handle the selects (so the raiseevent code would vary depending on which item was selected). It involved a bit of code to find and pull out the appropriate raiseevent call. The latter was the bit that is browser dependent, but I've modifed it from the below (what I changed it to follows that). Look for lines starting

    change = change.substring(
    and
    if (navigator.appVersion

    Heres the original excerpt that I had to change:

    function WriteHtml()
    {
    return sprintf('<script language="javascript" type="text/javascript" defer="defer">
    if (navigator.appVersion.indexOf("Safari")>-1)
    {

    var sels = document.getElementsByTagName("SELECT");
    var inp = document.getElementsByTagName("INPUT");


    function Select()
    {
    var ID;
    var Event;
    };

    var _selects = [];
    var _inputs = [];

    for(var i = 0; i < sels.length; i++)
    {
    var change = sels[i].onchange.toString().replace(/\);/g, ", this);");
    change = change.substring(change.indexOf("{") + 1, change.indexOf("}")-1);
    var sel = new Select();
    sel.ID = sels[i].name;
    sel.Event = change;
    _selects.push(sel);

    sels[i].onchange = function()
    {
    for(var j = 0; j < _selects.length; j++)
    if(_selects[j].ID == this.name)
    {
    eval(_selects[j].Event);
    break;
    .
    .
    .
    .
    .
    .

    And now the same with my changes........

    function WriteHtml()
    {
    return sprintf('
    <script language="javascript" type="text/javascript" defer="defer">
    if ((navigator.appVersion.indexOf("Safari")>-1) || (navigator.userAgent.toLowerCase().indexOf("chrome") > -1) || (navigator.appVersion.toLowerCase().indexOf("chrome")>-1))
    {

    var sels = document.getElementsByTagName("SELECT");
    var inp = document.getElementsByTagName("INPUT");


    function Select()
    {
    var ID;
    var Event;
    };

    var _selects = [];
    var _inputs = [];

    for(var i = 0; i < sels.length; i++)
    {
    var change = sels[i].onchange.toString().replace(/\);/g, ", this);");
    alert (change);
    change = change.replace(/^\s*|\s*$/g,"").substring(change.indexOf("{raise") + 1, change.indexOf(";}")+1);
    alert (change);
    var sel = new Select();
    sel.ID = sels[i].name;
    sel.Event = change;
    _selects.push(sel);

    sels[i].onchange = function()
    {
    for(var j = 0; j < _selects.length; j++)
    if(_selects[j].ID == this.name)
    {
    eval(_selects[j].Event);
    break;
    }
    }
    }

    for(var i = 0; i < inps.length; i++)
    {
    if(inps.type.toLowerCase() == "button")
    {
    var change = inps[i].onclick.toString().replace(/\);/g, ", this);");
    change = change.substring(change.indexOf("{") + 1, change.indexOf("}") - 1);
    var inp = new Select();
    inp.ID = inps[i].name;
    inp.Event = change;
    _inputs.push(inp);

    inputs[i].onclick = function()
    {
    for(var j = 0; j < _inputs.length; j++)
    if(_inputs[j].ID == this.name)
    {
    eval(_inputs[j].Event);
    break;
    }

  5. #5
    Kyrax is offline Senior Member
    Join Date
    Apr 2009
    Location
    Qc, Canada
    Posts
    495

    Default

    Glad you got it to work

Similar Threads

  1. Selector/dropdown with onchange/raiseevent not working
    By Skibrowse in forum Bugs and Vulnerabilities
    Replies: 0
    Last Post: 04-18-2009, 04:32 PM
  2. www.McAfee.com dropdown menu
    By Nemo in forum Bugs and Vulnerabilities
    Replies: 2
    Last Post: 01-08-2009, 03:28 PM
  3. file, edit etc menu bar??
    By Katheechrome in forum Chrome Talk
    Replies: 0
    Last Post: 12-14-2008, 01:37 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •