Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7050927
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:12:11+00:00 2026-05-28T03:12:11+00:00

First of all, I’m using the following code to generate a form via JavaScript

  • 0

First of all, I’m using the following code to generate a form via JavaScript and appending it to some container ( of my choice ) :

var registerStructureWrapper = '<div class="content-register"></div>';

var registerStructure = [
        '<form name="',opts.regFormClass,'" class="',opts.regFormClass,'" method="post" action="#">',
            '<fieldset class="',opts.regFieldsWrapper,'">',
                '<fieldset class="',opts.regUserWrapper,'">',
                    '<label for="',opts.regUserInt,'" class="',opts.regUserLbl,'">',checkNameLenght(opts.regUserName,regNamesLenght.userNameLenght,20,'Username'),'</label>',
                    '<input type="text" name="',opts.regUserInt,'" class="',opts.regUserInt,'" placeholder="" value="" autocomplete="off" />',
                '</fieldset>',
                '<fieldset class="',opts.regEmailWrapper,'">',
                    '<label for="',opts.regEmailInt,'" class="',opts.regEmailLbl,'">',checkNameLenght(opts.regEmailName,regNamesLenght.emailNameLenght,20,'Email'),'</label>',
                    '<input type="email" name="',opts.regEmailInt,'" class="',opts.regEmailInt,'" placeholder="" value="" autocomplete="off" />',
                '</fieldset>',
                '<fieldset class="',opts.regPassWrapper,'">',
                    '<label for="',opts.regPassInt,'" class="',opts.regPassLbl,'">',checkNameLenght(opts.regPassName,regNamesLenght.passNameLenght,20,'Password'),'</label>',
                    '<input type="password" name="',opts.regPassInt,'" class="',opts.regPassInt,'" placeholder="" value="" autocomplete="off" />',
                '</fieldset>',
                '<fieldset class="',opts.regConfWrapper,'">',
                    '<label for="',opts.regConfInt,'" class="',opts.regConfLbl,'">',checkNameLenght(opts.regConfName,regNamesLenght.confNameLenght,20,'Confirm Password'),'</label>',
                    '<input type="password" name="',opts.regConfInt,'" class="',opts.regConfInt,'" placeholder="" value="" autocomplete="off" />',
                '</fieldset>',
                '<fieldset class="',opts.regBtnWrapper,'">',
                    '<div class="message-handling"></div>',
                    '<button type="submit" name="',opts.regBtnInt,'" class="',opts.regBtnInt,'">',checkNameLenght(opts.regBtnName,regNamesLenght.btnNameLenght,8,'Register'),'</button>',
                '</fieldset>',
            '</fieldset>',
        '</form>',
        '<div class="',opts.regBackBtn,'">',
            '<ul class="inside">',
                '<li class="back"><a><img src="assets/gfx/back.png" alt="Back" /></a></li>',
            '</ul>',
        '</div>'
    ];


    $(registerStructureWrapper).appendTo(container).hide();
    var registerWrapper = $(container).find('.content-register');
    $(registerStructure.join('')).appendTo(registerWrapper);

And I have the following code to generate a math captcha :

<?php

    public function mathCaptcha()
    {
        $sum1 = mt_rand(1,9);
        $sum2 = mt_rand(1,9);
        $sum3 = $sum1 + $sum2;
        $_SESSION['answer'] = $sum3;
       return $sum1 . ' + ' . $sum2 . ' = ';
    }

?>

My question would be can I somehow include that sum into the js generated form ? Is there a way to do that without having the form in plain html but generating it as I already do ?

Mention: The script is’t on page, it’s a loaded script with <script> tags.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T03:12:12+00:00Added an answer on May 28, 2026 at 3:12 am

    If you want to pass the variable from PHP to JS, you need to generate the JS code by PHP or you need to load the PHP result dynamically by AJAX and include it to your form.

    For AJAX loading, use something like this:

    $('#captcha_placeholder').load('/php_captcha.php');
    

    Where your php_captcha.php file should look similar to yours, but should echo the output.

    You should make some changes, as this is just the raw idea.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First of all (in case this is important) I'm using ActiveState's Perl (v5.8.7 built
First of all - I don't have a problem with bad-indentated code and I
First all, I am still learning CakePHP and I am close to ZERO using
First of all, here's my config: VS2010/Debug/C++ Win32 Project/Vista Home Premium Invoking GetOpenFileName via
First of all, pardon my hacky code, I'm just trying to try this out
First of all, some background: I'm trying to get in a list of integers
First of all, I know how to build a Java application. But I have
First of all, I don't need a textual comparison so Beyond Compare doesn't do
First of all, I'm fairly sure snapping to grid is fairly easy, however I've
First of all: I am not an experienced ClearCase user, but I have lots

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.