Help - Search - Members - Calendar
Full Version: Java & PHP problems
Pixel2Life Forum > Help Section > PHP, ASP, MySQL, JavaScript and other Web/Database Programming Help
ReZTeR
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:

CODE
<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:

CODE
<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?
rc69
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.gif
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

yodasearch.gif
ReZTeR
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.
rc69
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.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.