n33dl3 Posted April 19, 2007 Share Posted April 19, 2007 Hi there I am having problems with the following: opener.document.getElementById(\'version\').value="$version"; The value should be a php variable, I have tried \'"$version\"' and so on but that don't work maybe you know what is the right syntax. Thanx Regards RobH Quote Link to comment Share on other sites More sharing options...
tomfmason Posted April 19, 2007 Share Posted April 19, 2007 You will first need to make sure that the page is being processed as php, i.e. it has the .php extension. If so try this: opener.document.getElementById('version').value="<?php echo $version; ?>"; also if you have short tags enabled you could also do it this way. opener.document.getElementById('version').value="<?=$version; ?>"; Quote Link to comment Share on other sites More sharing options...
n33dl3 Posted April 20, 2007 Author Share Posted April 20, 2007 Hi thanx for replaying, With regards to your answer, I am already in PHP my intention is to put the whole statement into one variable like this: $button_save = '<input class="button" type="submit" name="save_new_case_version" value="save" onClick="opener.document.getElementById(\'aer_version\').value=\'$version\';self.close();" />'; The $version variable is set. This is not working because I have an error with the value statement (marked red) somehow I have set the ' ' or the " " wrong maybe you have an idear how it should be done right. Thanx Regards RobH Quote Link to comment Share on other sites More sharing options...
mainewoods Posted May 2, 2007 Share Posted May 2, 2007 when strings in php are surrounded by single quotes, the php variables within them will not be translated to their value: '<input class="button" type="submit" name="save_new_case_version" value="save" onClick="opener.document.getElementById(\'aer_version\').value=\'$version\';self.close();" />'; break the $version out using concatenation: '<input class="button" type="submit" name="save_new_case_version" value="save" onClick="opener.document.getElementById(\'aer_version\').value=\'' . $version . '\';self.close();" />'; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.