Search
Search titles only
By:
Search titles only
By:
Log in
Register
Search
Search titles only
By:
Search titles only
By:
Menu
Install the app
Install
Forums
New posts
All threads
Latest threads
New posts
Trending threads
Trending
Search forums
What's new
New posts
New ads
New profile posts
Latest activity
Free Ads
Latest reviews
Search ads
Members
Current visitors
New profile posts
Search profile posts
Contact us
Latest ads
RHCSA, RHCE, AWS, Docker, Kubernetes Training
Sanjeewani95
Updated:
Tuesday at 10:28 AM
🛡️ Kaspersky Antivirus – 1 Year / 1 Device | Rs. 2,300 | Only 9 Left
KSPathirana
Updated:
Sep 7, 2026
Ad icon
Professional CCTV Installation Service
Techguy231
Updated:
Sep 6, 2026
Ad icon
I'll research & write an article - Rs. 2000 onwards
Blogerwiki
Updated:
Sep 3, 2026
House Plan
lenura
Updated:
Sep 2, 2026
Electronics
Vehicles
Property
Search
Reply to thread
Forums
General
Education
ElaKiri Programmer's Club
Get the App
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Message
<blockquote data-quote="විල්සන් මාමා" data-source="post: 16594312" data-attributes="member: 397789"><p><strong>ඇයි ajax වලින් එන response එක දෙවෙනි dropdown එකට එකතු වෙන්නෙ &a</strong></p><p></p><p><span style="font-size: 15px">මෙතන dropdowns ඩෙකක් තියෙනවා (ඩෙකක් නෙමයි දෙකක් <img src="/styles/default/xenforo/smilies/default/lol.gif" class="smilie" loading="lazy" alt=":lol:" title="LOL :lol:" data-shortname=":lol:" />). පලවෙනි එකේ values db table එකකින් ගන්නෙ. දෙවෙනි එකෙ values වෙනස් වෙනවා first dropdown එකෙ තොරන දෙය අනුව . </span></p><p><span style="font-size: 15px"></span></p><p><u><strong>පලවෙනි dropdown එක </strong></u></p><p></p><p>[HTML]<div class="formBlock"> <label for="branch_id">Branch Name<span class="required">*</span></label> <select id="branch_id" name="branch_id" class="textInput"> <?php $branches = $branch->find_by_sql("SELECT * FROM branch");//this is an arry foreach ($branches as $branch) { echo "<option value='$branch->id'>$branch->branch_name</option> "; } ?> </select> </div> [/HTML]<u><strong>දෙවෙනි එක.</strong></u></p><p></p><p> [HTML]</p><p> <div class="formBlock"> <label for="cust_id">Customer Name <span class="required">*</span></label> <select id="cust_id" ></select> </div></p><p></p><p>[/HTML]JS</p><p></p><p>[CODE]</p><p> $(function(){ $("#branch_id").bind("change",function(){ $.ajax({ type:"GET", url:"create_loan_request.php", //same file data:"branch_id="+$("#branch_id").val(), dataType:"text", //changed this to html also success:function(html){ $("#cust_id").html(html); // I have tried append also console.log(html); //inserting options to second dropdown }, error: function(jqXHR, textStatus, errorThrown) { console.log(textStatus, errorThrown); } }); });</p><p>[/CODE]</p><p>PHP code</p><p>[PHP]</p><p>if(isset($_GET["branch_id"])){ $id=(int)$_GET["branch_id"]; $customers= Customer::find_by_sql("SELECT id,firstname,lastname FROM customer WHERE branch_id=".$id); foreach ($customers as $customer) { echo "<option value='$customer->id'>".$customer->firstname."</option>"; } }</p><p></p><p>[/PHP]<span style="font-size: 15px">Console එකේ print වෙනවා මචන්ලා හරියට.එත් දෙවෙනි dropdown එකට එන්නෙ නැහැනේ. ajax success එකේ alert කලාම <option> tags වලට අම්තරව මුලු html file එකම එනවා. </span></p></blockquote><p></p>
[QUOTE="විල්සන් මාමා, post: 16594312, member: 397789"] [b]ඇයි ajax වලින් එන response එක දෙවෙනි dropdown එකට එකතු වෙන්නෙ &a[/b] [SIZE=4]මෙතන dropdowns ඩෙකක් තියෙනවා (ඩෙකක් නෙමයි දෙකක් :lol:). පලවෙනි එකේ values db table එකකින් ගන්නෙ. දෙවෙනි එකෙ values වෙනස් වෙනවා first dropdown එකෙ තොරන දෙය අනුව . [/SIZE] [U][B]පලවෙනි dropdown එක [/B][/U] [HTML]<div class="formBlock"> <label for="branch_id">Branch Name<span class="required">*</span></label> <select id="branch_id" name="branch_id" class="textInput"> <?php $branches = $branch->find_by_sql("SELECT * FROM branch");//this is an arry foreach ($branches as $branch) { echo "<option value='$branch->id'>$branch->branch_name</option> "; } ?> </select> </div> [/HTML][U][B]දෙවෙනි එක.[/B][/U] [HTML] <div class="formBlock"> <label for="cust_id">Customer Name <span class="required">*</span></label> <select id="cust_id" ></select> </div> [/HTML]JS [CODE] $(function(){ $("#branch_id").bind("change",function(){ $.ajax({ type:"GET", url:"create_loan_request.php", //same file data:"branch_id="+$("#branch_id").val(), dataType:"text", //changed this to html also success:function(html){ $("#cust_id").html(html); // I have tried append also console.log(html); //inserting options to second dropdown }, error: function(jqXHR, textStatus, errorThrown) { console.log(textStatus, errorThrown); } }); }); [/CODE] PHP code [PHP] if(isset($_GET["branch_id"])){ $id=(int)$_GET["branch_id"]; $customers= Customer::find_by_sql("SELECT id,firstname,lastname FROM customer WHERE branch_id=".$id); foreach ($customers as $customer) { echo "<option value='$customer->id'>".$customer->firstname."</option>"; } } [/PHP][SIZE=4]Console එකේ print වෙනවා මචන්ලා හරියට.එත් දෙවෙනි dropdown එකට එන්නෙ නැහැනේ. ajax success එකේ alert කලාම <option> tags වලට අම්තරව මුලු html file එකම එනවා. [/SIZE] [/QUOTE]
Insert quotes…
Verification
Dahaya deken beduwama keeyada?
Post reply
Top
Bottom