General |  Social Media |  Miscellaneous
Login | Register
srcraft blog logo
  • Business
  • News
  • Shopping
  • Travel
  • Disease
  • Pets
  • Life
  • Health
  • Technology
  • Category
  • Contact Us
Latest Blog : 
☛ True Story of Beggar: Punishment for the deeds done by us ☛ India: The Story of a Joint Family ☛ AI Driven Analytics | Life Sciences Data Analytics | WhizAI ☛ The Story of Gurukul: Test of intelligence ☛ The Problem Solving Skills ☛ Eternal law that never changes ☛ After all, why does Mahadev apply ashes on the body? ☛ Kitchen Worktops Buy now | Grey Worktops on sale ☛ Black Kitchen Worktops on Sale in UK ☛ White Kitchen Laminated Worktops Buy in UK 
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

☛ True Story of Beggar: Punishment for the deeds done by us

☛ India: The Story of a Joint Family

☛ AI Driven Analytics | Life Sciences Data Analytics | WhizAI

☛ The Story of Gurukul: Test of intelligence

☛ The Problem Solving Skills

☛ Eternal law that never changes

☛ After all, why does Mahadev apply ashes on the body?

☛ How to get an e-pass for curfew in Delhi, know the complete process in 6 easy steps

☛ 10 TIPS TO QUICKLY CLEAN YOUR JEWELLERY

☛ Quartz Worktops: Better Choice for Many People


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

© 2022 SRCRAFT INIDA