form / java question

S

sluijten

What can be suddenly wrong with this java script (it calculates
participants x price = total price)???

function bereken() {
var prijs = 5.0
var totaal = ""
aantal = document.FrontPage_Form1.aantal_lopers.value
tempNumber = aantal * prijs
tempNumber = Math.round(tempNumber * 100)
tempString = "" + tempNumber
totaal = "€ " + tempString.substring(0,(tempString.length-2))
totaal += "," +
tempString.substring((tempString.length-2),tempString.length)
document.FrontPage_Form1.totaal.value = totaal
}

The run time error says:
document.FrontPage_Form1.aantal_lopers.value is null or not an object.

It has always worked!! The form part looks as follows:

<!--webbot bot="Validation" b-value-required="TRUE"
b-disallow-first-item="TRUE" --><select name="aantal_lopers" size="1">
<option value="&lt;pick one&gt;">&lt;kies uit&gt;</option>
<option value="1">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>
</select>
 
J

Jon Spivey

Hi,
This line
aantal = document.FrontPage_Form1.aantal_lopers.value
should be
aantal =
document.FrontPage_Form1.aantal_lopers.options[document.FrontPage_Form1.aantal_lopers.options.selectedIndex].value;

Cheers,
Jon

What can be suddenly wrong with this java script (it calculates
participants x price = total price)???

function bereken() {
var prijs = 5.0
var totaal = ""
aantal = document.FrontPage_Form1.aantal_lopers.value
tempNumber = aantal * prijs
tempNumber = Math.round(tempNumber * 100)
tempString = "" + tempNumber
totaal = "? " + tempString.substring(0,(tempString.length-2))
totaal += "," +
tempString.substring((tempString.length-2),tempString.length)
document.FrontPage_Form1.totaal.value = totaal
}

The run time error says:
document.FrontPage_Form1.aantal_lopers.value is null or not an object.

It has always worked!! The form part looks as follows:

<!--webbot bot="Validation" b-value-required="TRUE"
b-disallow-first-item="TRUE" --><select name="aantal_lopers" size="1">
<option value="&lt;pick one&gt;">&lt;kies uit&gt;</option>
<option value="1">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>
</select>
 
M

Murray

It's javascript, not Java.

--
Murray
--------------
MVP FrontPage


What can be suddenly wrong with this java script (it calculates
participants x price = total price)???

function bereken() {
var prijs = 5.0
var totaal = ""
aantal = document.FrontPage_Form1.aantal_lopers.value
tempNumber = aantal * prijs
tempNumber = Math.round(tempNumber * 100)
tempString = "" + tempNumber
totaal = "? " + tempString.substring(0,(tempString.length-2))
totaal += "," +
tempString.substring((tempString.length-2),tempString.length)
document.FrontPage_Form1.totaal.value = totaal
}

The run time error says:
document.FrontPage_Form1.aantal_lopers.value is null or not an object.

It has always worked!! The form part looks as follows:

<!--webbot bot="Validation" b-value-required="TRUE"
b-disallow-first-item="TRUE" --><select name="aantal_lopers" size="1">
<option value="&lt;pick one&gt;">&lt;kies uit&gt;</option>
<option value="1">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>
</select>
 
S

sluijten

Jon,
thanks for the quick response!
Now I have:

<script language="javascript">
function bereken() {
var prijsbus = 13.5
var prijskamer = 6.5
var korting = 6
var totaal = ""
aantalbus =
document.FrontPage_Form1.ik_ga_mee_met.options[document.FrontPage_Form1.ik_ga_mee_met.options.selectedIndex].value;
aantalkamer =
document.FrontPage_Form1.gebruik_hotelkamer.options[document.FrontPage_Form1.gebruik_hotelkamer.selectedIndex].value;
aantallid =

document.FrontPage_Form1.aantal_lid.options[document.FrontPage_Form1.aantal_lid.selectedIndex].value;
tempNumber = aantalbus * prijsbus + aantalkamer * prijskamer -
aantallid * korting
tempNumber = Math.round(tempNumber * 100)
tempString = "" + tempNumber
totaal = "€ " + tempString.substring(0,(tempString.length-2))
totaal += "," +
tempString.substring((tempString.length-2),tempString.length)
document.FrontPage_Form1.totaal.value = totaal
}

