Jump to content

[SOLVED] php access javascript value?


simon551

Recommended Posts

can php access a value stored on the page? I'm trying to modify a spry (adobe ajax library) select box to read a php cookie... I'm a little lost.

 

This is very basic:

 <option value="1" <?php if (!(strcmp(1, $_SESSION['itemSetting']))) {echo "selected=\"selected\"";} ?>>Regular </option>

 

this is an option value as written using spry:

 <option value="{itemId}" <?php if (!(strcmp("{itemId}", $_SESSION['itemSetting']))) {echo "selected=\"selected\"";} ?>>{item}</option>

 

I'd like to modify it to be like this:

 <option value="1" <?php if (!(strcmp(1, $_SESSION['itemSetting']))) {echo "selected=\"selected\"";} ?>>Regular - Client billable</option>

 

do you know of a way to do this?

 

Link to comment
https://forums.phpfreaks.com/topic/115110-solved-php-access-javascript-value/
Share on other sites

oh. I totally botched that.

 

this is an option value as written using spry:

 

<option value="{itemId}" >{item}</option>

I'd like to modify it to be like this:

<option value="{itemId" <?php if (!(strcmp("{itemId}", $_SESSION['itemSetting']))) {echo "selected=\"selected\"";} ?>>Regular - Client billable</option>

 

obviously php just reads {itemId} as text and there would not be any match. But can I somehow pass that info from the javascript?

This is how I do it

 

JavaScript Code

document.write('<a href="/"><img src="shrink.php?varname=varinfo&var2name=var2info" /></a>');

 

PHP Code

<?php
$phpvarname = $_GET["varname"]; // The image pathway returned from JavaScript. (ie. images/)
$phpvar2name = $_GET["var2name"]; // The users screen width returned from JavaScript? (ie 800)
?>

 

Wayne

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.