javascript - How to create a function in which a box moves in accordance with 2 user inputs (direction and # of pixels to move) -


Even I have so far:

My CSS is for the following box: P {width: 100px; Padding: 25px; Limit: 25px solid red; Margin: 25px; Status: fixed; Top: 100px; }

And here is the JavaScript and HTML that I have done so far:

   & Lt; Br> Directions to move: & lt; Select ID = "Direction Selection" & gt; & Lt; Options & gt; Up & lt; / Options & gt; & Lt; Options & gt; Down & lt; / Options & gt; & Lt; Options & gt; Left & lt; / Options & gt; & Lt; Options & gt; Rights & lt; / Options & gt; & Lt; / Select & gt; & Lt; Br> & Lt; Br> & Lt; Input id = "status box" type = "button" value = "move the box" & gt; & Lt; / Form & gt; & Lt; / Body & gt; & Lt; / Html & gt;   

The part I am stumped on is how can I get my status box button to interact with my directions. Select drop-down menu and numpixels within my javascript Can anyone help me out here?

In my class yesterday, my professor showed us an example of getting the button to go with hard-coded parameters, but now I need to do this with a box of pixels With the number of users proceed with the specified direction I can also post that example code if it can be useful for anyone.

part I function, use document.getElementById ("numpixels "). Value and document.getElementById ("directionSelection"). Value Number of pixels and direction to move

We have shown an example of getting the button to go with hard-coded criteria, but now I need to do that with the box

movebox function, you id attr to & lt; P & gt; This box has to be added. & Lt; / P & gt; element so you can choose it from the var box = document.getElementById ("myBox"); . After this, the values ​​of box.style.top and box.style.left to move the box instead of implementing the positionbox .

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -