Jump to content

This topic is 7855 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

Hello again.......please have pity.......I'm still very, very new to JS.

What I want is this........I have performed a search on a continuing education db and returned a list of classes. Some of the classes still have space in them but some don't. I then click on a "More Information" button (a link to the record) to see information about the class like time, date, credit or not, etc. Then I have a submit button for them to "register" for this class. I want to prevent them from registering for a class that is already full.

The field is on the page. I can pass it in a token - no problem. I'm in the right database to check this field. And the field is definitely listed on the layout that I'm using.

Here is my feable attempt at JS........the goal being to have an alert box come up that the event is full but allow the button to submit (and go on to the next screen) when the event is not full.

[color:"green"]<SCRIPT LANGUAGE="JavaScript"><!--

function verify ()

{

submitOK = "false";

if (document.verify.Event_Full.value == X)

{

alert ('This class is full! No registration allowed!');

submitOK = "true";

};

if (submitOK == "false") document.verify.submit();

}

//--></script>

I'm really not sure about when to say it's false or true. I then added the onsubmit part to the form statement.

[color:"green"]<FORM NAME="verify" ACTION="FMPro" METHOD="post" onsubmit="verify(); return true;">

What happens.....nothing. It just goes on to the next screen like before. I have switched the "true" to "false" and still nothing happens........

Any suggestions......

Thanks in advance......Donna

Posted

hi Donna!

how about deducating a field to hold this walue and u can controll it..

[filed: status] or using a token=this_filed as u have mentioned

and then on the results.html page (let them enter whatever they want)

--------results.html--------------

[FMP-IF: status/token.x .eq X]

sorry this class is closed

