Forum Moderators: open

Message Too Old, No Replies

JavaScript question

Question related to setting fields in a form

         

ecroswell21

6:46 pm on Jun 23, 2004 (gmt 0)


First, thank you for taking the time to read this. Im using an Interactive PDF that requires JavaScript to do some checking in the form. I am letting people sign up for a conference online. Some people need a hotel and some dont. So based on what someone selects in dropdown menus, it inserts a dollar amount on the grand total. At the current time, I have a JavaScript chekcing to make sure that the arrival date is before the departure date. What Im having a problem with is if someone checks the NOHOTEL checkbox I want that dollar amount to be 0. code below......

var f = this.getField("departure")
var g = this.getField("arrival")
var h = this.getField("nohotel")
event.value = f.value - g.value

if (event.value < 0){
app.alert("Check Out date must be AFTER Check In date")
}

DO i have to put at the end of this something like.... if (document.form1.nothotel.checked == true) {
? I want it to set a value of zero here
}

crashomon

8:42 pm on Jun 23, 2004 (gmt 0)

10+ Year Member



It sounds like you need to use a ternary operator

[webmasterworld.com...]

"In use, this operator takes the form expression1? expression2 : expression 3. Expression1 must be a Boolean - that means it must evaluate to either True or False. If expression1 is True, the ternary operator will return expression2 as a result. If expression1 is False, then the ternary operator will return expression3 as a result. "

Does that help?

Bernard Marx

9:15 pm on Jun 23, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I think that? was just a?, meaning "and what here?". Apart from that, I don't know. There's a lot of object methods (from the PDF interface?). Set dollarAmount to zero?

dollarAmount = 0

That can't be it, surely. We need more.