Jump to content

generate a hidden form values from database pull


egiblock

Recommended Posts

i'm pulling hole scores from a database.  variable names are h1,h2,h3.....etc....

 

so my database pull code for display is:

 

<?php echo $row_CourseDetail['h1']; ?>

 

but i also want to generate hidden form values for this at the same time.

 

so i was trying this:

 

<script type="text/javascript">
<!-- Calculate the Scores for Hole Calculations
var i=1;
var j=18;
var ParScore = new Array(); 

while (i<=j)
{
document.write('<input type="hidden" value="<?php echo $row_CourseDetail['h1']; ?>">');
  i++;
}
</script>

 

ovbiosusly i want the "h1" variable name in there to be different depending on the loop it's going through.

 

so it should be h + variable 'i'

 

but i can't get the code to process right.

 

any ideas ?

 

 

 

 

The '+' sign is used for concatenating javascript, but the problem here is that he wants to output a php value based on a javascript loop - this can't be done. Gevans had the most viable suggestion - doing the loop in PHP. It could be done with AJAX as well.

Why aren't you just using php to do this?

 

<?php

$i=1;
$j=18;
$ParScore = array();

while ($i<=$j)
{
echo('<input type="hidden" value="'.$row_CourseDetail['h'.$i].'">');
  $i++;
}

 

honestly i just started working with php about 2 weeks ago..  i have no clue what i am doing..  but i got it now.

 

thanks !

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.