[FMP-Else: "run your inlineaction of adding/submitting a new student]

----------------------------------

IM_very_HO Javascript here will get a bit complicated since u 1st have to pull the data then capture it into a variable and then validate...

anyhow...just a though!

All the best!

Posted

This is how I would do it:

<SCRIPT LANGUAGE="JavaScript">

function verify ()

{

if (document.verify.Event_Full.value == "X")

{

alert ('This class is full! No registration allowed!');

}

else

{

document.verify.submit();

};

}

</script>

The Form tag would look like this:

<FORM NAME="verify" ACTION="FMPro" METHOD="post" onsubmit="verify(); return false;">

All the best.

Garry

Posted

Hi Garry!

if (document.verify.Event_Full.value == "X")

would this work even on the hidden filed that has the value/token? (can u "validate" hidden field?)

....sorry for butting in.....I was just curious smile.gif

thanx_

Posted

The <input> type doesn't matter. Most Form elements are capable of holding a value. Hence, they can be "set" or "tested".

As an example:

<input type="hidden" name="-token" value="[FMP-CurrentToken]">

is

document.myform.elements["-token"].value

All the best.

Garry

Posted

On a sidenote, I would change the submit button to a simple button, and put the event handler to call the verify function on the button, not on the form, like this:

<input type="button" name="submitButton" value="Submit" onClick="verify();">

and so the form would look like this:

<FORM NAME="verify" ACTION="FMPro" METHOD="post">

This means that people with javascript turned off in their browser won't be able to bypass the verify function.

Regards

V

Posted

Hi, Donna! At least you're braving the world of JavaScript... I haven't done that yet even though I hear it can be an invaluable companion for web functionality. If someone told me I had to do a check before a submit, I'd probably look into something I read about in a post having to do with creating temporary global fields in FileMaker to hold/accept data before records are created.

JavaScript-lessly Yours, ST

Posted

RE: If someone told me I had to do a check before a submit, I'd probably look into something I read about in a post having to do with creating temporary global fields in FileMaker to hold/accept data before records are created.

I wouldn't do that, because Globals are shared for all web visitors.

It's easy to do that in JavaScript.

Or Lasso with LassoScript or in FileMaker, but with small disadvantage of round trip to server.

Posted

Hi All!

I tried Garry's suggestion but it is ignoring the field verification. I get no error messages; it just goes on to the next screen.

I do have this field in a token. It's number 7. Garry you mentioned that I might be able to verify on a token.....would that be worth a try? If so, how do I change the code to reflect that?

Here is what I have right now:

[color:"blue"]<SCRIPT LANGUAGE="JavaScript"><!--

function verify ()

{

if (document.verify.Event_Full.value == "X")

{

alert ('This class is full! No registration allowed!');

}

else

{

document.verify.submit();

};

}

//--></script>

</HEAD>

<BODY CLASS="first">

<FORM NAME="verify" ACTION="FMPro" METHOD="post" onsubmit="verify(); return false;">

<INPUT TYPE="hidden" NAME="-DB" VALUE="CE_Events">

<INPUT TYPE="hidden" NAME="-lay" VALUE="Online">

<INPUT TYPE="hidden" NAME="-Format" VALUE="login.htm">

<INPUT TYPE="hidden" NAME="-Token.3" VALUE="2003-TR24">

<INPUT TYPE="hidden" NAME="-Token.4" VALUE="OCLC/ILL: The New Web Interface">

<INPUT TYPE="hidden" NAME="-Token.7" VALUE="X">

Thanks once again for any and all help! Donna

Posted

Donna:

what is wrong with using Garry's example?

<input type="hidden" name="-token" value="[FMP-CurrentToken]">

is

document.myform.elements["-Token.7"].value

================

var Limit

Limit = document.myform.elements["-Token.7"].value

if (Limit == "X")

..

.

.

<FORM NAME="verify" ACTION="FMPro" METHOD="post" onsubmit="verify();">

===========

Also, if u like, u can use the DB to record the value of X...meaning use FM to enter how many students are alllowed.

So create another filed eg. [studsAllowed] and set some variable = to it.

eg.

=========================

var Limit

var Students

Students = [FMP-Field:Qty]

Limit = document.myform.elements["-Token.7"].value

if (Limit == "Students")

....

===================

good luck to you!

Posted

"What I want is this........I have performed a search on a continuing education db and returned a list of classes. Some of the classes still have space in them but some don't. I then click on a "More Information" button (a link to the record) to see information about the class like time, date, credit or not, etc. Then I have a submit button for them to "register" for this class. I want to prevent them from registering for a class that is already full."

Leb i Sol, "Also, if u like, u can use the DB to record the value of X...meaning use FM to enter how many students are alllowed."

Precisely, and when that is done, and "...I have performed a search on a continuing education db and returned a list of classes...", the returned page could inform, based on the db solution, HTML and CDML if a class was full on not, or could simply not show classes or disallow links to classes which are full. And since you would be using a calc_field to create that "X", you would not need the field to be physically on your web layout. laugh.gif

Posted

The "X" field is a calculated field from how many can attend to how many have signed up. That has existed since 1996.

So, that's really not an issue. The fields calculation works just fine. I can pass whether or not the class is full in a token (but Garry's original example -- see above in blue) does not use the token phrase.

I would like to try passing it in a token since his original idea didn't work. Any suggestions?

Thanks! Donna

Posted

Donna...Garry didn't but I think I have- u missed my post ?

u CAN assing form element number as well...

1----<INPUT TYPE="hidden" NAME="-DB" VALUE="CE_Events">

2--<INPUT TYPE="hidden" NAME="-layout" VALUE="Online">

3---<INPUT TYPE="hidden" NAME="-Format" VALUE="login.htm">

4---<INPUT TYPE="hidden" NAME="-Token.3" VALUE="2003-TR24">

5---<INPUT TYPE="hidden" NAME="-Token.4" VALUE="OCLC/ILL: The New Web Interface">

6---<INPUT TYPE="hidden" NAME="-Token.7" VALUE="X">

====================

IF document.myform.element[6].value =="X"

again...this is theory... smile.gif

Posted

Hi Donna,

If the "document in blue" to which you refer is #74871 - 07/16/03 08:49 AM - and if my understanding of your Form in that post is correct, then the -Token.7 is being assigned the value X by the (unnamed) action of that form; therefore that value will be established upon form submission. Until that value is established (successfully assigned by an action), the JavaScript is meaningless.

