Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is there a way so I can do this:

Status
Not open for further replies.

DeSn

Programmer
Joined
Nov 20, 2001
Messages
111
Location
BE
Is there a way so I can do this:

function doAction()
{
var theType=document.Criteria.selectType;
var theType=theType.options[theType.selectedIndex].value;
var theYear =document.Criteria.selectYear;
var theYear = theYear.options[theYear.selectedIndex].value;
var thePeriod =document.Criteria.selectPeriod;
var thePeriod = thePeriod.options[thePeriod.selectedIndex].value;
var theCntry =document.Criteria.selectCntry;
var theCntry = theCntry.options[theCntry.selectedIndex].value;

return &quot;dvectrpg.php?product=<?php echo $dta_class; ?>&type=&quot; + theType + &quot;&year=&quot; + theYear + &quot;&period=&quot; + thePeriod + &quot;&cntry=&quot; + theCntry ;

}

<form name=&quot;Criteria&quot; method=&quot;post&quot; action=&quot;javascript:doAction();&quot;>

In stead of my original code know:

<form name=&quot;Criteria&quot; method=&quot;post&quot; action=&quot;dvectrpg.php?product=<?php echo $_GET['product'] ?>&type=<?php echo $_GET['type'] ?>&year=&quot; + <?php echo $_GET['year'] ?> + &quot;&period=<?php echo $_GET['period'] ?>&cntry==<?php echo $_GET[cntry] ?>&quot;>

that need this javascript-code first (so the page has to refresk (pink) first):

document.location = &quot;dvectzpg.php?product=<?php echo $dta_class; ?>&type=&quot; + theType + &quot;&year=&quot; + theYear + &quot;&period=&quot; + thePeriod + &quot;&cntry=&quot; + theCntry ;
 
You are mixing up to things here. You need to be aware that:
1. PHP is a server side language that is interpreted before the document is delivered to the client (browser).
2. JavaScript is a client side language and is only available after the document has been delivered.

So, there is no immediate interaction between PHP and JavaScript. You can use PHP to generate JavaScript or you can amnipulate data in JavaScript in the client and send it (POST/GET) to a PHP script.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top