Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Eingabefeld (textarea) vergrössern / verkleinern

Empfohlene Antworten

Veröffentlicht

Hou

Ich habe folgendes Problem:

Auf meiner Seite befindet sich ein textarea. Es ist 400px breit und 100px hoch. Daneben befindet sich ein Icon, dem ein über ein onClick-Event ein Javascript hinterlegt ist. Dieses Script holt sich ein textarea von 400*200px. das kleine textarea wird also aufgeklappt. Nun möchte ich das textarea aber auch wieder zuklappen lassen. Hat jemand so was schon einmal gemacht und wenn ja, wie funktioniert das?

Grüsse aus dem Bärengraben

Hi,

ich würd sagen, schau doch einfach mal in die "Antworen-Maske" dieses Forums.

Dort kannst du auch per Link die Textarea vergrößeren und verkleinern.

Gruß,

Markus

Danke für den Hinweis, aber der bringt mir gar nichts! Mit zwei Icons (oder Links) ist das ganze natürlich kein Problem. Ich habe allerdings nur ein Icon, das zudem noch ändert von (-) nach (+).

Du willst also bloß zwischen den beiden Zuständen Wechseln?

Nein! Ich will, dass das Icon ein (+) anzeigt wenn das Textarea klein ist. Wenn ich auf das Icon klicke soll das textarea gross werden und das Icon soll (-) anzeigen. Wenn ich erneut das Icon anklicke soll das textarea wieder klein werden und das Icon soll wieder (+) anzeigen.

Dann musst Du Dir halt den State des Icons merken und den angezeigten Text ändern.

Ich arbeite nicht mit JavaScript, aber vom Prinzip her funktioniert es so:


ist die textarea gerade gross (=> ist der Button mit "-" beschriftet oder sonst ein gemerktes Merkmal)?
mach die textarea klein und ändere den Buttontext
ansonsten
mach die textarea gross und ändere den Buttontext
[/PHP]

Peter

Nein! Ich will, dass das Icon ein (+) anzeigt wenn das Textarea klein ist. Wenn ich auf das Icon klicke soll das textarea gross werden und das Icon soll (-) anzeigen. Wenn ich erneut das Icon anklicke soll das textarea wieder klein werden und das Icon soll wieder (+) anzeigen.

nichts anderes hab ich auch gesagt....


function toggleTextarea( boxid) {

	var box = fetch_object(boxid);

	var boxheight = parseInt(box.style.height);

        if ( boxheight == 200) {

            alter_box_height( box, 500);

        } else {

            alter_box_height( box, 200);

        }


}


function alter_box_height(box, pixelvalue)

{

	var boxheight = parseInt(box.style.height);

	var newheight = boxheight + pixelvalue;

	if (newheight > 0)

	{

		box.style.height = newheight + "px";

	}

	return false;

}

// #############################################################################

// let's find out what DOM functions we can use

var vbDOMtype = '';

if (document.getElementById)

{

	vbDOMtype = "std";

}

else if (document.all)

{

	vbDOMtype = "ie4";

}

else if (document.layers)

{

	vbDOMtype = "ns4";

}


// make an array to store cached locations of objects called by fetch_object

var vBobjects = new Array();


// #############################################################################

// function to emulate document.getElementById

function fetch_object(idname, forcefetch)

{

	if (forcefetch || typeof(vBobjects[idname]) == "undefined")

	{

		switch (vbDOMtype)

		{

			case "std":

			{

				vBobjects[idname] = document.getElementById(idname);

			}

			break;


			case "ie4":

			{

				vBobjects[idname] = document.all[idname];

			}

			break;


			case "ns4":

			{

				vBobjects[idname] = document.layers[idname];

			}

			break;

		}

	}

	return vBobjects[idname];

}

musst nur das bild noch drehen....

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.