Jump to content


Java & PHP problems


3 replies to this topic

#1 ReZTeR

    Young Padawan

  • Members
  • Pip
  • 9 posts

Posted 10 June 2009 - 08:03 PM

OK.... I am not the best with Java, Javascript or PHP... but I think on this occasion I need to try use them.

Let me explain what my ultimate goal is; I want to have a colour selector on my website and then people will click "This is my colour!" and then I will get the hex code in PHP to do with it what I want (save the info in a database, use it in an email... whatever!). But right now I am stuck, I have a Java colour selector which I have downloaded and implemented on to the page but I am having trouble getting the colour (and hex code) it generates out of it! OK here is my code of the page:

<head>
	<title>ColorPicker</title>
	<script language="JavaScript">
		var color="#808080";
	</script>
</head>

<body>
<form name="submit">
	<table>
		<tr>
			<td align="center" width="400">
				<applet code="colorpicker.class" width="400" height="450" MAYSCRIPT>
				<param name="variable" value="color">
				</applet>
			</td>
		</tr>
		<tr>
			<td align="center"><input type="Button" value="Show value in JavaScript" onClick="alert(color);"></td>
		</tr>
	</table>
</form>
</body>
</html>

As you can see by my example if you click the button it will give you the correct hex code and you can copy and paste it from the text box, but I would just like that button for example to give me a url like....

woopie.php?hex=#000000

But with the selected colour at the end. I have tried doing the with a form but Java and PHP on the same page dont work because PHP doesnt adapt to the changes.

Here is what I tried:

<html>
<head>
	<title>ColorPicker</title>
	<script language="JavaScript">
		var color="#555555";
	</script>
</head>

<body>
<form action="submit.php" method="get" name="submit">
	<table>
		<tr>
			<td align="center" width="400">
				<applet code="colorpicker.class" width="400" height="450" MAYSCRIPT>
				<param name="variable" value="color">
				</applet>
				<input type="hidden" name="type" value="">
			</td>
		</tr>
		<tr>
			<td align="center" colspan="2"><input type="submit" name="Submit" value="Submit"></td>
		</tr>
	</table>
</form>
<script language="JavaScript">
document.submit.type.value = color;
</script>
</body>
</html>

But it jsut keeps coming up like... filename?type=%23555555 as to what I set in the <head>.

So is there a way to make a link with that Button from the first code I already have to create the url I want?

Edited by ReZTeR, 11 June 2009 - 09:05 PM.


#2 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 10 June 2009 - 10:15 PM

Interesting problem you have. I've seen people try to communicate with flash before, but never Java.

As such, the only adivce i can give you comes from the following article which i found on :google:
http://www.coderanch.com/t/121682/HTML-Jav...-box-value-from

Might i also suggested a different approach?
http://www.dynamicdrive.com/dynamicindex11...icker/index.htm

:D

#3 ReZTeR

    Young Padawan

  • Members
  • Pip
  • 9 posts

Posted 11 June 2009 - 05:48 AM

Thanks a lot man... that alternative works great for me.

FYI... I had been searching around for ages... I guess I didn't know exactly what to search for.

#4 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 11 June 2009 - 10:45 PM

Don't worry, over the years i have come to realize that googling is more of an art than a science. It helps to know a fair bit about what you're looking for.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users