Locked programming question

  • Friday, December 22, 2006 6:36 PM
     
     

    1)Code not working

    strbldTextboxDiv.append("<input type='text' name='middledigits' maxLength=3 style='width:35px;height:15px'>&nbsp;");

    strbldTextboxDiv.append("<input type='text' name='lastdigits' maxLength=4 style='width:45px;height:15px'>&nbsp;");

    strbldTextboxDiv.append("<input type='button' src='http://localhost/gadgets/fiosavailability/searchbtn.gif'style='width:50px;height:20px' align='absmiddle' onclick='searchinfo()'>"); //its giving error "Object expected"

    secondDIV.appendChild(strbldTextboxDiv);

    function searchinfo()

     {

     var sinput=document.getElementsByName("middledigits");

     alert(sin.value);

     }

    2) Code not working

    addradiobutton("Help");

    function addradiobutton(option)

    {

    var rdoptions=document.createElement("input");

    //rdoptions.id="rdo" + option;

    rdoptions.type="radio";

    rdoptions.value=option;

    rdoptions.name="rdooptions";

    //rdoptions.title=option;

    rdoptions.checked=option;

    rdoptions.attachEvent("onclick",testbutton);

    secondDiv.appendChild(rdoptions);

    //var op1=(option!="Both") ? lbl.innerHTML=option + "&nbsp;&nbsp;<span style='color:red'>or</span>&nbsp;&nbsp;": lbl.innerText=option

    } //I am not able to select any of the radio buttons

    Appreciate any  help!!

     Thanks

     

     

     

Answers

  • Saturday, December 23, 2006 5:54 AM
     
     Answered

    Problem 1:

    You're trying to appendChild() a string.  appendChild() expects an HTML element.  If you're going to build your HTML via string concatenation, you need to set innerHTML to the string value.  I'd recommend you go the other way and use document.createElement() to create your <input> elements and append them as appropriate.

    Problem 2:

    I'm not quite clear what's going on here.  If you have your gadget hosted on a public server, a link to the manifest would help out in debugging your issues.