www.webdeveloper.com
Recent Articles
  • Finding Slow Running Queries in ASE 15
  • A More Advanced Pie Chart for Analysis Services Data
  • Adobe AIR Programming Unleashed: Working with Windows
  • Performance Testing SQL Server 2008's Change Data Capture Functionality
  • The ABC's of PHP: Introduction to PHP
  • How to Migrate from BasicFiles to SecureFiles Storage
  • Why the Twitter Haters Are Wrong
  • User Personalization with PHP: Beginning the Application
  • Whats in an Oracle Schema?
  • Lighting Enhancement in Photoshop
  •  

    Go Back   WebDeveloper.com > Client-Side Development > JavaScript

    JavaScript JavaScript (not Java) Discussion and technical support, including AJAX and frameworks (JQuery, MooTools, Prototype...)

    Reply
     
    Thread Tools Search this Thread Rate Thread Display Modes
      #1  
    Old 05-10-2006, 10:12 AM
    Jaydeep Jaydeep is offline
    Registered User
     
    Join Date: Apr 2006
    Posts: 41
    Thumbs up select value in a combobox when i check checkbox

    hello friends i am having problem here.

    when i click a check box i need to display data in a text box and one item should be selected in the combobox. i am using this script in php..
    and ckman1.value is a string not a integer so how can i select a value in a combobox called man1..
    here javascript for txtballname1 is working but for man1 itis not working...

    <script language="javascript">

    function setball()
    {
    var Lform2 = this.document.advbbsearch2;
    var Lform1= this.document.advbbsearch1;
    Lform2.txtballname1.value = Lform1.ckb1.value;
    Lform2.man1.selectedindex = Lform1.ckman1.value;
    return true;
    }
    </script>

    *********************************************
    echo "<input type=\"hidden\" value=\"".$ballname1."\" name=\"ckb1\"";
    echo "<input type=\"hidden\" value=\"".$manu1."\" name=\"ckman1\"";
    *********************************************
    echo "<input type=\"checkbox\" name=\"chkbox1\" value=\"ball1\" onclick=\" return setball()\" align=\"right\">";


    so please help me .......

    Jaydeep Vadher....
    Reply With Quote
      #2  
    Old 05-10-2006, 10:32 AM
    Kor's Avatar
    Kor Kor is offline
    Red Devil Moderator
     
    Join Date: Dec 2003
    Location: Bucharest, ROMANIA
    Posts: 11,522
    var opt = Lform2.man1.options;
    for(var i=0;i<opt;i++){
    opt[i].selected=(Lform1.ckman1.value==opt[i].value)?true:false;
    }
    --------reedit--------

    Last edited by Kor; 05-10-2006 at 10:34 AM.
    Reply With Quote
      #3  
    Old 05-10-2006, 10:32 AM
    phpnovice phpnovice is offline
    Banned
     
    Join Date: Dec 2004
    Posts: 8,652
    Presuming that you've got FORM tags somewhere, change this part of your PHP code:

    onclick=\" return setball()\"

    to this:

    onclick=\"return setball(this)\"

    Then, change your function to this:
    Code:
    function setball(chkbox)
    {
        var Lform1= document.forms["advbbsearch1"];
        var Lform2 = document.forms["advbbsearch2"];
        Lform2.txtballname1.value = Lform1.ckb1.value;
        if(chkbox.checked) {
            var opt = Lform2.man1.options;
            var x, len = opt.length;
            for(x=0; x<len; ++x)
            {
                if(opt[x].value == Lform1.ckman1.value)
                {
                    opt[x].selected = true;
                    break;
                }
            }
        }
        return true;
    }

    Last edited by phpnovice; 05-10-2006 at 10:34 AM.
    Reply With Quote
      #4  
    Old 05-10-2006, 11:19 AM
    Jaydeep Jaydeep is offline
    Registered User
     
    Join Date: Apr 2006
    Posts: 41
    thanks for reply I worked as you told but still it is not working...
    so can you send me another solution please...
    Reply With Quote
      #5  
    Old 05-10-2006, 11:22 AM
    phpnovice phpnovice is offline
    Banned
     
    Join Date: Dec 2004
    Posts: 8,652
    I can't provide anything else without any information as to just what is the problem. So, you provide a live link to your page on the Internet so I can see just what "is not working."
    Reply With Quote
    Reply

    Bookmarks


    Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
     
    Thread Tools Search this Thread
    Search this Thread:

    Advanced Search
    Display Modes Rate This Thread
    Rate This Thread:

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is Off
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 02:10 PM.



    Acceptable Use Policy


    The Network for Technology Professionals

    Search:

    About Internet.com

    Legal Notices, Licensing, Permissions, Privacy Policy.
    Advertise | Newsletters | E-mail Offers

    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.