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
Puffin Rock Characters Plush Toy Set
anil1961
Updated:
Saturday at 3:51 PM
Toyota Vitz scp10 For Sale
Lakmal Bandara
Updated:
Nov 4, 2026
Kandy
Welcome all my all new pet shop Bark.lk
dilumrane
Updated:
Nov 2, 2026
Windows RDP Only Rs.500 a month
Blogerwiki
Updated:
Nov 1, 2026
Ad icon
V2ray VPN for Tunneling
hu KANNA
Updated:
Oct 22, 2026
Electronics
Vehicles
Property
Search
Reply to thread
Forums
General
ElaKiri Talk!
Java Script help එකක්!!!
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="ishan0001" data-source="post: 21845084" data-attributes="member: 262672"><p><span style="font-size: 12px">මුලින්ම API call එකක් දානව country data ටික variable එකකට ගන්න. ඒකට use කරන්නෙ GetJSON. ඒකට url එකයි callback function එකකුයි දාන්න ඕන. Data ටික ආවොත් ඒ ටික දාල callback function එක call වෙනව. ඒක ඇතුලෙ ලියල තියනව data json එකේ හැම object එකකටම අදාලව dropdown එකට option element එක ගානෙ add කරන්න කියල. ඔය ටික ඔක්කොම කරන්නෙ document ready උනාම. ඒ කියන්නෙ page එක ලෝඩ් වෙලා ඉවර උනාම.</span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px">ඊලගට dropdown එකෙන් කැමති රට තෝරල button එක click කලාම populate function එක call වෙනව. ඒකෙ ලියල තියෙන්නෙ dropdown එකේ select කරල තියන value එක name එක විදියට තියන json එක return කරන්න කියල. මේකෙන් ඇත්තටම return වෙන්නෙ අදාල json එක විතරක් තියන json array එකක්. ඒ නිසා අපිට අදාල json object එක refer කරන්න json array එකේ 0th index එක ගන්න වෙනව (<span style="color: #000000">selectedCountry[0]</span>). ඒකෙත් callingCodes කියන්නෙ තව json එකක්. ඒකෙ 0h index එකේ තමයි අවශ්ය dial code එක තියෙන්නෙ. ඊට පස්සෙ alert එකක් දාල ඒක display කරන්න තියෙන්නෙ.</span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px">api එකෙන් country එකේ තව ගොඩක් විස්තර එනව. ඒ නිසා api response එක ටිකක් bulky. ඔය මට්ටමේ program එකක් performance critical නැති නිසා ඒක අව්ලක් වෙන්නෙ නෑ. optimize කරන්න ඕනම නම් country code එකයි dial code එකයි විතරක් දෙන api තියෙනව ඒකක් use කරන්න. ඔය වැඩේට විතරක් නම් data ටික databse එකක දාගෙන නටන්න ඕන නෑ.</span> <img src="/styles/default/xenforo/smilies/default/happy.gif" class="smilie" loading="lazy" alt=":)" title="Happy :)" data-shortname=":)" /><img src="/styles/default/xenforo/smilies/default/happy.gif" class="smilie" loading="lazy" alt=":)" title="Happy :)" data-shortname=":)" /></p><p style="text-align: center"><span style="color: #FFFFFF">Save</span></p></blockquote><p></p>
[QUOTE="ishan0001, post: 21845084, member: 262672"] [SIZE=3]මුලින්ම API call එකක් දානව country data ටික variable එකකට ගන්න. ඒකට use කරන්නෙ GetJSON. ඒකට url එකයි callback function එකකුයි දාන්න ඕන. Data ටික ආවොත් ඒ ටික දාල callback function එක call වෙනව. ඒක ඇතුලෙ ලියල තියනව data json එකේ හැම object එකකටම අදාලව dropdown එකට option element එක ගානෙ add කරන්න කියල. ඔය ටික ඔක්කොම කරන්නෙ document ready උනාම. ඒ කියන්නෙ page එක ලෝඩ් වෙලා ඉවර උනාම. ඊලගට dropdown එකෙන් කැමති රට තෝරල button එක click කලාම populate function එක call වෙනව. ඒකෙ ලියල තියෙන්නෙ dropdown එකේ select කරල තියන value එක name එක විදියට තියන json එක return කරන්න කියල. මේකෙන් ඇත්තටම return වෙන්නෙ අදාල json එක විතරක් තියන json array එකක්. ඒ නිසා අපිට අදාල json object එක refer කරන්න json array එකේ 0th index එක ගන්න වෙනව ([COLOR=#000000]selectedCountry[0][/COLOR]). ඒකෙත් callingCodes කියන්නෙ තව json එකක්. ඒකෙ 0h index එකේ තමයි අවශ්ය dial code එක තියෙන්නෙ. ඊට පස්සෙ alert එකක් දාල ඒක display කරන්න තියෙන්නෙ. api එකෙන් country එකේ තව ගොඩක් විස්තර එනව. ඒ නිසා api response එක ටිකක් bulky. ඔය මට්ටමේ program එකක් performance critical නැති නිසා ඒක අව්ලක් වෙන්නෙ නෑ. optimize කරන්න ඕනම නම් country code එකයි dial code එකයි විතරක් දෙන api තියෙනව ඒකක් use කරන්න. ඔය වැඩේට විතරක් නම් data ටික databse එකක දාගෙන නටන්න ඕන නෑ.[/SIZE] :):) [CENTER][COLOR=#FFFFFF]Save[/COLOR][/CENTER] [/QUOTE]
Insert quotes…
Verification
Dawasata paya keeyak thibeda?
Post reply
Top
Bottom