mvasco mvasco - 1 year ago 92
HTML Question

Passing URL parameter to input text

I want to set the value from a URL parameter to a HTML form input text, like this:

<div class="input_container">
<div class="field_container">
<?php $clave = $_GET['pu'];?>
<input type="hidden" class="text" name="puntos_libres__id" id="puntos_libres_id" value="<?php echo $clave;?>" >


The form opens in a modal window, but the value for the input is not passed correctly to the action script. It always pass 0 as value.
Any idea why?

Answer Source

Perhaps performing a pre-check for the $_GET Variable could do. The Snippet below demonstrates what is meant with that:

<?php   $clave = isset($_GET['pu']) ?  $_GET['pu'] : ""; /*TRY DUMPING: $clave*/ ?>
<?php   var_dump($clave); // JUST TO SEE ITS CONTENTS B4 IT GETS TO THE INPUT.   ?>

<div class="input_container">
       <div class="field_container">
            <input type  = "hidden" 
                   class = "text" 
                   name  = "puntos_libres__id" 
                   id    = "puntos_libres_id" 
                   value = "<?php echo $clave;?>" 
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download