Multiple Object Area

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
jayr517
Forum Commoner
Posts: 26
Joined: Fri Aug 22, 2003 7:28 pm
Location: Boise, ID
Contact:

Multiple Object Area

Post by jayr517 »

Ok...I hope I can explain this so it's understandable...here goes...(forgive me if this doesn't go in client side...didn't really know where it would fit).

I'm creating a web based training log application, where users can add new entries solely by clicking buttons and drop downs. For 95% of the entries, there's a one to one relationship between all of the objects. For example, there's one distance entry/object for each run entry/object, one temperature entry/object for each weather entry/object, etc, etc.

The problem I'm having is with speed workouts. For each training log entry/object, there can be one to many speedwork "intervals" that can exist. This is the only occurance of a one to many relationship in this OO system, and the first one I've tried to incorporate into the client-side. I can pretty easily accomodate this in the database, but I'm more of a backend person and the gui part of PHP and web is pretty new to me.

What I want to do is create a sort of "selection area" in the user interface, that's initially empty, and can hold objects instead of just text. I want the user to be able to select criteria outside of this area (via drop-downs) which will populate the object, and then click an "add interval" button to add the new object to the selection area. I want them to be able to do this for as many intervals as they need, and WITHOUT the PHP page have to resubmit itself (I'm using a self-submitting form).

I hope that makes sense. For an example of what I'm trying to do, go to http://www.runnerslog.com/ and create a new account (it only takes a minute). Once you have a new account, create a new location, and then add a new entry. From the new entry UI, you'll see what I'm trying to explain. The site is using ASP to do this.

If you need more info, shoot me an email...my addy is in my profile. I would appreciate the help.

Thanks,
J
User avatar
Vincent Puglia
Forum Commoner
Posts: 67
Joined: Thu Sep 04, 2003 4:20 pm
Location: where the World once stood

Post by Vincent Puglia »

Hi,
this is a quickly-written, but poor example; it does show you how to go about, though.

Code: Select all

<html>
<head>
<script language='javascript>
<!--
function doit(num)
&#123;
  txt = ""
  for (var i = 0; i < num; i++)
    txt += "<input type='text'>"

     document.getElementById('b').innerHTML = txt;

&#125;

//-->
</script>
</head>
<body>
<form>
<select name="a" onchange='doit(this.options&#1111;this.selectedIndex].value)'>
<option value="0">select # of fields</option>
<option value="1">1</option>
<option value="2">2</option>
</select>
</form>
<div id="b">
</div>
</body>
</html>
Vinny
Post Reply