NetTalk Central

Author Topic: How to make a form popup  (Read 7171 times)

MyBrainIsFull

  • Full Member
  • ***
  • Posts: 134
    • View Profile
How to make a form popup
« on: August 12, 2015, 09:39:28 PM »
Hi all, in a quiz I ask a multiple choice question, someone clicks an answer and presses submit.

This submit button calls server side code to determine if they answered correctly or not, I make a greed (good) screen or red (bad) screen open for 2 seconds then back to the quiz.

When I do this as a non popup form it works fine.

What I want to do is make the Memory Form open as a popup, not as an action that is on the browser, this is clarion code on the server, I want to make a popup that closes itself, then navigation goes back to the quiz.

Eg
if StudentAnswer = TrueAnswer
   PopupGreen
else
   PopupRed
end

My attempts to make the form a popup causes the form to open as a popup, but its blank, that is, there are no fields, buttons or images on the popup, and its in the wrong theme. So obviously its not being initialised correctly. 

This appears to be because the popup is part of the parent (calling) form and needs to be populated much earlier.

Anyone done this ?

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: How to make a form popup
« Reply #1 on: August 12, 2015, 10:55:11 PM »
Hi Kevin,

not quite on the same track, but there is a "popup" message you can use when a field is completed.

p_web.script('ntAlert("Well Done",'Right")

This opens a small popup with a button they can press to close it. In 8.60 I've added a timer to this as well so it becomes;

p_web.script('ntAlert("Well Done",'Right",1000) ! time in thousandths of a second

Cheers
Bruce

MyBrainIsFull

  • Full Member
  • ***
  • Posts: 134
    • View Profile
Re: How to make a form popup
« Reply #2 on: August 12, 2015, 11:53:13 PM »
Thanks Bruce

Will this be an Alert boxes in JavaScript which can only display pure text.
Or using jQuery to display a modal instead ?  ie can have an image on it.

Kevin

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: How to make a form popup
« Reply #3 on: August 14, 2015, 01:28:24 AM »
at this point it's pure text.

terryd

  • Hero Member
  • *****
  • Posts: 759
    • View Profile
    • Davcomm
    • Email
Re: How to make a form popup
« Reply #4 on: August 30, 2015, 12:22:31 AM »

If I use p_web.Script('ntAlert("This Stall is still available.","Wonderful");')  on a NetWebPage the message popsup but any code after the popup is also processed. In my case I used code suggested by Kevin to chain to a new page like this:
        p_web.Script('ntAlert("This Stall is still available.","Wonderful");')   
        p_web.Script(  P_web.WindowOpen('IndexPage') )

The popup flickers on but so fast that it is not readable and the the new webpage is called immediately.

I was under the impression that Alert was a bit like the Windows Message box where execution is paused until the button is clicked.
Your new version in 8.60 would be great but only if the execution pauses for the nominated length of time in this particular instance.
Terry Davidson
Windows 10 64 bit/Windows7 64bit
Clarion 9.1.11529/Clarion10 12567
Nettalk 913
Nettalk 1015
StringTheory267/Winevent515/XFiles298/MessageBox239/Cryptonite186

MyBrainIsFull

  • Full Member
  • ***
  • Posts: 134
    • View Profile
Re: How to make a form popup
« Reply #5 on: August 30, 2015, 12:49:44 AM »
You cannot ask the web page to halt the server in an asynchronous system.

Your only choice here is to call a separate page and put the conditional code here when the user clicks a button
« Last Edit: August 30, 2015, 12:52:10 AM by MyBrainIsFull »

Robert Iliuta

  • Sr. Member
  • ****
  • Posts: 472
    • View Profile
    • Email
Re: How to make a form popup
« Reply #6 on: February 28, 2016, 01:11:37 AM »
Hallo Bruce!

Is there a way to inject html in ntAlert message?

p_web.script('ntAlert("<span style="color:red;">Well Done</span>",'Right")


1.Also what is the purpose of the timer here?
p_web.script('ntAlert("Well Done",'Right",1000) ! time in thousandths of a second

2.Also is there any other parameters for ntAlert?

3.How can I change the text button for a message?

4.How can I change the default width:300px ?



Thank you,
Robert
« Last Edit: February 28, 2016, 01:28:52 AM by Robert Iliuta »

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: How to make a form popup
« Reply #7 on: February 28, 2016, 11:21:58 PM »
Hi robert,

>> Is there a way to inject html in ntAlert message?

yes, but you need to get your quotes all right.

>> p_web.script('ntAlert("<span style="color:red;">Well Done</span>",'Right")

try

p_web.script('ntAlert("<span style=''color:red;''>Well Done</span>",'Right")


I replace the double quotes around color:red with 2 single quotes. You can't use double quotes because you are already inside the double quotes of the parameter to ntAlert.

>> 1.Also what is the purpose of the timer here?

It closes the dialog. Well, it would if there wasn't a bug (fixed for 9.07)

>> 2.Also is there any other parameters for ntAlert?

the nice thing about JavaScript is that you can always just check it to see... the function is in netweb.js.

>> 3.How can I change the text button for a message?
>> 4.How can I change the default width:300px ?

you can't. If you need something more powerful than ntAlert then make a small Memory Form procedure and rather do it from there.

cheers
Bruce





Robert Iliuta

  • Sr. Member
  • ****
  • Posts: 472
    • View Profile
    • Email
Re: How to make a form popup
« Reply #8 on: February 29, 2016, 12:58:10 AM »
Hallo Bruce!
Noted and thank you!
Robert