</script>


But still the same error.....
 
J

Jon Spivey

Can I see the page online?

Jon

Jon,
thanks for the quick response!
Now I have:

<script language="javascript">
function bereken() {
var prijsbus = 13.5
var prijskamer = 6.5
var korting = 6
var totaal = ""
aantalbus =
document.FrontPage_Form1.ik_ga_mee_met.options[document.FrontPage_Form1.ik_ga_mee_met.options.selectedIndex].value;
aantalkamer =
document.FrontPage_Form1.gebruik_hotelkamer.options[document.FrontPage_Form1.gebruik_hotelkamer.selectedIndex].value;
aantallid =

document.FrontPage_Form1.aantal_lid.options[document.FrontPage_Form1.aantal_lid.selectedIndex].value;
tempNumber = aantalbus * prijsbus + aantalkamer * prijskamer -
aantallid * korting
tempNumber = Math.round(tempNumber * 100)
tempString = "" + tempNumber
totaal = "? " + tempString.substring(0,(tempString.length-2))
totaal += "," +
tempString.substring((tempString.length-2),tempString.length)
document.FrontPage_Form1.totaal.value = totaal
}

</script>


But still the same error.....
 
S

sluijten

Sure Jon, here it is (it's in Dutch, its a form to register for a bus
trip to the rotterdam marathon):

http://www.joggingclubdow.nl/bus/aanmelden_rotterdam.htm

I think the form is not recognized as a form....

The following HTML code is put just before the javascript:
<form method="POST" action="bus_form_handler.php?deelnrrdam.dat">
</form>

And when I remove the </form>, and save, Frontpage bluntly puts it back
where I just removed it !!!

Stef
btw: thanks for your help!!


Can I see the page online?

Jon

Jon,
thanks for the quick response!
Now I have:

<script language="javascript">
function bereken() {
var prijsbus = 13.5
var prijskamer = 6.5
var korting = 6
var totaal = ""
aantalbus =
document.FrontPage_Form1.ik_ga_mee_met.options[document.FrontPage_Form1.ik_­ga_mee_met.options.selectedIndex].value;
aantalkamer =
document.FrontPage_Form1.gebruik_hotelkamer.options[document.FrontPage_Form­1.gebruik_hotelkamer.selectedIndex].value;
aantallid =

document.FrontPage_Form1.aantal_lid.options[document.FrontPage_Form1.aantal­_lid.selectedIndex].value;
tempNumber = aantalbus * prijsbus + aantalkamer * prijskamer -
aantallid * korting
tempNumber = Math.round(tempNumber * 100)
tempString = "" + tempNumber
totaal = "? " + tempString.substring(0,(tempString.length-2))
totaal += "," +
tempString.substring((tempString.length-2),tempString.length)
document.FrontPage_Form1.totaal.value = totaal

} </script>

But still the same error.....

Hi,
This line
aantal = document.FrontPage_Form1.aantal_lopers.value
should be
aantal =
document.FrontPage_Form1.aantal_lopers.options[document.FrontPage_Form1..aan­­tal_lopers.options.selectedIndex].value;
Cheers,
Jon

