Formularfelder direkt ausfüllen

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • AmicaNoctis
    replied
    Originally posted by sepp View Post
    Code:
     document.form.preis.value=document.form[B][COLOR="Red"].[/COLOR][/B]["stpreis[document.form.detail_id.value].value"]*document.form.["detail_menge[document.form.detail_id.value].value"]
    Also, erstmal muss bei der []-Notation der Punkt ganz weg (rot), dann wird der Inhalt als String angegeben und daher nicht mehr ausgewertet.


    Damit es doch ausgewertet wird, muss der String aufgebrochen und konkateniert werden:
    Code:
    document.form.preis.value =
    	document.form["stpreis[" + document.form.detail_id.value + "]"].value
    	* document.form.["detail_menge[" + document.form.detail_id.value + "]"].value
    Gruß,

    Amica

    Leave a comment:


  • sepp
    replied
    Danke für die schnelle Antwort, leider komme ich dennoch nicht zum Ziel.

    Habe es wie folgt ohne Erfolg versucht.
    Code:
     document.form.preis.value=document.form.["stpreis[document.form.detail_id.value].value"]*document.form.["detail_menge[document.form.detail_id.value].value"]
    oder

    Code:
     document.form.preis.value=document.form.stpreis["[document.form.detail_id.value]"].value*document.form.detail_menge["[document.form.detail_id.value]"].value

    Leave a comment:


  • AmicaNoctis
    replied
    Hallo Sepp,

    um eine ähnliche Frage ging es hier: http://www.php-resource.de/forum/htm...tml#post625292

    Wenn dir das nicht helfen sollte, bitte nochmal nachfragen.

    Gruß,

    Amica

    Leave a comment:


  • sepp
    started a topic Formularfelder direkt ausfüllen

    Formularfelder direkt ausfüllen

    Hallo zusammen

    Ich mache mit Java Script folgendes, um die Felder sofort zu aktuallisieren.
    Code:
    script type="text/JavaScript">
    function  rechne()
    {  document.form.preis.value=document.form.stpreis.value*document.form1.detail_menge.value
    }
    </script>
    Aufgerufen wird die Funktion mittels onKeyUp="rechne()"

    Das funktioniert also einwandfrei, nun die Schwierigkeit.
    Die Formularfelder werden mittels while Schlaufe aus einer DB gezogen und wie folgt dargestellt.
    HTML Code:
    <input type="text" onKeyUp="rechne()" value="<? echo"$detail_stkpreis"; ?>" name="stpreis[<? echo"$detail_id" ?>]" >
    Das heist ich habe den Namen in einem Array referenziert mit der $detail_id. Und so kann ich im JS das feld nicht mehr ansteuern. Wie kann ich auf ein solches Array zugreifen?

    Folgendes habe ich schon erfolglos versucht.
    Code:
     document.form.preis.value=document.form.stpreis[document.form.detail_id.value].value*document.form.detail_menge[document.form.detail_id.value].value
    weiss mir hier jemand Rat? Danke
Working...
X