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 ?

 

 

 

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 !

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.