Click to See Complete Forum and Search --> : Problems with FORM
WarFare
12-18-2002, 10:24 AM
This is my Code:
So I want to reload the page and give the page the variable f_sparte .... so that I can user the VAR.
I think I have to do it with javascript ... so I tested onchange="" but I don't know how to reload the frame and set the variable to the selected value...
<select name="f_sparte" class="text">
<option value="0">Bitte wählen Sie eine vorhandene Kategorie aus</option>
<?php
$abfrage_kategorien = mysql_query("select * from sparten ORDER BY sparten ASC");
$anzahl_kategorien = mysql_num_rows($abfrage_kategorien);
for($i=1;$i<=$anzahl_kategorien;$i++){
$array_kategorien = mysql_fetch_array($abfrage_kategorien);
?>
<option <?php if($array_kategorien[0] == $f_sparte) print "selected"; ?> value="<?php print $array_kategorie[0]; ?>">
<?php
print $array_kategorien[0];
?>
</option>
<?php
}
?>
Thx a lot in advance ... and sorry fpr bad english
khalidali63
12-18-2002, 10:48 AM
Hello WarFare,
this line of code will reload the immidiate window..on any event that may call to execute this line
window.location.reload();
Khalid
WarFare
12-18-2002, 11:01 AM
And how to submit the VAR ?
window.location.reload(VAR) ?
The problem is, that he don't select what I selected before ... so I need a variable ...
Please HELP
Hello WarFare,
you have luck, I'm a friend of PHP ;-)
try it with this:
<script language=javascript>
function reload(myvalue) {
window.location.href='yoursite.php?f_sparte=' + myvalue;
}
</script>
<select name="f_sparte" class="text" onChange="reload(this.value)">
<option value="0">Bitte wählen Sie eine vorhandene Kategorie aus
<option value=test>test
<?php
$abfrage_kategorien = mysql_query("select * from sparten ORDER BY sparten ASC");
$anzahl_kategorien = mysql_num_rows($abfrage_kategorien);
for($i=1;$i<=$anzahl_kategorien;$i++){
$array_kategorien = mysql_fetch_array($abfrage_kategorien);
?>
<option <?php if($array_kategorien[0] == $f_sparte) print "selected"; ?> value="<?php print $array_kategorie[0]; ?>">
<?php
print $array_kategorien[0];
?>
<?php
}
?>
</select>
it looks like your language is german?
khalidali63
12-18-2002, 12:28 PM
Ok WarFare,
here you go.
forget about the line I of code I posted earlier.
below is the code which does exactly what you want.
1.Create an new empty html page
2.Copy all the code below in its entirety and paste it.
3.Save the page.
An click on reload button.
You will see that it creates a variable passes it to itsef, and then increases that variable by 1 and show it in the text field.When you click on reload again,it follows the process all over again,Only this time around it will increment the value you passed to itself.
If you have any questions let me know . Code below
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled</title>
</head>
<body>
<script>
/*
Author Khalid Ali
k_ali@shaw.ca
Date December 18, 2002
Self forwarding/recieving code written for WarFare
INSTRUCTIONS
1.Create an new empty html page
2.Copy all the code below in its entirety and paste it.
3.Save the page.
4.And click on reload button.
You will see that it creates a variable passes it to itsef,
and then increases that variable by 1 and show it in the text
field.
When you click on reload again,it follows the process all
over again,Only this time around it will increment the value
you passed to itself.
Have fun
Khalid
*/
onload = getData;
function getData(){
var data = window.location.toString();
if(data.indexOf("?")>-1){
var x = data.indexOf("?");
data = data.substring(x,data.length);
num = data.substring(data.indexOf("=")+1,data.length);
document.frm.textfield.value = ""+num;
}else{
document.frm.textfield.value = 1;
}
}
function load(){
var n = 0;
n = parseInt(document.frm.textfield.value);
var val = "";
n++;
val = "?value="+n;
self.location.href = val;
}
</script>
<form name="frm">
value submitted = <input type="Text" name="textfield"></input>
<input type="Button" onclick="load();" value="reload"></input>
</form>
</body>
</html>