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

  • Home
  • SEARCH
  • 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 6994375
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:53:04+00:00 2026-05-27T19:53:04+00:00

I have this JQuery: $(document).ready(function() { $(#generate).click(function() { var texts = []; alert(); $(form

  • 0

I have this JQuery:

$(document).ready(function() {
    $("#generate").click(function() {
        var texts = [];
        alert();
        $("form label").each(function() {
            var oLabel = $(this);
            var oInput = oLabel.next();
            texts.push(oLabel.text() + " " + oInput.val());
        });
        texts[0] += texts[1];
        texts[2] += texts[3];
        for(i=3;i<texts.length;i++)
            texts[i-1] = texts[i];
        texts[texts.length-1] = null;
        $("#cont").html(texts.join("<br />"));
    });
});

What it do is it reads form elements then types them as regular text (there is a purpose for this).

And this is how my form looks like …

<div id="cont" style="float:right; width:75%; height:auto">
    <form onSubmit="return generate();">
      <label class="itemLabel" for="name">Name : </label>
        <input name="name" type="text" class="itemInput" value="<? echo $queryB[1]; ?>" readonly="readonly" />

        <label>@ Some Text</label><br />
        <label for="priPhone" class="itemLabel">Customer Telephone Number : </label>Phone#
        <input name="priPhone" type="text" class="itemInput" readonly="readonly" value="<? echo $queryB[2]; ?>" />

        <label for="secPhone"> // Mobile#</label>
        <input name="secPhone" type="text" class="itemInput" readonly="readonly" value="<? echo $queryB[3]; ?>" /><br />
        <label class="itemLabel" for="email">Customer Email Address : </label>
        <input name="email" type="text" class="itemInput" readonly="readonly" value="<? echo $queryB[4]; ?>" /><br />

        <label>***************</label><br />
        <label>Best Regards,</label><br />
        <input name="another_field" type="text" /><br />
        <label>last thing</label><br />
        <button type="button" id="generate">Generate</button>
    </form>
</div>

now, when I click the button “Generate”, everything goes well except that it ignores “another_field” and doesn’t get its value

Anyone got an idea to solve this? (Note: This piece of code will be running on around 25 forms so I need to have it working.)

UPDATE:

Sample output:

Name : username @ Some Text
Customer Telephone Number :  90237590 // 3298579
Customer Email Address : email@host.com
***************
Best Regards,
last_field
last thing 

Workaround

Since I’m having all the forms have the same ending, I’ve been able to get to this code:

texts[0] += " " + texts[1];
texts[1] = texts[2] + " " + texts[3];
for(i=4;i<texts.length;i++)
    texts[i-2] = texts[i];
texts[texts.length-2] = texts[texts.length-3];
texts[texts.length-3] = $("#agent").val() ;
texts[texts.length-1] = null;

It solved the problem, but I’m looking for a better way to accomplish this.

  • 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-27T19:53:05+00:00Added an answer on May 27, 2026 at 7:53 pm

    Try this javascript:

    $(document).ready(function() {
        $("#generate").click(function() {
            var texts = [];
            $("form").children().each(function() {
                var el = $(this);
                if (el.prop('tagName') == "LABEL") texts.push(el.text());
                if (el.prop('tagName') == "INPUT") texts.push(el.val());
                if (el.prop('tagName') == "BR") texts.push("<br />");
            });
            $("#cont").html(texts.join(""));
        });
    });
    

    Working example here:

    http://jsfiddle.net/Q5AD4/6/

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

Sidebar

Related Questions

I have this code in jQuery.. $(document).ready(function(){ var fieldCounter = 0; ... I have
Really quick jQuery question... I have this function: $(document).ready(function() { $('a#show1').click(function() { $('.item1').toggle(1000); return
I have this jQuery: $(document).ready(function() { $(#panel).hide(); $('.login').toggle( function() { $('#panel').animate({ height: 150, padding:20px
Never ran into this problem with jQuery before. I have the following: $(document).ready(function() {
I have the following jQuery which I need adapting: $(document).ready(function(){ $(.rss-popup a).hover(function() { $(this).next(em).stop(true,
I have this jQuery which works fine $(li[id^='shop_id']).click( function () { alert(I clicked on
I have this code: var $msg = jQuery('<div></div>') .hide() .appendTo(document.body) ; if ($msg.is(:hidden)) {
i have the following jquery code: $(document).ready(function() { $('.restrictiveOptions input[type!=checkbox], .restrictiveOptions select').change(function() { //
I have some jquery code that uses the live method of triggering events: $(document).ready(function()
Do we have a document for jQUery 1.4.2..something that says this was there in

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.