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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:40:58+00:00 2026-05-22T22:40:58+00:00

I just started using jQuery in the past few days. I love how it

  • 0

I just started using jQuery in the past few days. I love how it makes functions simple. However because I am very new to using Javascript, I keep hitting a road block with one function.

I am trying to bind a couple functions together, but I’m not sure if I am doing it in the right order. What I want it to do is get a variable from a selector href='#from=xxxxx&to=xxxxx', with the xxxxx being a value printed out from a DB using PHP.

Then create a DOM window to display a form and insert those values into the hidden input fields. I have been stuck trying to figure out a way to pass those variables from the link to the form.

Here is my script:

<html>
<head>
  <script src="http://code.jquery.com/jquery-latest.js"></script>
<script src="http://swip.codylindley.com/jquery.DOMWindow.js"></script>
</head>
<body>
<div id="msgBox" style="display:none"></div>
<?php   $from="0";  $to="0";
for ($x=1; $x<=4; $x++){ $from++; $to++;    ?>
<a href="#from=<?php echo $from;?>&to=<?php echo $to;?>" class="foo">user<?php echo $x;?></a><br>
<?php } ?>
<script type="text/javascript">
       $("#msgBox").append("<form id='myForm' method='post' action='index.php'><div style='border:1px solid #cc0; width:300px;'><input type='hidden' value='<?php echo $from;?>'><input type='hidden' value='<?php echo $to;?>'>subject:<input type='text' name='subject'><br>message:<textarea class='mbox' name='msg'></textarea><br><input type='submit' value='submit'></div></form>");
        $('.foo').click(function(){
            $.openDOMWindow({
                windowSourceID:'#msgBox',
                height:135,
                width:300,
                overlay:0,
                positionType:'anchoredSingleWindow',
                windowBGColor:'#f9f5f5',
                anchoredSelector:'.foo',
                positionLeft:200,
                positionTop:150
            });
                  $("#msgBox").trigger();
            return false;
     });
</script></body></html>
  • 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-22T22:40:59+00:00Added an answer on May 22, 2026 at 10:40 pm

    In the handler for the click event on each link you can get a reference to the target link and extract the values from the href attribute and then set the values of the hidden fields in the form.

    $('.foo').click(function() {
    
    var href = $(this).attr('href'); // will contain the string "#from=0&to=0"
    
    var from,to = ... // extarct from string by splitting by & or using url parse library
    
    $('#msgBox').find("input[name='from']").val(from);
    $('#msgBox').find("input[name='to']").val(to);
    
    // rest of code...
    
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Could someone help me understand whats going on here, Ive just started using Jquery
I just started using Colorbox modal plugin and cannot figure out how to get
I have been using jquery ui with no problem but just recently the jquery
I have a new web app that is packaged as a WAR as part
I am using a 3rd-party rotator object, which is providing a smooth, random rotation
Actually this is a more specific version of a question I posted in past
I'm using server side processing as per the Django example in DataTables . I
We recently moved to jQuery 1.6 and ran into the attr() versus prop() back-compat
(please excuse that I didn't use aliases). I would like my query output to
I'm working on a project in C# w/ XNA, and I want to reorganize

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.