looping variables
| From: | Wen Ni Leong | Date: | Fri, 09 Feb 2001 05:52:54 +0000 |
| Subject: | looping variables | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-38899@lists.php.net to get a copy of this message | ||
Please help me to solve this problem. I have looping selected menu and
I want to use javascript to control each function. For example if
select Text Form,the javascript will automate to open new window.
Right now my problem is I can't differentiate from which menu or
location I had selected because all of them are looping. So please help
me to look at the coding below. See what I need to change. Thanks.
print "<SCRIPT LANGUAGE = \"JavaScript\">
function chg_list(temp_val,form_property,num)
{
var value = temp_val;
var count = 1;
var max_count = document.theform.result.value;
var loc = document.theform.docvar.value;
while (count < max_count)
{
var var_temp = \"title_\"+count+\"_lf\";
if(value == \"text\")
{
newWindow = window.open(\"newwin.php?doc_var=$doc_var'\",
\"newWindow\",
\"toolbar=no,menubar=no,scrollbars=yes,width=783,height=400,top=0,left=0\");
}
if(value == \"exist_doc\")
{
alert(\"testing=\"+value+\"\");
}
count++;
}
return true;
}
</SCRIPT>\n";
<form>
while ($count < $last_row_no)
{
$doc_var = "title_"."$count"."_lf";
if ($count =="1")
{ print "<TD align=center><b>Start</b></TD>\n"; }
else
{
print "<TD><a name=\"$var_loc\"></a>
<font size=3><select name=\"$doc_var\"
onchange=\"chg_list(this.form.$doc_var.options[this.form.$doc_var.selectedIndex].value,
form.$doc_var.options[0])\">\n";
if ($doc_title == "")
{print "<option value=\"\" selected>\n";}
else
{print "<option value=\"$doc_title\"
selected>$doc_title\n";}
print "<option value=\"new_doc\">New Document
<option value=\"exist_doc\">Existing Document
<option value=\"\">--------------- End Of List
--------------
</select></font></TD>\n";
}
print "<input type=hidden name=\"docvar\"
value=\"$doc_var\">\n";
</form>