Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Two questions regarding <select> data manipulation

combobox

  • Please log in to reply
4 replies to this topic

#1 Joeyeti

Joeyeti

    CC Lurker

  • Just Joined
  • Pip
  • 4 posts

Posted 21 November 2008 - 02:19 AM

Hi all programmers,

I am creating a simple webpage with an image in the background and multiple comboboxes (<select> tag) for the user to select values. Here is one of the comboboxes:

<select style="position:absolute; left:919px; top:288px; background-color: blue; color: white;" id="cze us" class="us">
<option selected>0 <option>1 <option>2 <option>3 <option>4 <option>5 <option>6 <option>7 <option>8 <option>9 <option>10 <option>11
</select>

I need to work with these selected values further and as I am quite a noob in HTML/Web programming, I have these questions:


1. How could I add values in multiple comboboxes selected, e.g. 1,3,2,6,0 together to a sum value with a button click?

2. Or would it be possible to make the addition interactive - e.g. once the user selects a different value in a combobox, the sum would be adjusted?

3. How could I store the current selections in multiple comboboxes in a txt file on the server and then recall it later?

Thx!

Joe
  • 0

#2 WingedPanther73

WingedPanther73

    A spammer's worst nightmare

  • Moderator
  • 17757 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others

Posted 21 November 2008 - 09:18 AM

Your code should really look more like this:
<select style="position:absolute; left:919px; top:288px; background-color: blue; color: white;" id="cze us" class="us">
  <option selected value="0">0</option>
  <option value="1">1</option>
  <option value="2">2</option>
  <option value="3">3</option>
  <option value="4">4</option>
  <option value="5">5</option>
  <option value="6">6</option>
  <option value="7">7</option>
  <option value="8">8</option>
  <option value="9">9</option>
  <option value="10">10</option>
  <option value="11">11</option>
</select>

Most of what you are talking about requires either JavaScript or server-side scripting.

Edited by WingedPanther, 21 November 2008 - 09:20 AM.
formatting

  • 0

Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

My MineCraft server site: http://banishedwings.enjin.com/


#3 Xav

Xav

    CC Mentor

  • VIP Member
  • PipPipPipPipPipPipPipPip
  • 8356 posts

Posted 21 November 2008 - 10:50 AM

If you can use PHP then you could automate the process of generating options:


<select style="position:absolute; left:919px; top:288px; background-color: blue; color: white;" id="cze us" class="us">
<?php
for ($i = 0; $i <= 11; $i++)
{
echo "<option selected value=\"$i\">$i</option>";

}
?>
</select>

  • 0
If you enjoy reading this discussion and are thinking about commenting, why not click here to register and start participating in under a minute?

#4 Joeyeti

Joeyeti

    CC Lurker

  • Just Joined
  • Pip
  • 4 posts

Posted 21 November 2008 - 11:29 AM

Thx guys,

could this then perhaps be moved to the PHP section to fit?
I would be interested in a PHP solution for the addition of the dropdown boxes...
  • 0

#5 Xav

Xav

    CC Mentor

  • VIP Member
  • PipPipPipPipPipPipPipPip
  • 8356 posts

Posted 21 November 2008 - 11:34 AM

If you want the items to be added without reloading the page, then you need to use JavaScript.

My code above was just to add the items when the user opens the page.
  • 0
If you enjoy reading this discussion and are thinking about commenting, why not click here to register and start participating in under a minute?





Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download