It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming JavaScript Forum

alert

alert

Postby peterfc2 on Thu May 22, 2008 11:28 am

<script>
{
alert("You Pledged=");
document.write(document.form.Bricks_Pledged.value)
}
</script>

newby. Why this not working please?
peterfc2
 
Posts: 4
Joined: Thu May 22, 2008 11:22 am

Postby flabbyrabbit on Thu May 22, 2008 11:43 am

So you want to show an alert that says "You Pledged=" then the value that they submitted from the form?

Flabby Rabbit
Image
User avatar
flabbyrabbit
500+ Club
 
Posts: 706
Joined: Thu Jan 25, 2007 1:10 pm
Location: Midlands, England

Postby peterfc2 on Thu May 22, 2008 12:56 pm

well really don't need the alert box.
<select name="Bricks_Pledged" size="1">
<option value="1" selected>1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
</select>

Then I want to show on the print what they selected please.

You selected 'n' of bricks
peterfc2
 
Posts: 4
Joined: Thu May 22, 2008 11:22 am

Postby flabbyrabbit on Thu May 22, 2008 2:36 pm

Are you showing "You selected 'n' of bricks" on the same page and it changes when they change their selection from the drop down box?

Flabby Rabbit
Image
User avatar
flabbyrabbit
500+ Club
 
Posts: 706
Joined: Thu Jan 25, 2007 1:10 pm
Location: Midlands, England

Postby peterfc2 on Thu May 22, 2008 2:43 pm

yes.as soon as it changed from the selected [1]. otherwise it does not need to be displayed
peterfc2
 
Posts: 4
Joined: Thu May 22, 2008 11:22 am

Postby flabbyrabbit on Thu May 22, 2008 2:59 pm

This is the way I would do it:
Code: Select all
<form name="pledge">
<select onChange="javascript:change_pledge();" name="Bricks_Pledged" size="1">
<option value="1" selected>1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
</select>
</form>

<p id="pledge_text"></p>

<script type="text/javascript">
function change_pledge(){
num = document.pledge.Bricks_Pledged.value;
text = "You selected " + num + " bricks"
document.getElementById('pledge_text').innerHTML=text;
}
</script>

I'm sure some one will think of a better way of doing it, but that works.

Flabby Rabbit
Image
User avatar
flabbyrabbit
500+ Club
 
Posts: 706
Joined: Thu Jan 25, 2007 1:10 pm
Location: Midlands, England

Postby peterfc2 on Thu May 22, 2008 6:04 pm

Works a treat. Thank you for your time.
peterfc2
 
Posts: 4
Joined: Thu May 22, 2008 11:22 am

Postby flabbyrabbit on Thu May 22, 2008 6:09 pm

Glad I could be of assistance.

Flabby Rabbit
Image
User avatar
flabbyrabbit
500+ Club
 
Posts: 706
Joined: Thu Jan 25, 2007 1:10 pm
Location: Midlands, England


Who is online

Users browsing this forum: No registered users and 8 guests