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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:51:50+00:00 2026-06-13T08:51:50+00:00

I have the following snippets that open a single Modal Form: <a class=modalbox id=foo

  • 0

I have the following snippets that open a single Modal Form:

<a class="modalbox" id="foo" href="#inline">Request a Quote</a>
<a class="modalbox" id="bar" href="#inline">Request a Quote</a>
...and so on...

Somehow, I need to render the value of ID in the input “sub” in the following HTML form
as well as concatenate the ID with some predetermined text, which is “I am interested in…”

<form id="contact" name="contact" action="#" method="post">
    <input type="hidden" id="product" name="product" value="">
    <label for="sub">Subject:</label>
    <input type="sub" id="sub" name="sub" class="txt" value="I am interested in '$id'">
    <button id="send">Submit</button>

I’m already using Javascript for verification and AJAX for processing to PHP script.

Edit:
This is the Javascript already being used to populate the hidden input above, which is working perfectly:

$('a').click(function(e) {

 $('#product').val($(this).attr('id'));
  • 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-06-13T08:51:51+00:00Added an answer on June 13, 2026 at 8:51 am

    I’d suggest, with plain JavaScript, something like:

    function addTextToInput(from, to, prefix, e) {
        e = e || window.event;
        if (!from || !to) {
            return false;
        }
        else {
            from = from.nodeType == 1 ? from : document.getElementById(from);
            to = to.nodeType == 1 ? to : document.getElementById(to);
            var text = from.id;
            to.value = prefix ? prefix + ' ' + text : text;
        }
    }
    
    var as = document.querySelectorAll('a.modalbox');
    for (var i = 0, len = as.length; i<len; i++) {
        as[i].onclick = function(e) {
            addTextToInput(this, 'sub', 'I am interested in', e);
        };
    }​
    

    JS Fiddle demo.

    But given that you already seem to be using jQuery:

    $('a.modalbox').click(function(e){
        e.preventDefault();
        $('#sub').val('I am interested in ' + this.id);
    });
    

    JS Fiddle demo.

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

Sidebar

Related Questions

If we have the following 2 snippets of code in c++ that do the
I have following code snippet that i use to compile class at the run
I have the following code that simply uses a jquery ui modal dialog to
I have following code snippet: class ABC{ public: int a; void print(){cout<<hello<<endl;} }; int
I have used the following code to open the current page URL in Rich
Suppose I have the following snippets: int compareFoo(std::string** a, std::string** b) { return (**a).compare(**b);
I know this is a rather broad question, but have a class that has
I have the following code snippet of a small Thread class I am trying
I have the following code that I'm using in a small frame work I've
I have to write a composite component that shows a login form and can

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.