Tech Musings

Tuesday, September 26, 2006

Javascript and PHP

In the past I've created buttons as navigational links rather than using hyperlinks to professionalize the look and feel of my Web application's GUI. However, I ran into a few syntax snags trying to pass PHP variables using these navigational buttons, so I always opted for the easier route (using hyperlinks) because I needed to get the job done quickly and I didn't feel like investing additional time into the R&D it would take for me to learn how to do it. Today, I finally devoted the 15-20 minutes of extra time to learn how to create a Javascript navigational button that passes a PHP initiated variable while working on the VISIONS requirements database project here at ETR.

I messed around with the concat() feature in Javascript but finally settled on manipulating my Javascript string using an approach shown in this post and then applying this modification to the button code below:

! -- Original: Sven David Hildebrandt ( --->
! -- Web Site: --->
! -- Begin

function goToURL() {
var url = null;
url = "reflection_insert.php?uid=";
url += "<~? echo $row_Person['uid']; ?~>";
window.location = url; }

// End --


input type="button" onClick="goToURL()" value="Add Reflection"


Post a Comment

Links to this post:

Create a Link

<< Home