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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T01:22:49+00:00 2026-06-07T01:22:49+00:00

I have a form with number of input type images. I need to replace

  • 0

I have a form with number of input type images. I need to replace the webpage location to url of the image when a user clicks any image.

form is like,

<form action='free.php' id='freeForm' method='post' autocomplete="off">
<?
for($j=1;$j<=5;$j++)
{
?>
<a href="<?=$url;?>" class="anchor-url"> <input type="image" src="<?=$img;?>" /></a>
 <?
 }
 ?>
 </form>

$img and $url values from database.

My jquery is like,

$("#freeForm").submit(function()
    {
            var Form = { };
            Form['inputFree'] = $("#inputFree").val();

                    Form['freeTOS'] = '1';



              $('.anchor-url').click(function(e){
             e.preventDefault();
              alert($(this).attr('href'));
           });


            $.post('processFree.php', Form, function(data)
            {
                    if(data == "Success")
                    {
                            $("#FreeErrors").html('').hide();
                            swapToPane('paneSuccess');
                            return;
                    }

                    swapToPane('paneFree');
                    $("#FreeErrors").html(data).show();
            });

            return false;
    });

Now I am getting ‘http://au.yahoo.com&#8217; when i click each image. But I want to replace ‘http://au.yahoo.com&#8217; with URL of each image. How can I pass the PHP variable $url to this form?
Any idea?

Thanks!

  • 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-07T01:22:52+00:00Added an answer on June 7, 2026 at 1:22 am

    This should work, if I understood what you were asking for correctly and though I haven’t tried it. Basically you bind the click event to each image, and on click it replaces the window location with the value in the src attribute of the input element being clicked on.

    $('input[type=image]').click(function(e){
      e.preventDefault();
      window.location.replace($(this).attr('src'));
    });
    

    EDIT

    First you should add a class name to your anchor elements:

    <form action='free.php' id='freeForm' method='post' autocomplete="off">
    <?
    for($j=1;$j<=5;$j++)
    {
    ?>
    <a href="<?=$url;?>" class="anchor-url"> <input type="image" src="<?=$img;?>" /></a>
     <?
     }
     ?>
    </form>
    

    Your JS:

    $('.anchor-url').click(function(e){
      e.preventDefault();
      window.location.replace($(this).attr('href'));
    });
    

    Notice how I added a class to the anchor links. This can be named almost anything. This gives you the ability to select for those elements with that classname only with jQuery using the $(‘.any-classname’) selector.

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

Sidebar

Related Questions

I have a form with number of submit type as images. Each image has
I have a number of forms like this: <form class=some-name> <input type=hidden name=bill valueflower
I have a form with phone number field, i need to validate it with
I have a form field that uses some Javascript to format user input 'price'
I have a form that allows a user to add an unlimited number of
I have the following markup: <input type=number max=99 /> In Google Chrome (and possibly
Greetings, I have a form with a variable number of inputs, a simplified version
I have a form with a number of radiobuttons where only one should be
I have a vaadin form with huge number of fields in it(textbox, select box
I have a form that takes in a number of fields about a camera's

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.