HTML Help Forum HTML Help
Please Search for the answer to your question before asking it! Thanks.
 

javascript error (unusual javascript error)
Post a Reply to this Topic Ask a New Question
Click here to go to the original topic
       HTML Help Forum -> Javascript
View previous topic :: View next topic  
Author Message
itunes66



Joined: 09 Mar 2005
Posts: 184

Posted: Fri Jun 17, 2005 4:52 pm     javascript error (unusual javascript error)  

javascript error (unusual javascript error)
--------------------------------------------------

i have an error and i dont knoe why the script is doing this

first here is the page chmod.php (it is in php)
(its the first form)
Code:
<?php
require("protect.php");
require("library/functions.php");
?>
<?php
echo "
<form name=\"chmod\" action=\"{$_SERVER['PHP_SELF']}\" method=\"post\">
chmod file:<input type=\"text\" name=\"file\">
<br>
permissions:
<select name=\"chmod1\" onchange=\"calcperm()\">
<option value=\"00\">0</option>
<option value=\"01\">1</option>
<option value=\"02\">2</option>
<option value=\"03\">3</option>
<option value=\"04\">4</option>
<option value=\"05\">5</option>
<option value=\"06\">6</option>
<option value=\"07\">7</option>
</select>
<select name=\"chmod2\" onchange=\"calcperm()\">
<option value=\"0\">0</option>
<option value=\"1\">1</option>
<option value=\"2\">2</option>
<option value=\"3\">3</option>
<option value=\"4\">4</option>
<option value=\"5\">5</option>
<option value=\"6\">6</option>
<option value=\"7\">7</option>
</select>
<select name=\"chmod3\" onchange=\"calcperm()\">
<option value=\"0\">0</option>
<option value=\"1\">1</option>
<option value=\"2\">2</option>
<option value=\"3\">3</option>
<option value=\"4\">4</option>
<option value=\"5\">5</option>
<option value=\"6\">6</option>
<option value=\"7\">7</option>
</select>
<br>
<input type=\"text\" name=\"permdisplay\" readonly=\"true\">
<br>
default permissions:
folders: 755
files: 644
<br>
<input type=\"submit\">
</form>
";

if (isset($_POST['chmod1']) && isset($_POST['chmod2']) && isset($_POST['chmod3']) && isset($_POST['file'])) {

$p = $_POST['chmod1'] . $_POST['chmod2'] . $_POST['chmod3'];
$f = $_POST['file'];

chmod($f, $p);
}
?>


here is library/functions.php
Code:
<?php
echo"
<script>

function calcperm() {

ch1_option=chmod.chmod1.options[chmod.chmod1.selectedIndex].value
ch2_option=chmod.chmod2.options[chmod.chmod1.selectedIndex].value
ch3_option=chmod.chmod3.options[chmod.chmod1.selectedIndex].value

if (ch1_option = \"00\") {
if (ch2_option = \"0\") {
if (ch3_option = \"0\") {
document.chmod.permdisplay.value = \"000\";
}}}

if (ch1_option = \"00\") {
if (ch2_option = \"1\") {
if (ch3_option = \"0\") {
document.chmod.permdisplay.value = \"010\";
}}}

if (ch1_option = \"00\") {
if (ch2_option = \"0\") {
if (ch3_option = \"1\") {
document.chmod.permdisplay.value = \"001\";
}}}

if (ch1_option = \"01\") {
if (ch2_option = \"0\") {
if (ch3_option = \"0\") {
document.chmod.permdisplay.value = \"100\";
}}}

if (ch1_option = \"01\") {
if (ch2_option = \"1\") {
if (ch3_option = \"0\") {
document.chmod.permdisplay.value = \"110\";
}}}

if (ch1_option = \"01\") {
if (ch2_option = \"1\") {
if (ch3_option = \"1\") {
document.chmod.permdisplay.value = \"111\";
}}}
}
</script>
";
?>


i have not finished the script but once you tell me the problem i can fix all parts and add the rest there
degsy



Joined: 23 Feb 2005
Posts: 2440
Location: North East, UK

Posted: Fri Jun 17, 2005 5:57 pm      

you didn't post the javascript error you are getting :roll:
itunes66



Joined: 09 Mar 2005
Posts: 184

Posted: Fri Jun 17, 2005 6:14 pm      

oh yaeh on chmod.php it alwasy when you change the options it always makes the premissions display 111
degsy



Joined: 23 Feb 2005
Posts: 2440
Location: North East, UK

Posted: Sat Jun 18, 2005 6:07 am      

You have many errors. you probably should start simpler and build it up.

The nested if statements do nothing and you are assigning values using = rather than checking them using ==

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<script>
function l2k(){
fname = document.form1.fname.options[document.form1.fname.selectedIndex].value;
lname = document.form1.lname.options[document.form1.lname.selectedIndex].value;
code = document.form1.code.options[document.form1.code.selectedIndex].value;

if((fname == "james") && (lname == "bond") && (code == "007")){
alert("License to Kill!");
}

}
</script>
</head>

<body>
<form name="form1" id="form1" method="post" action="">
  <select name="fname" id="fname" onchange="l2k()">
    <option value="john">john</option>
    <option value="james">james</option>
    <option value="joe">joe</option>
  </select>
  <select name="lname" id="lname" onchange="l2k()">
    <option value="bloggs">bloggs</option>
    <option value="bond">bond</option>
    <option value="burton">burton</option>
  </select>
  <select name="code" id="code" onchange="l2k()">
    <option value="001">001</option>
    <option value="007">007</option>
    <option value="009">009</option>
  </select>
</form>
</body>
</html>
itunes66



Joined: 09 Mar 2005
Posts: 184

Posted: Sat Jun 18, 2005 10:40 am      

thanks illf ix the script right a way
degsy



Joined: 23 Feb 2005
Posts: 2440
Location: North East, UK

Posted: Sun Jun 19, 2005 6:29 am      

I was messing around and came up with this

http://www.degs.co.uk/test/hct/loop_through_checkbox_addup_chmod.htm
itunes66



Joined: 09 Mar 2005
Posts: 184

Posted: Sun Jun 19, 2005 10:10 am      

i use a linux host
itunes66



Joined: 09 Mar 2005
Posts: 184

Posted: Sun Jun 19, 2005 10:10 am      

and i want to use numbers
 
 
DARFUR
HOSTING / DESIGN
MAKE MONEY

       HTML Help Forum -> Javascript
Page 1 of 1


Powered by phpBB Search Engine Indexer
Powered by phpBB 2.0.19 © 2001, 2002 phpBB Group