Jump to content

Help with syntax needed


n33dl3

Recommended Posts

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 

Link to comment
Share on other sites

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; ?>";

Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • 2 weeks later...

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();" />';

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.