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 7024273
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:49:08+00:00 2026-05-27T23:49:08+00:00

I am passing some values out of a form into a function so it

  • 0

I am passing some values out of a form into a function so it is ready for database insertion.
The function theoretically works fine. However, it misses a unique value that puts me in trouble afterward.
I’m trying to generate a unique ID based on the data that is submitted to the database.
I want to generate the ID like this:

var mystringId = prodID+'{‘+selectId+’}’+selectedOptionValue;

Should output for example: 20{100}3{200}6.
In my sample it generates above the following:

20{100}3

20{200}6

because of the each();

$("#submitme").live('click', function() {
//var mystringId = prodID;
    $('select').each(function() {
        var addedOn = new Date();
        var selectName= $(this).attr("name");        
        var selectId= $(this).attr("id");
        var selectedOption = $(this).find('option:selected');
        var selectedOptionValue = selectedOption.val();
        var selectedOptionText = selectedOption.text();

        var mystringId = prodID+'{'+selectId+'}'+selectedOptionValue;

        db.transaction(function(tx) {
        tx.executeSql('INSERT INTO xxxxx mystringId');

        });

    });
    $.mobile.changePage( "#cart", { transition: "slideup"} );
    });
  • 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-27T23:49:09+00:00Added an answer on May 27, 2026 at 11:49 pm

    From what I can gather from your question, you can simply do a each loop before your current code to generate the mystringId in the format your looking for to use inside your code.

    Code

    $("#submitme").live('click', function() {
        var mystringId = prodID;
    
        $('select').each(function() {
            var selectId= $(this).attr("id");
            var selectedOption = $(this).find('option:selected');
            var selectedOptionValue = selectedOption.val();
    
            mystringId += '{' + selectId + '}' + selectedOptionValue;
        });
    
        $('select').each(function() {
            var addedOn = new Date();
            var selectName= $(this).attr("name");
            var selectId= $(this).attr("id");
            var selectedOption = $(this).find('option:selected');
            var selectedOptionValue = selectedOption.val();
            var selectedOptionText = selectedOption.text();
    
            db.transaction(function(tx) {
                tx.executeSql('INSERT INTO xxxxx mystringId');
            });
        });
    
        $.mobile.changePage( "#cart", { transition: "slideup"} );
    });
    

    Results

    The results would be mystringId starting off with the value of prodID mystringId = 20

    The first iteration of the loop would append {100}3 resulting in mystringId = 20{100}3

    The second iteration of the loop would append {200}6 resulting in mystringId = 20{100}3{100}6

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

Sidebar

Related Questions

I'm passing some parameters to a CR report programatically and it was working fine,
For some unknown reason I'm running into a problem when passing a variable to
I need to filter out some values before they are bound from POST data
I am trying to read out some values from response headers from a Shoutcast
I'm passing some numeric arguments while creating a process (in VC++) I'm stuck at
I'm currently passing some date-time info to a web page using url parameters, which
I want to call a url with passing some parameter and i want to
I'm currently trying to run a certain procedure (sql 2005) in VB6, passing some
I'm not even sure how I should phrase this question. I'm passing some CustomStruct
Is there a way to start an instance of eclipse, passing it some sort

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.