place the fields at a particular position (left, right, top, bottom) as selected by the admin.

i have the following fields and each field is in separate div and there is a drop down menu in front of each field having options are left, right, top, middle, bottom. these fields are in the admin part.

name (div1)    -  there is a drop down menu (options are left, right, top, bottom,middle)
company address (div2)    -  there is a drop down menu (options are left, right, top, bottom,middle)
full name  (div3)    -  there is a drop down menu (options are left, right, top, bottom,middle)
address line 1  (div4)    -  there is a drop down menu (options are left, right, top, bottom,middle)

Below there is a submit button, on clicking the button, according to the options selected by the user, that field should be placed at that position.
designersxAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Steve BinkCommented:
The user selections will be passed to your page through $_POST.  It should be a simple matter of examining those selections, and creating the div with the appropriate class.  For example, imagine I have this CSS entry:

<style>
  div.option_topleft { position:absolute;top:0;left:0 }
  div.option_bottomright { position:absolute;top:300;left:250 }
</style>

Now take a look at this code:
<?
/*
based on:
<input type="text" name="ctl_name" value="" />
<select name="ctl_name_pos">
  <option value="0">Top Left</option>
  <option value="1">Bottom Right</option>
</select>
*/
 
$controls = array('ctl_name');  // put all your control names
foreach ($controls as $key=>$val) {
  switch($controls["{$key}_pos"]) {
    case 0:$class="topleft";break;
    case 1:$class="bottomright";break;
    default:$class="";break;
  }
  echo "<div class=\"$class\">$val</div>";
}
?>

Open in new window

0
Steve BinkCommented:
DOH...forgot the part about $_POST...  :)


<?
/*
based on:
<input type="text" name="ctl_name" value="" />
<select name="ctl_name_pos">
  <option value="0">Top Left</option>
  <option value="1">Bottom Right</option>
</select>
*/
 
$controls = array('ctl_name');  // put all your control names
foreach ($controls as $key) {
  switch($_POST["{$key}_pos"]) {
    case 0:$class="topleft";break;
    case 1:$class="bottomright";break;
    default:$class="";break;
  }
  echo "<div class=\"$class\">",$_POST[$key],"</div>";
}
?>

Open in new window

0
designersxAuthor Commented:
where is the submit button in this? what will be the output? can u tell me please?
0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

designersxAuthor Commented:
Sir, my simple question is this

how to move the text on a window as selected by the user from a drop down menu on clicking the button ?
0
Steve BinkCommented:
The submit was not important to my example, so I did not include it.  When the user clicked the submit button, the page would be refreshed with the correct class for each div.  I assumed you wanted this in PHP because you posted this question in the PHP zone.

If you want this to be done through javascript, take a look at the example below.

<script type="text/javascript">
  function changepos() {
    var x;
    x = document.getElementById('selpos').selectedIndex;
    y = document.getElementById('test');
    switch(x) {
    	case 0: y.style.top='50px';y.style.left='200px';break;
    	case 1: y.style.top='350px';y.style.left='200px';break;
    	case 2: y.style.top='200px';y.style.left='0px';break;
    	case 3: y.style.top='200px';y.style.left='400px';break;
    }
  }
</script>
<style>
  #test { width:200px;height:50px;position:absolute;top:50px;left:200px; }
</style>
<form>
  <div class="t1" id="test">Stuff</div>
  <select id="selpos" onchange="changepos();">
  	<option value="0">Top</option>
  	<option value="1">Bottom</option>
  	<option value="2">Left</option>
  	<option value="3">Right</option>
  </select>
</form>

Open in new window

0
designersxAuthor Commented:
this was exactly i wanted, thanks buddy for this.

Actually buddy, this is exactly ok but can u do it if i have a submit button

with ur previous code, nothing happens with this code when i tested.

<?
/*
based on:
<input type="text" name="ctl_name" value="" />
<select name="ctl_name_pos">
  <option value="0">Top Left</option>
  <option value="1">Bottom Right</option>
</select>
*/
 
