# Php+js. using php var in js "for" statement

**URL:** <https://forum.kirupa.com/t/php-js-using-php-var-in-js-for-statement/181560>\
**Category:** Uncategorized\
**Created:** [March 10, 2006, 11:28am UTC](https://forum.kirupa.com/t/php-js-using-php-var-in-js-for-statement/181560 "2006-03-10T11:28:02Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![paul\_ferrie](https://avatars.discourse-cdn.com/v4/letter/p/919ad9/32.png) [@paul\_ferrie](https://forum.kirupa.com/u/paul_ferrie)\
**Post date:** [March 10, 2006, 11:28am UTC](https://forum.kirupa.com/t/php-js-using-php-var-in-js-for-statement/181560/1 "2006-03-10T11:28:02Z")

</div>

Hi guys,  
I have never tried to do this before but i think it can be done.  
What i am trying to do is get the js validater to check that all form feilds have been filled in.  
The fields are generated form a dd menu. the dd menu is cleared once the new fields are created so i can call on it for count status.  
Here is what i have

```auto

function validate2() { 
for (var i=0; i < <? $_POST['numOfUpload']; ?>; i++){
// do checks here
}
}

```

numOfUpload is being passed since this number is used to generate the new feilds.  
I keep getting an error sayiong snytax error at line where for() is.  
Can someone correct me where i am going wrong.  
THanks