But I could be misunderstanding the processing sequence here since

Posted

I've assumed that you have a field called "Event_Full". Hence, any of these will work:

<SCRIPT LANGUAGE="JavaScript"><!--

function verify ()

{

if ("[FMP-Field:Event_Full]" == "X")

{

alert ('This class is full! No registration allowed!');

}

else

{

document.verify.submit();

};

}

//--></script>

</HEAD>

<BODY CLASS="first">

<FORM NAME="verify" ACTION="FMPro" METHOD="post" onsubmit="verify(); return false;">

<INPUT TYPE="hidden" NAME="-DB" VALUE="CE_Events">

<INPUT TYPE="hidden" NAME="-lay" VALUE="Online">

<INPUT TYPE="hidden" NAME="-Format" VALUE="login.htm">

<INPUT TYPE="hidden" NAME="-Token.3" VALUE="2003-TR24">

<INPUT TYPE="hidden" NAME="-Token.4" VALUE="OCLC/ILL: The New Web Interface">

<INPUT TYPE="hidden" NAME="-Token.7" VALUE="X">

Or

<SCRIPT LANGUAGE="JavaScript"><!--

function verify ()

{

if (document.verify.elements["-Token.7"].value == "X")

{

alert ('This class is full! No registration allowed!');

}

else

{

document.verify.submit();

};

}

//--></script>

</HEAD>

<BODY CLASS="first">

<FORM NAME="verify" ACTION="FMPro" METHOD="post" onsubmit="verify(); return false;">

<INPUT TYPE="hidden" NAME="-DB" VALUE="CE_Events">

<INPUT TYPE="hidden" NAME="-lay" VALUE="Online">

<INPUT TYPE="hidden" NAME="-Format" VALUE="login.htm">

<INPUT TYPE="hidden" NAME="-Token.3" VALUE="2003-TR24">

<INPUT TYPE="hidden" NAME="-Token.4" VALUE="OCLC/ILL: The New Web Interface">

<INPUT TYPE="hidden" NAME="-Token.7" VALUE="[FMP-Field:Event_Full]">

I hope that I have made the correct assumption smile.gif

Both Leb and Unable have useful comments.

Good Luck.

Garry

Posted

Hi.......

I tried the suggestion of changing the IF statement (still doesn't work). I now have.....

[color:"blue"] <SCRIPT LANGUAGE="JavaScript"><!--

function verify ()

{

if (document.myform.element[6].value == "X")

{

alert ('This class is full! No registration allowed!');

}

else

{

document.verify.submit();

};

}

//--></script>

</HEAD>

<BODY CLASS="first">

<FORM NAME="verify" ACTION="FMPro" METHOD="post" onsubmit="verify(); return false;">

<INPUT TYPE="hidden" NAME="-DB" VALUE="CE_Events">

<INPUT TYPE="hidden" NAME="-lay" VALUE="Online">

<INPUT TYPE="hidden" NAME="-Format" VALUE="login.htm">

<INPUT TYPE="hidden" NAME="-Token.3" VALUE="2003-TR24">

<INPUT TYPE="hidden" NAME="-Token.4" VALUE="OCLC/ILL: The New Web Interface">

<INPUT TYPE="hidden" NAME="-Token.7" VALUE="X">

Did I make a mistake in understanding what you are trying to tell me?

Again, any help is appreciated! Thanks! Donna

Posted

The "if" should be:

if (document.verify.elements[5].value == "X")

The name of the Form is "verify" and the field should be "elements", and the numbering of the <input> tags starts at 0.

With what you have the class will always be "full"! This is because you are testing against Token.7 which is "hard-wired" to the value of "X".

All the best.

Garry

  • 3 weeks later...
Posted

Garry:

You have done it again! What I wouldn't give to know what you know......

Oh well, sorry it took so long to respond but again I ended up doing my "real job" for a week or so, and now I'm back to this.

Thanks to everyone who offered help. It is greatly appreciated!

Thank you! Thank you! Thank you!

This topic is 7855 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.