Note that there are some explanatory texts on larger screens.

plurals
  1. POHidden Field Manipulation in Perl
    primarykey
    data
    text
    <p>I'm trying to write a multi question survey in perl that displays one question at a time with a "previous" and "next" button. Eventually I will need to read the questions from a file, but I haven't gotten that far yet so I am hard coding them in for now.</p> <p>Part of the assignment requirements are that I MUST use CGI, so I cannot print any html directly.</p> <p>Currently I have the script printing out the first question, along with two submit buttons, one labeled 'next' and the other 'previous'. </p> <p><code>print $form-&gt;submit(-name=&gt;'question', -value=&gt;'next');</code><br> <code>print $form-&gt;submit(-name=&gt;'question', -value=&gt;'previous');</code></p> <p>I also have a hidden field:</p> <p><code>print $form-&gt;hidden(-name=&gt;'hidden', -value=&gt; $currentQ);</code></p> <p>My idea is that once next is clicked, I would increment (or decrement, if previous was clicked) $currentQ so that the script knows which question it was on.</p> <p>The problem I'm having is manipulating the hidden field once the button is pushed. I have:</p> <p><code>my $direction = $form-&gt;param( 'question' ) || '';</code><br> <code>if ($direction eq 'next'){ $currentQ++; }</code></p> <p>Along with a print statement to print $currentQ. In other words, it should print a higher number each time I click next, but all it does is remain at 1(This is just to test the functionality, once this is working I then have to figure out how to actually implement it so that it will print the correct question). </p> <p>Hopefully this description makes some sense, but if you need more details please let me know. I'm really stuck on this one, so any help is greatly appreciated, thanks in advance!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload