SELFPHP: Version 5.8.2 Befehlsreferenz - Tutorial – Kochbuch – Forum für PHP Einsteiger und professionelle Entwickler

SELFPHP


Professional CronJob-Service

Suche



CronJob-Service    
bei SELFPHP mit ...



 + minütlichen Aufrufen
 + eigenem Crontab Eintrag
 + unbegrenzten CronJobs
 + Statistiken
 + Beispielaufrufen
 + Control-Bereich

Führen Sie mit den CronJobs von SELFPHP zeitgesteuert Programme auf Ihrem Server aus. Weitere Infos



:: Buchempfehlung ::

Websites optimieren für Google & Co.

Websites optimieren für Google & Co. zur Buchempfehlung
 

:: Anbieterverzeichnis ::

Globale Branchen

Informieren Sie sich über ausgewählte Unternehmen im Anbieterverzeichnis von SELFPHP  

 

:: Newsletter ::

Abonnieren Sie hier den kostenlosen SELFPHP Newsletter!

Vorname: 
Name:
E-Mail:
 
 

Zurück   PHP Forum > SELFPHP > HTML, CSS und JavaScript Help!

HTML, CSS und JavaScript Help! Hier gibt es Hilfe zu HTML, CSS und JavaScript Problemen

Antwort
 
Themen-Optionen Ansicht
  #1  
Alt 15.06.2015, 20:22:21
frodod frodod ist offline
Anfänger
 
Registriert seit: Jun 2015
Alter: 69
Beiträge: 3
Dynamische Dropboxen mit Arrays

Ich habe zwei dynamische Dropboxen ... und das funktioniert auch so wie es soll:

HTML-Code:
<head>
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">

function Type(id, type){
this.id = id;
this.type = type;
}
function Style(id, id_type, style){
this.id = id;
this.id_type = id_type;
this.style = style;
}
TypeArray = new Array(
new Type(1, "HAUPTGRUPPE A"),
new Type(2, "HAUPTGRUPPE B"),
...

new Style(1, 1, "1.UNTERGRUPPE A"),
new Style(2, 1, "2.UNTERGRUPPE A"),
...

new Style(21, 2, "1.UNTERGRUPPE B"),
new Style(22, 2, "2.UNTERGRUPPE B")
...
);


function init(sel_type, sel_style){
document.product.id_type.options[0]	= new Option("HAUPTGRUPPE");
document.product.id_style.options[0] = new Option("UNTERGRUPPE");
for(i = 1; i <= TypeArray.length; i++){
document.product.id_type.options[i]	= new Option(TypeArray[i-1].type, TypeArray[i-1].id);
if(TypeArray[i-1].id == sel_type)
document.product.id_type.options[i].selected = true;
}
OnChange(sel_style);
}
function OnChange(sel_style){
sel_type_index = document.product.id_type.selectedIndex;
sel_type_value = parseInt(document.product.id_type[sel_type_index].value);
for(i = document.product.id_style.length - 1; i > 0; i--)
document.product.id_style.options[i] = null;
j=1;
for(i = 1; i <= StyleArray.length; i++){
if(StyleArray[i-1].id_type == sel_type_value){
document.product.id_style.options[j] = new Option(StyleArray[i-1].style, StyleArray[i-1].id);
if(StyleArray[i-1].id == sel_style)	document.product.id_style.options[j].selected = true;
j++;
}
}
}

</script>
</head>
Die Auswahl erfolgt in einer Standard-form:

HTML-Code:
<body>

<form name="product" method="post" action="xy.php">

<select name="id_type" size="1" onChange="OnChange()"></select>

<select name="id_style" size="1"></select>

<input type="text" name="auswahl" value="">*

</form>


<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
init();
</SCRIPT>

</body>
Nun brauche ich aber den tatsächlichen, gleich "selected" value aus der select id_style, erhalte aber, wie ich es auch anstelle, nur die id des arrays ... oben habe ich, nur zu Testzwecken dafür die input type=text" rein gesetzt.
Alle Versuche wie [INLINE]]document.forms.auswahl.value=...[/INLINE] schlagen fehl. Die Weiterverarbeitung dieses id_style.values soll per PHP erfolgen. Wie krieg ich den gewählten (selected) Wert der UNTERGRUPPE und nicht nur die array-id raus?
Mit Zitat antworten
  #2  
Alt 16.06.2015, 09:28:40
Ckaos Ckaos ist offline
Member
 
Registriert seit: Nov 2007
Beiträge: 843
AW: Dynamische Dropboxen mit Arrays

Hi,

code gekürzt und wirr formatiert, naja...egal.

Probier das mal aus, sofern ich dich verstanden habe.
HTML-Code:
<!doctype html>
<html>
<head>
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">

function Type(id, type){
	this.id = id;
	this.type = type;
}
function Style(id, id_type, style){
	this.id = id;
	this.id_type = id_type;
	this.style = style;
}
TypeArray = new Array(
	new Type(1, "HAUPTGRUPPE A"),
	new Type(2, "HAUPTGRUPPE B")
);
StyleArray = new Array(
	new Style(1, 1, "1.UNTERGRUPPE A"),
	new Style(2, 1, "2.UNTERGRUPPE A"),
	new Style(21, 2, "1.UNTERGRUPPE B"),
	new Style(22, 2, "2.UNTERGRUPPE B")
);


