#1
  1. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Apr 2001
    Location
    Cape Town
    Posts
    572
    Rep Power
    16

    Red face Javascript loop and php loop?


    Here is code:

    I appologize if this not php question but code does have php init.
    PHP Code:
    <html>
    <head>
    <title>Rules</title>
     <style>

    input.prompt {
        border:1 solid transparent; background-color:#ccccff;width:70;font-family:arial;font-size:12; color:black;
        }
    td.titlebar {
        background-color:#C4B0FF; color:black; font-weight:bold;font-family:arial; font-size:12;
    }
    table.promptbox {
        border:1 solid #ccccff; background-color:white; color:black;padding-left:2;padding-right:2;padding-bottom:2;font-family:arial; font-size:12;
        }
    input.promptbox {
        border:1 solid #ccccff; background-color:#ccccff;width:100%;font-family:arial;font-size:12; color:black;
    }
    </style>

    <META HTTP-EQUIV="Pragma" CONTENT="no-cache">
    <META HTTP-EQUIV="Expires" CONTENT="-1">
    <script type="text/javascript">
    /*
    A javascript prompt that looks a bit better than the normal prompt
    command (output = prompt2(picture, title, message, function to pass result to)
    */
    var response = null
    function prompt2(promptpicture, prompttitle, message, sendto) {
        promptbox = document.createElement('div');
        promptbox.setAttribute ('id' , 'prompt')
        document.getElementsByTagName('body')[0].appendChild(promptbox)
        promptbox = eval("document.getElementById('prompt').style")
     promptbox.position = 'absolute'
        promptbox.top = 100
        promptbox.left = 400
        promptbox.width = 300
        promptbox.border = 'outset 1 #bbbbbb'
        document.getElementById('prompt').innerHTML = "<table cellspacing='0' cellpadding='0' border='0' width='100%'><tr valign='middle'><td width='22' height='22' style='text-indent:2;' class='titlebar'><img src='" + promptpicture + "' height='18' width='18'></td><td class='titlebar'>" + prompttitle + "</td></tr></table>"
        document.getElementById('prompt').innerHTML = document.getElementById('prompt').innerHTML + "<table cellspacing='0' cellpadding='0' border='0' width='100%' class='promptbox'><tr><td>" + message + "</td></tr><tr><td><input type='text' id='promptbox' onblur='this.focus()' class='promptbox'></td></tr><tr><td align='right'><br><input type='button' class='prompt' value='OK'  onMouseOver='this.style.border=\"1 outset #dddddd\"' onMouseOut='this.style.border=\"1 solid transparent\"' onClick='" + sendto + "(document.getElementById(\"promptbox\").value); document.getElementsByTagName(\"body\")[0].removeChild(document.getElementById(\"prompt\"))'> <input type='button' class='prompt' value='Cancel' onMouseOver='this.style.border=\"1 outset transparent\"' onMouseOut='this.style.border=\"1 solid  transparent\"' onClick='" + sendto + "(\"\"); document.getElementsByTagName(\"body\")[0].removeChild(document.getElementById(\"prompt\"))'></td></tr></table>"
        document.getElementById("promptbox").focus()
    }
    function myfunction(value) {
        document.getElementById("output").innerHTML = value
    var ed = document.getElementById("output").innerHTML;
    var cid = document.hotform1.classid.value;
       location.href="/yep.php?test=ttt&classid=" + cid + "&irer=dffd&limit=" + ed + "&cheers=" + screen.height;
    }

    </script>
    </head>
    <body bgcolor=white marginwidth=0 marginheight=0 topmargin=0 leftmargin=0>

    <?


    $count 
    "1";

    while(
    $count <= '2'){
    echo 
    "
    <form name=hotform
    $count onClick=\"prompt2('images/e.gif', 'Limit','Enter Limit $count:', 'myfunction')\">
    <input type=hidden name=ifacs value='any'>
    <input type=hidden name=classid value='
    $count'>
    Current: sfq<br>
    <input type=button value=Change>
    </form>
    <div id=\"output\"></div>
    "
    ;
    $count++;
    }
     
    ?>

    If you run this it will work but only on the first form cause
    I use var cid = document.hotform1.classid.value;
    I also tried replacing hotform1 with this or thisform, but still not work.
    Its that hotform1 part, I tried putting that into a loop to..
    How would you do this?

    Thanks
    Last edited by bonechair; April 30th, 2003 at 05:39 AM.

IMN logo majestic logo threadwatch logo seochat tools logo