It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming JavaScript Forum

Dynamic drop down menu

Dynamic drop down menu

Postby realttc on Mon Feb 19, 2007 1:05 pm

hi all, im a new user here .. im seeking an advice frm JS gurus .. is there anyway to save a user population into form drop down menu by using JS ?? Assume I have a drop down menu that can be customized by user and save the user input for next uses. I just dont want to bother about using DB. Only insist to use JS and if there is a way out, please let me know. I appreciate your advice thanks!

here is the code of the form:

Code: Select all
<html>
<head>
<script LANGUAGE="JavaScript" TYPE="text/javascript">

function validateForm(objForm)
{
var returnStatus = 1;

if (objForm.dynamicSelection.selectedIndex == 0) {
  alert("Please select a template");
  returnStatus = 0;
};
if (objForm.dynamicSelection.selectedIndex == 4)
{
  if (objForm.mseg.value == "")
  {
      alert ("Please create a new template.");
      objForm.valueinsert.focus();
      returnStatus = 0;
   }
}

}

function insertOption()
  {
   myOption = new Option();
   var variable1 = document.selectionForm.mseg.value
   var variable2 = document.selectionForm.mseg.value
   myOption.text = variable1;
   myOption.value = variable2;
    if (document.selectionForm.dynamicSelection.selectedIndex>0)
    insertIndex=document.selectionForm.dynamicSelection.selectedIndex;
   else
    insertIndex=document.selectionForm.dynamicSelection.options.length;

   document.selectionForm.dynamicSelection.options[insertIndex]=myOption;   
  }
 
  function deleteOption()
  {
   if (document.selectionForm.dynamicSelection.selectedIndex>0)
    deleteIndex=document.selectionForm.dynamicSelection.selectedIndex;
   else
     deleteIndex=document.selectionForm.dynamicSelection.options.length-1;

   document.selectionForm.dynamicSelection.options[deleteIndex]=null;
  }
 
   function Choice()
   {
      selectionForm.mseg.value = selectionForm.dynamicSelection.value;
   }
   
   
 
</script>

<body>
<form name="selectionForm" action="" method="POST">
<table width="80%" cellpadding="5" cellspacing="0">

<tr><td align="right">Select Template:</td>
<td align="left"><select name="dynamicSelection" onChange="Choice();">
<option value="0">--Pls select the template--</option>
<option value=""></option>
</select>
</td>

<tr><td align="right"></td>
<td align="left"><input type="hidden" name="tmpl_id"></td>
</tr>

<tr>
<td align="right">
    BroadCast box:</td><td align="left"> <textarea name="mseg" rows="5" cols="33"
onKeyUp="val = this.value;
if (val.length>160)
{
  alert('Sorry, you are over the limit of 160 characters');
  this.value = val.substring(0,160);
  smsInput.focus()
}
this.form.count.value=160-parseInt(this.value.length);">
</textarea></td>

&nbsp;
<tr> <td colspan="2" align="center">
<input type="text" name="count" value="160" size="3" onFocus="this.blur" readonly>
<font size="-1">characters left</font></td>
<td colspan="2" align="left"><input type="button" value="InsertOption" onclick="insertOption();">
<input type="button" value="DeleteOption" onclick="deleteOption();"></td>
</td></tr>

<tr>
        <td align="right">Please specify file to upload:</td>
   <td align="left"><input type="file" name="address" size="30" maxlength="80" /></td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="button" name="submit" value="Upload" onClick="validateForm(document.upload);">
<input type="reset" name=".reset" value="Reset" />
</td>
</tr>
<tr><td colspan="2">&nbsp;</td></tr>
</table>


<input type="hidden" name="mode" value="uploading" />

</p>

<p> &nbsp;</p>

</form>

</body>
</html>
realttc
 
Posts: 0
Joined: Mon Feb 19, 2007 1:03 pm

Who is online

Users browsing this forum: No registered users and 6 guests