1

I have a web app. I am accessing the web app using the link ...:8080/EPQ/. Web app has only one HTML file. I have the following code in HTML.

<input type="hidden" name="id" id ="id" >

I want to pass value for this id through the URL ...:8080/EPQ/. Let me know how to do that.

lukeocom
  • 3,243
  • 3
  • 18
  • 30
Ramesh
  • 392
  • 1
  • 12
  • 39

1 Answers1

1

If you change your file to have a .php extension instead of .html, then you can use a script to check if a value has been added to the url. Your server must have php installed for this to work of course.

An example would look something like this in your php file.

<?php
    //check if var is in URL and store it in $yourVar otherwise store the string 'blank text'
    if ($_GET) {
        $yourVar = $_GET['hidden-val'];
    } else {$yourVar = 'blank text';
    }   
?>

your url would look something like this

http://www.yourdomain.com/yourfile.php?hidden-val=somevalue

or if the file is index.php you can use

http://www.yourdomain.com/?hidden-val=somevalue

An alternative solution is to use a javascript/jquery approach, which would look something like..

$(document).ready(function() {
    var yourVar = window.location.search.substring(1);
    alert('you passed in ' + yourVar);
}

this thread may be of help also.. How to get the value from the GET parameters?

Community
  • 1
  • 1
lukeocom
  • 3,243
  • 3
  • 18
  • 30