General |  Social Media |  Miscellaneous
Login | Register
srcraft blog logo
  • Business
  • News
  • Shopping
  • Travel
  • Disease
  • Pets
  • Life
  • Health
  • Technology
  • Category
  • Contact Us
Latest Blog : 
☛ Who can be called a true monk ? ☛ God arranges everything ☛ Faith in god ☛ What is a Rotary Encoder? How does it work? ☛ Things to Know About PLC and SCADA ☛ According to Ramayana, why do women wear jewelry? ☛ After registering an FIR, can I not apply for a government job ☛ Daughter: A angel of his father ☛ How VOIP Phone System is Useful For your Business? ☛ test 
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

☛ Who can be called a true monk ?

☛ God arranges everything

☛ Faith in god

☛ What is a Rotary Encoder? How does it work?

☛ Things to Know About PLC and SCADA

☛ According to Ramayana, why do women wear jewelry?

☛ After registering an FIR, can I not apply for a government job

☛ Daughter: A angel of his father

☛ 'Gurukul' literally means 'family of Guru' or 'clan of Guru'

☛ When does mother's honor get less


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

© 2021 SRCRAFT INIDA