0

I thought a html input field could be populated with an url by using ?fieldname=value behind the base url But I am stuck with this all morning now.

this is the part of my html

                <tr class="pure-table-odd">
                <td><label for="name">Naam</label></td>
                <td><input type="text" name="name" value="" required  id="name" title=""></td>
            </tr>

When i make a link with the following url the field still stays empty. Any suggestion?

http://83.163.140.140//web2016/spa_wellness_arrangementen/vriendinnendag_wellness_arrangement.html?name=test

ps Actually I need to check a checkbox. But I thought to try something more 'easy' first

3
  • How are you populating the input field? Or you think that just by using the "name" parameter in url it should automatically populate your input beacuse it's name and id is "name"? Commented Nov 24, 2016 at 10:41
  • you are right. I saw this solution in other webpages. I got the answer now, i will look for JS to solve it. Thank you for your response Commented Nov 24, 2016 at 10:46
  • check this: w3lessons.info/2013/02/25/… Commented Nov 24, 2016 at 10:47

1 Answer 1

1

You can't use URL-parameters like that. You will need to either process the request server-side (via PHP or similar), or via javascript. However, processing things like this opens up a lot of other potential security holes, so you should know what you're doing.

In PHP, this would be something like:

<?php
echo '<tr class="pure-table-odd">
        <td><label for="name">Naam</label></td>
        <td>';
if ($_GET['parameter']) { //checks if "parameter" exists in the URL string
  $var = $_GET['parameter'];
  echo '<input type="text" name="name" value="'.$var.'" required  id="name" title="">';
}
echo '</td></tr>';

?>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.