Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Aug 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    OnChange issue found when used in conjunction with innerHTML

    Hey Guys,

    I was wondering if anyone could solve the issue I am currently having.

    I am attempting to create a text box using innerHTML between div tags when the value of a scroll down box is 0.

    Here stands my code:

    Code:
    <select name="destination" onchange="dest(document.signoutForm.destination.options[document.signoutForm.destination.selectedIndex].value);">
    Code:
    function dest(destination){
    	if(destination == 0){
    document.getElementById("demo").innerHTML="<input type=\"text\" name=\"dest\" />";
    	}else {
    		document.getElementById("demo").innerHTML=" ";
    	}
    }
    I have attempted changing the function which calls the method (i.e. to onclick, onkeyup, etc.) but alas, no success.

    The textbox is created when the destination is == 0 however once the function has been called and the text box been created, the function is not called again (I have tested this with various alert message placed throughout the code).

    Anyone have any idea what I can do to solve the issue.

    Thanks

    SACoder

  • #2
    New to the CF scene
    Join Date
    Aug 2012
    Location
    Thane
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    hi everyone ,
    i face following problem. in IE it works but problem in firefox .

    in xsl file :<IMG name="img_start_date" id="Detail1.{normalize-space($dbID)}.start_date__img" src="/ibase/scheduler/images/table.gif" style="width=15;height=15;" onClick="showCalendar(this);" value="{$start_date}" ISCHANGED="false" />
    ---------------------------------------------------------------------------------------------------------------------------
    in js file :
    var curFieldName = obj.id;

    fldName = curFieldName.substring(0, curFieldName.indexOf("__img") );

    obj1 = document.getElementById(fldName);
    alert("field name : "+obj1);
    oldDate = obj1.value;
    show_calendar();

    value of the oldDate is null in firefox and in IE display date

    ple'z reply ASAP
    Thanks in advanced

    Regards
    D.V. pawar

  • #3
    Regular Coder low tech's Avatar
    Join Date
    Dec 2009
    Posts
    852
    Thanks
    173
    Thanked 94 Times in 94 Posts
    #SACoder

    Your code worked for me.

    Code:
    <div id="demo"></div>
    <form name="signoutForm">
    <select name="destination" onchange="dest(document.signoutForm.destination.options[document.signoutForm.destination.selectedIndex].value);">
    <option value="">Choose</option>
    <option value="0">0</option>
    <option value="1">1</option>
    <option value="2">2</option>
    </select>
    </form>
    <script type="text/javascript">
    function dest(destination){
    	if(destination == 0){document.getElementById("demo").innerHTML="<input type=\"text\" name=\"dest\" />";
    	}else {
    		document.getElementById("demo").innerHTML="";
    	}
    }
    </script>
    "The greatest revenge is to accomplish what others say you cannot do."
    ~ Unknown

    I used to be indecisive, but now I'm not so sure.


  •  

    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
    •