/    Sign up×
Community /Pin to ProfileBookmark

Changing selected items

I’m creating the shipping section of a shopping cart which when a different country is selected, the price of shipping to that country changes on a label within a form.
I don’t want the user to be able to edit this value- I want it to appear much like <h1>£10.99</h1> so it’s rather large on the screen.
I’m using asp for the rest of the form processing (it’s quite complicated because the price of shipping is also calculated by the weight).

How can I display this value? and when a different country is selected, will this value automatically update the same as if it was an input box?

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@UltimaterFeb 03.2005 — You can do that with the [color=skyblue][b].innerHTML[/b][/color] property.
<i>
</i>&lt;html&gt;
&lt;head&gt;
&lt;script language="JavaScript"&gt;
var Sheqel="u20AA"
var Pound="u00A3"
var Dollar="u0024"
var RATE_US_UK=0.7
var RATE_US_IL=4.4

var totalcost=24.99 //cost in US Dollars
function ShowPrice(){
if(document.input_info.Country.value=="US")
{Price.innerHTML="&lt;H1&gt;&lt;center&gt;"
+Dollar+totalcost+"&lt;/center&gt;&lt;/H1&gt;"}
if(document.input_info.Country.value=="UK")
{Price.innerHTML="&lt;H1&gt;&lt;center&gt;"
+Pound+(Math.round(totalcost*RATE_US_UK)-0.01)+"&lt;/center&gt;&lt;/H1&gt;"}
if(document.input_info.Country.value=="IL")
{Price.innerHTML="&lt;H1&gt;&lt;center&gt;"
+Sheqel+(Math.round(totalcost*RATE_US_IL)-0.01)+"&lt;/center&gt;&lt;/H1&gt;"}
}

function ONLD(){
document.input_info.Country[0].click();ShowPrice()
}
&lt;/script&gt;
&lt;/head&gt;
&lt;body onload=ONLD()&gt;
&lt;center&gt;
&lt;form name="input_info"&gt;
&lt;table width=50% height=10% border=2&gt;
&lt;tr&gt;&lt;td style="background-color: skyblue; width: 122 px;"&gt;
&lt;STRONG&gt;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;
&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;
&amp;amp;nbsp;Price:&lt;/STRONG&gt;&lt;/td&gt;
&lt;td style="background-color: skyblue;"&gt;
&lt;STRONG&gt;Choose a Country:&lt;/STRONG&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;
&lt;div id="Price"&gt;&lt;/div&gt;&lt;/td&gt;&lt;td&gt;
&lt;select name="Country" onchange="ShowPrice()"&gt;
&lt;option selected value="US"&gt;United States&lt;/option&gt;
&lt;option value="UK"&gt;United Kingdom&lt;/option&gt;
&lt;option value="IL"&gt;Israel&lt;/option&gt;&lt;/select&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;
&lt;/form&gt;
&lt;/center&gt;
&lt;/body&gt;
&lt;/html&gt;
×

Success!

Help @neilb spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.6,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...