i have the following:
i convert varchar from the db to urlencode to avoid my javascript being broken by new lines apostraphes etc.
$safecode = urlencode($row['name']);
echo '<a href="#" onClick="doThis(\"$safecode\"")>Some link</a>';
then in my javascript i have:
<script language="javascript">
function doThis(post1) {
opener.form_name.post1.value = post1
}
</script>
so in the above example i need to use urldecode to convert it back to it's normal state but having trouble mixing the javascript and php
because i cannot say opener.form_name.form_field.value = <? urldecode(javascript_var); ?>
this is an obvious php error since there is no dollar sign in front of the var, nor is there a variable called $javascript_var?
Or is there another method rather than using this in the popup window deal with it in the opener window, have tried this too but without success. In my opener i have:
<input type="text" name="post1" value="<? if (isset($POST['post1'])) {
echo urldecode($POST['post1']);
}">
The problem with this is the value from the js is not a POST var and would anyway overwrite any value inside the field? So it would be safer to be able to do this from the popup window (yes i know im contradicting myself)? but how....