homepage Welcome to WebmasterWorld Guest from 54.226.147.84
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
Upon Render Remove Countries From DropDown List
theblade24

10+ Year Member



 
Msg#: 4632136 posted 1:02 pm on Dec 19, 2013 (gmt 0)

Hi, I have a dropdown list of countries used to select which countries I'll ship to.

I really only need it to be United States and Canada.... but the list of options includes about every country there is.

I cannot alter this list, there is a template tag that simply spits out the following code when the page renders (list shorted for ease of display)

<select name="billing_country" onchange="document.billing.action='checkout3.asp?step=3&amp;action=updatecountry';document.billing.submit();" class="txtBoxStyle">
<option value="AF">
Afghanistan
</option>
<option value="AX">
Aland Islands
</option>
<option value="AL">
Albania
</option>
<option value="DZ">
Algeria
</option>
<option value="AS">
American Samoa
</option>
<option value="AD">
Andorra
</option>
<option value="AO">
Angola
</option>
<option value="AI">
Anguilla
</option>
<option value="AQ">
Antarctica
</option>
<option value="AG">
Antigua &amp; Barbuda
</option>
<option value="CA">
Canada
</option>
<option selected="" value="US">
United States
</option>
</selected>

I need a method of removing all the choices from the list except United States and Canada so only those two can be seen when the list drops down.

Can this be done with javascript? Code?

 

Fotiman

WebmasterWorld Senior Member fotiman us a WebmasterWorld Top Contributor of All Time 5+ Year Member



 
Msg#: 4632136 posted 2:02 pm on Dec 19, 2013 (gmt 0)

It can be done with JavaScript, but should not be. Any users that don't have JavaScript will get the full list still. You really should modify the template to remove the options.

theblade24

10+ Year Member



 
Msg#: 4632136 posted 4:40 pm on Dec 19, 2013 (gmt 0)

Unfortunately, as I mentioned

"I cannot alter this list, there is a template tag that simply spits out the following code when the page renders"

Fotiman

WebmasterWorld Senior Member fotiman us a WebmasterWorld Top Contributor of All Time 5+ Year Member



 
Msg#: 4632136 posted 5:10 pm on Dec 19, 2013 (gmt 0)

And as I mentioned "You really should modify the template to remove the options."

Why can't you modify the template?

theblade24

10+ Year Member



 
Msg#: 4632136 posted 5:16 pm on Dec 19, 2013 (gmt 0)

Because the template simply has a template tag [ddcountrylist] that produces that code.

I don't have access to what that tag spits out.

I can only possibly change it before the page render is complete.

Fotiman

WebmasterWorld Senior Member fotiman us a WebmasterWorld Top Contributor of All Time 5+ Year Member



 
Msg#: 4632136 posted 5:34 pm on Dec 19, 2013 (gmt 0)

What kind of template is it? PHP? Where is the code behind that template tag that generates the output? That's what you should be modifying.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved