General |  Social Media |  Miscellaneous
srcraft blog logo
  • Business
  • News
  • Shopping
  • Travel
  • Disease
  • Pets
  • Life
  • Health
  • Technology
  • Category
  • Contact Us
Latest Blog : 
☛ Best Europe cities to travel with Toddlers ☛ Make Your Limousine Ride Even More Special: 10 Top Ideas ☛ Leverage SEO Services to Secure Success for Your Storage Company ☛ Telerehab physical therapy : healing at your fingertips ☛ 10 Best Activities in India for Thrills and Relaxation ☛ Wedding Limos That Redefine Luxury Transportation ☛ Flying with Family: A Guide to Kid-Friendly Travel from Calgary to Kelowna ☛ How To Protect Your Privacy Online? [Complete Guide] ☛ Help and kindness is the biggest religion ☛ Burning bamboo wood is prohibited in the scriptures, Why 
Home > Innovation & Technology > Javascript

How to pass href variable to JavaScript


If you are trying to pass anchor tag value in html to JavaScript, it is very easy. Here we are explaining, How to pass anchor tag value in JavaScript function or How to pass multiple parameters to javascript function. You can do that. It is possible in Javascript function.

First of all, we will pass a value by onclick function with user defined function in anchor tag <a>

See below example:

<a href='#' onclick='send(2205)'>Click Here</a>

After that we will use user define send() function in Javascript for sending value to javascript function also we will send anchor tag value in page url by redirection in Javascript for getting this value in PHP.

See below example:

<script>

  function send(value) {

    var orderID = parseInt(value);

    var status = “complete”;                          

    window.location = "?status=" + status + "&orderID=" + orderID;

  }

</script>

Now, we will use $_GET PHP superglobal variables for retrieving url variable.

See below example:

<?php

                                if (isset($_GET['orderID'])) {

                                                $anchorValue = $_GET['orderID'];

                                                echo 'This is anchor tag value '.$anchorValue;

                                }

                                else

                                {

                                                $anchorValue = "<br />no anchor value found!";

                                                echo $anchorValue;

                                }

                ?>

Written By: Charles Miller Published in Javascript


Search

Publish your passions on srcraftblog.com

Latest Post

☛ Best Europe cities to travel with Toddlers

☛ Make Your Limousine Ride Even More Special: 10 Top Ideas

☛ Leverage SEO Services to Secure Success for Your Storage Company

☛ Telerehab physical therapy : healing at your fingertips

☛ 10 Best Activities in India for Thrills and Relaxation

☛ Wedding Limos That Redefine Luxury Transportation

☛ Flying with Family: A Guide to Kid-Friendly Travel from Calgary to Kelowna

☛ How To Protect Your Privacy Online? [Complete Guide]

☛ Help and kindness is the biggest religion

☛ Burning bamboo wood is prohibited in the scriptures, Why


We are accepting well-written informative Guest Posts on srcraftblog.com

Innovation & Technology

Artificial Intelligent blogs
Cryptocurrency blogs
Digital India blogs
Data science blogs
Neuroscience blogs
Programming blogs

Physical science

Physics blogs
Chemistry blogs
Earth science blogs
Geology blogs
Oceanography blogs
Meteorology blogs

Industry

Business blogs
Economy blogs
Freelancing blogs
Leadership blogs
Productivity blogs
Work blogs

Society

Basic income blogs
Education blogs
Environment blogs
Media blogs
Philosophy blogs
Women blogs
About us |  Write for us |  Terms and conditions |  Contact us

© 2023 SRCRAFT INIDA