messageWhat can be suddenly wrong with this java script (it calculates
participants x price = total price)???
function bereken() {
var prijs = 5.0
var totaal = ""
aantal = document.FrontPage_Form1.aantal_lopers.value
tempNumber = aantal * prijs
tempNumber = Math.round(tempNumber * 100)
tempString = "" + tempNumber
totaal = "? " + tempString.substring(0,(tempString.length-2))
totaal += "," +
tempString.substring((tempString.length-2),tempString.length)
document.FrontPage_Form1.totaal.value = totaal
}The run time error says:
document.FrontPage_Form1.aantal_lopers.value is null or not an object.
It has always worked!! The form part looks as follows:
<!--webbot bot="Validation" b-value-required="TRUE"
b-disallow-first-item="TRUE" --><select name="aantal_lopers" size="1">
<option value="&lt;pick one&gt;">&lt;kies uit&gt;</option>
<option value="1">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>
</select>- Tekst uit oorspronkelijk bericht niet weergeven -- Tekst uitoorspronkelijk bericht weergeven -
 
J

Jon Spivey

OK. It is the form tag to blame here. It should surround your fields, eg
<form name="FrontPage_Form1"....
your fields
</form>

Alternative is to pass the form into the function then you don't need to
name the form, eg
<input onclick="bereken(this.form)"
and then reference the fields thus
function bereken(f) {
aantalbus
=f.ik_ga_mee_met.options[f.ik_­ga_mee_met.options.selectedIndex].value;
// etc

Whichever way you do this though you have to get the <form> and </form> tags
surrounding the form fields.

Cheers,
Jon

Sure Jon, here it is (it's in Dutch, its a form to register for a bus
trip to the rotterdam marathon):

http://www.joggingclubdow.nl/bus/aanmelden_rotterdam.htm

I think the form is not recognized as a form....

The following HTML code is put just before the javascript:
<form method="POST" action="bus_form_handler.php?deelnrrdam.dat">
</form>

And when I remove the </form>, and save, Frontpage bluntly puts it back
where I just removed it !!!

Stef
btw: thanks for your help!!


Can I see the page online?

Jon

messageJon,
thanks for the quick response!
Now I have:

<script language="javascript">
function bereken() {
var prijsbus = 13.5
var prijskamer = 6.5
var korting = 6
var totaal = ""
aantalbus =
document.FrontPage_Form1.ik_ga_mee_met.options[document.FrontPage_Form1.ik_­ga_mee_met.options.selectedIndex].value;
aantalkamer =
document.FrontPage_Form1.gebruik_hotelkamer.options[document.FrontPage_Form­1.gebruik_hotelkamer.selectedIndex].value;
aantallid =

document.FrontPage_Form1.aantal_lid.options[document.FrontPage_Form1.aantal­_lid.selectedIndex].value;
tempNumber = aantalbus * prijsbus + aantalkamer * prijskamer -
aantallid * korting
tempNumber = Math.round(tempNumber * 100)
tempString = "" + tempNumber
totaal = "? " + tempString.substring(0,(tempString.length-2))
totaal += "," +
tempString.substring((tempString.length-2),tempString.length)
document.FrontPage_Form1.totaal.value = totaal

} </script>

But still the same error.....

Hi,
This line
aantal = document.FrontPage_Form1.aantal_lopers.value
should be
aantal =
document.FrontPage_Form1.aantal_lopers.options[document.FrontPage_Form1.aan­­tal_lopers.options.selectedIndex].value;
Cheers,
Jon

messageWhat can be suddenly wrong with this java script (it calculates
participants x price = total price)???
function bereken() {
var prijs = 5.0
var totaal = ""
aantal = document.FrontPage_Form1.aantal_lopers.value
tempNumber = aantal * prijs
tempNumber = Math.round(tempNumber * 100)
tempString = "" + tempNumber
totaal = "? " + tempString.substring(0,(tempString.length-2))
totaal += "," +
tempString.substring((tempString.length-2),tempString.length)
document.FrontPage_Form1.totaal.value = totaal
}The run time error says:
document.FrontPage_Form1.aantal_lopers.value is null or not an object.
It has always worked!! The form part looks as follows:
<!--webbot bot="Validation" b-value-required="TRUE"
b-disallow-first-item="TRUE" --><select name="aantal_lopers" size="1">
<option value="&lt;pick one&gt;">&lt;kies uit&gt;</option>
<option value="1">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>
</select>- Tekst uit oorspronkelijk bericht niet weergeven -- Tekst uit
oorspronkelijk bericht weergeven -
 
S

sluijten

OK, it seems to work now. After changing the setting in Frontpage:
Tools...Page Options...HTML Source...
a couple of times and saving the file, the </form> didn't come back.
Thanks!

OK. It is the form tag to blame here. It should surround your fields, eg
<form name="FrontPage_Form1"....
your fields
</form>

Alternative is to pass the form into the function then you don't need to
name the form, eg
<input onclick="bereken(this.form)"
and then reference the fields thus
function bereken(f) {
aantalbus
=f.ik_ga_mee_met.options[f.ik_­ga_mee_met.options.selectedIndex].value;
// etc

Whichever way you do this though you have to get the <form> and </form> tags
surrounding the form fields.

Cheers,
Jon

Sure Jon, here it is (it's in Dutch, its a form to register for a bus
trip to the rotterdam marathon):

http://www.joggingclubdow.nl/bus/aanmelden_rotterdam.htm

I think the form is not recognized as a form....

The following HTML code is put just before the javascript:
<form method="POST" action="bus_form_handler.php?deelnrrdam.dat">
</form>

And when I remove the </form>, and save, Frontpage bluntly puts it back
where I just removed it !!!

Stef
btw: thanks for your help!!

Can I see the page online?

messageJon,
thanks for the quick response!
Now I have:
<script language="javascript">
function bereken() {
var prijsbus = 13.5
var prijskamer = 6.5
var korting = 6
var totaal = ""
aantalbus =
document.FrontPage_Form1.ik_ga_mee_met.options[document.FrontPage_Form1..ik_­­ga_mee_met.options.selectedIndex].value;
aantalkamer =
document.FrontPage_Form1.gebruik_hotelkamer.options[document.FrontPage_Form­­1.gebruik_hotelkamer.selectedIndex].value;
aantallid =
document.FrontPage_Form1.aantal_lid.options[document.FrontPage_Form1.aantal­­_lid.selectedIndex].value;
tempNumber = aantalbus * prijsbus + aantalkamer * prijskamer -
aantallid * korting
tempNumber = Math.round(tempNumber * 100)
tempString = "" + tempNumber
totaal = "? " + tempString.substring(0,(tempString.length-2))
totaal += "," +
tempString.substring((tempString.length-2),tempString.length)
document.FrontPage_Form1.totaal.value = totaal
} </script>
But still the same error.....
Hi,
This line
aantal = document.FrontPage_Form1.aantal_lopers.value
should be
aantal =
document.FrontPage_Form1.aantal_lopers.options[document.FrontPage_Form1.aan­­­tal_lopers.options.selectedIndex].value;
Cheers,
Jon
messageWhat can be suddenly wrong with this java script (it calculates
participants x price = total price)???
function bereken() {
var prijs = 5.0
var totaal = ""
aantal = document.FrontPage_Form1.aantal_lopers.value
tempNumber = aantal * prijs
tempNumber = Math.round(tempNumber * 100)
tempString = "" + tempNumber
totaal = "? " + tempString.substring(0,(tempString.length-2))
totaal += "," +
tempString.substring((tempString.length-2),tempString.length)
document.FrontPage_Form1.totaal.value = totaal
}The run time error says:
document.FrontPage_Form1.aantal_lopers.value is null or not an object.
It has always worked!! The form part looks as follows:
<!--webbot bot="Validation" b-value-required="TRUE"
b-disallow-first-item="TRUE" --><select name="aantal_lopers" size="1">
<option value="&lt;pick one&gt;">&lt;kies uit&gt;</option>
<option value="1">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>
</select>- Tekst uit oorspronkelijk bericht niet weergeven -- Tekst uit
oorspronkelijk bericht weergeven -- Hide quoted text -- Show quoted text -
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top