$controls = array('ctl_name');  // put all your control names
foreach ($controls as $key) {
  switch($_POST["{$key}_pos"]) {
    case 0:$class="topleft";break;
    case 1:$class="bottomright";break;
    default:$class="";break;
  }
  echo "<div class=\"$class\">",$_POST[$key],"</div>";
}
?>
0
Steve BinkCommented:
Do you want the page to refresh when the button is clicked?
0
designersxAuthor Commented:
it is not mandatory that i want the page to be refreshed, the only thing i want i that is through button.
0
Steve BinkCommented:
Using the PHP style, you can just put a regular form button as the submit.  Make sure the form method="POST" and that action points back to the same filename.

<input type="submit" name="dosubmit" value="Place Items" />
0
designersxAuthor Commented:
with php , text goes in the bottom for 1 second and then comes to its place when i select bottom and clik the submit button. This happens for all the the positions.


yogesh
<script type="text/javascript">
  function changepos() {
    var x;
    x = document.getElementById('selpos').selectedIndex;
    y = document.getElementById('test');
    switch(x) {
        case 0: y.style.top='50px';y.style.left='200px';break;
        case 1: y.style.top='350px';y.style.left='200px';break;
        case 2: y.style.top='200px';y.style.left='0px';break;
        case 3: y.style.top='200px';y.style.left='400px';break;
    }
  }
</script>
<style>
  #test { width:200px;height:50px;position:absolute;top:50px;left:200px; }
</style>
<form action="ox_print_left_right_2nd.php" method="post" name="form" onSubmit="javascript:changepos();">
  <div class="t1" id="test">Stuff</div>
  <select id="selpos">
        <option value="0">Top</option>
        <option value="1">Bottom</option>
        <option value="2">Left</option>
        <option value="3">Right</option>
  </select>
  <input type="submit" name="dosubmit" value="Place Items" />
</form>

Open in new window

0
Steve BinkCommented:
You mixed up the styles.  You have all the code for the javascript method, but you are letting the form submit to PHP.  Try this change, and don't use the submit button:
<script type="text/javascript">
  function changepos() {
    var x;
    x = document.getElementById('selpos').selectedIndex;
    y = document.getElementById('test');
    switch(x) {
        case 0: y.style.top='50px';y.style.left='200px';break;
        case 1: y.style.top='350px';y.style.left='200px';break;
        case 2: y.style.top='200px';y.style.left='0px';break;
        case 3: y.style.top='200px';y.style.left='400px';break;
    }
  }
</script>
<style>
  #test { width:200px;height:50px;position:absolute;top:50px;left:200px; }
</style>
<form action="ox_print_left_right_2nd.php" method="post" name="form">
  <div class="t1" id="test">Stuff</div>
  <select id="selpos" onchange="javascript:changepos();">
        <option value="0">Top</option>
        <option value="1">Bottom</option>
        <option value="2">Left</option>
        <option value="3">Right</option>
  </select>
  <input type="submit" name="dosubmit" value="Place Items" />
</form>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
designersxAuthor Commented:
your above code is working same as ur previous code. but it clicked me and i have done it.

see the code. now on selecting the options the div will not change but on clicking the button it will change.
but otherwise thanks for ur help.

yogesh

<script type="text/javascript">
  function changepos() {
    var x;
    x = document.getElementById('selpos').selectedIndex;
    y = document.getElementById('test');
    switch(x) {
        case 0: y.style.top='50px';y.style.left='200px';break;
        case 1: y.style.top='350px';y.style.left='200px';break;
        case 2: y.style.top='200px';y.style.left='0px';break;
        case 3: y.style.top='200px';y.style.left='400px';break;
    }
  }
</script>
<style>
  #test { width:200px;height:50px;position:absolute;top:50px;left:200px; }
</style>
<form action="ox_print_left_right_2nd.php" method="post" name="form">
  <div class="t1" id="test">Stuff</div>
  <select id="selpos">
        <option value="0">Top</option>
        <option value="1">Bottom</option>
        <option value="2">Left</option>
        <option value="3">Right</option>
  </select>
  <input type="button" name="dosubmit" value="Place Items" onclick="changepos();" />
</form>

Open in new window

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.