Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

jquery onchange cause a loop

Featured Replies

Hi all, i am just learning more about jquery, i have on a website a shipping calculator that works from a link, it pops up and you select the country and press a submit button to calculate shipping for your country, i have changed this to be inline with the rest of the basket details, so onchange it calculates the shipping, the problem i have with this is it will not calculate shipping onload.

 

so using jquery i have triggered an onchange event which works but then puts the page in a loop so another country can not be selected.

<script>
$(document).ready(function() {
 $('#myselect').trigger('change');
})
</script>

<select id="myselect"  name="country_id" onchange="this.form.submit();">

 

is there away around this or am going about it the wrong way

 

Thank you

Hi all, i am just learning more about jquery, i have on a website a shipping calculator that works from a link, it pops up and you select the country and press a submit button to calculate shipping for your country, i have changed this to be inline with the rest of the basket details, so onchange it calculates the shipping, the problem i have with this is it will not calculate shipping onload.

 

so using jquery i have triggered an onchange event which works but then puts the page in a loop so another country can not be selected.

<script>
$(document).ready(function() {
 $('#myselect').trigger('change');
})
</script>

<select id="myselect"  name="country_id" onchange="this.form.submit();">

 

is there away around this or am going about it the wrong way

 

Thank you

 

I hope I'm not misunderstanding your question. You want to calculate shipping onload, right? Did you try this bit of code?

 

 

$(function(){
   $(window).bind("load", function(){

       //calculations

   })
})

 

 

Edited by Iris

  • Author

I hope I'm not misunderstanding your question. You want to calculate shipping onload, right? Did you try this bit of code?

 

 

$(function(){
   $(window).bind("load", function(){

       //calculations

   })
})

thanks for the reply, i did it a different way in the end, the shipping form method was get so onload i set the country_id to 77 in the URL

 

Thank you

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.