function init(sel_type, sel_style){
	document.product.id_type.options[0]	= new Option("HAUPTGRUPPE");
	document.product.id_style.options[0] = new Option("UNTERGRUPPE");
	for(i = 1; i <= TypeArray.length; i++){
		document.product.id_type.options[i]	= new Option(TypeArray[i-1].type, TypeArray[i-1].id);
	if(TypeArray[i-1].id == sel_type)
		document.product.id_type.options[i].selected = true;
	}
	OnChange(sel_style);
}
function OnChange(sel_style){
	sel_type_index = document.product.id_type.selectedIndex;
	sel_type_value = parseInt(document.product.id_type[sel_type_index].value);
	for(i = document.product.id_style.length - 1; i > 0; i--)
	document.product.id_style.options[i] = null;
	j=1;
	for(i = 1; i <= StyleArray.length; i++){
		if(StyleArray[i-1].id_type == sel_type_value){
			document.product.id_style.options[j] = new Option(StyleArray[i-1].style, StyleArray[i-1].id);
			if(StyleArray[i-1].id == sel_style)	document.product.id_style.options[j].selected = true;
		j++;
		}
	}
}
function ShowValue()
{
	document.product.auswahl.value = document.product.id_style.options[document.product.id_style.selectedIndex].value+" "+
									document.product.id_style.options[document.product.id_style.selectedIndex].text;
}
</script>
</head>

<body>

<form name="product" method="post" action="xy.php">

<select name="id_type" size="1" onChange="OnChange()"></select>

<select name="id_style" size="1" onChange="ShowValue()"></select>

<input type="text" name="auswahl" value="" >*

</form>


<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
init();
</SCRIPT>

</body>
</html>
MfG

CKaos
__________________
"Wenn die Leute Häuser so bauen würden, wie wir Programme schreiben, würde der erstbeste Specht unsere Zivilisation zerhacken."
In den allermeisten Fällen sitzt der Bug etwa 40 cm vor dem Monitor!
Mit Zitat antworten
  #3  
Alt 16.06.2015, 09:51:22
frodod frodod ist offline
Anfänger
 
Registriert seit: Jun 2015
Alter: 69
Beiträge: 3
AW: Dynamische Dropboxen mit Arrays

Danke!!! Das war's!

Das der "Value" eines Arrays sich mit "text" auslesen lässt war mir neu ...
Code:
function ShowValue(){
document.product.auswahl.value = document.product.id_style.options[document.product.id_style.selectedIndex].value+" "+						document.product.id_style.options[document.product.id_style.selectedIndex].text;
}
Mit Zitat antworten
  #4  
Alt 16.06.2015, 10:43:02
Ckaos Ckaos ist offline
Member
 
Registriert seit: Nov 2007
Beiträge: 843
AW: Dynamische Dropboxen mit Arrays

Hi,

Zitat:
Das der "Value" eines Arrays sich mit "text" auslesen lässt war mir neu
So nicht.
Dein Value ist der Text.
HTML-Code:
<option value="2">2.UNTERGRUPPE A</option>
Value = 2
Text = 2.UNTERGRUPPE A

Wenn du das Formular sendest, empfängst du $_POST["id_style"]=2

MfG

CKaos
__________________
"Wenn die Leute Häuser so bauen würden, wie wir Programme schreiben, würde der erstbeste Specht unsere Zivilisation zerhacken."
In den allermeisten Fällen sitzt der Bug etwa 40 cm vor dem Monitor!
Mit Zitat antworten
  #5  
Alt 16.06.2015, 10:50:45
frodod frodod ist offline
Anfänger
 
Registriert seit: Jun 2015
Alter: 69
Beiträge: 3
AW: Dynamische Dropboxen mit Arrays

... und wieder was dazu gelernt! Irgendwann, in vielleicht 100 Jahren, werde ich dann mal vollständig kapieren, was ich da überhaupt mache. Nochmal: Danke
Mit Zitat antworten
Antwort

Stichworte
array, combobox, dynamische dropboxen


Aktive Benutzer in diesem Thema: 1 (Registrierte Benutzer: 0, Gäste: 1)
 
Themen-Optionen
Ansicht

Forumregeln
Es ist Ihnen nicht erlaubt, neue Themen zu verfassen.
Es ist Ihnen nicht erlaubt, auf Beiträge zu antworten.
Es ist Ihnen nicht erlaubt, Anhänge hochzuladen.
Es ist Ihnen nicht erlaubt, Ihre Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind aus.
[IMG] Code ist aus.
HTML-Code ist aus.

Gehe zu

Ähnliche Themen
Thema Autor Forum Antworten Letzter Beitrag
Arrays addieren mit Bedingung tsunamitsunami PHP Grundlagen 10 02.06.2014 17:29:40
Multidimensionale Arrays zusammen fügen und sortieren Inuendo PHP Grundlagen 2 18.01.2013 10:37:33
dynamische Tabelle oder dynamische DIV's urvater PHP Grundlagen 11 12.04.2012 04:41:48
array_intersect: wie leere arrays ausschließen? gerhard PHP Grundlagen 6 25.08.2004 03:20:08
wieviele Arrays ..... xtension PHP Grundlagen 34 06.07.2002 23:14:11


Alle Zeitangaben in WEZ +2. Es ist jetzt 13:14:48 Uhr.


Powered by vBulletin® Version 3.8.3 (Deutsch)
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.


© 2001-2024 E-Mail SELFPHP OHG, info@selfphp.deImpressumKontakt