I would use jquery. Here is an untested example so may be buggy

<script>
jQuery(document).ready(function(){
  jQuery('#mySelect').change(function(){
    if(jQuery('#mySelect').val()=='Specify...')
      jQuery('#mySelect:selected').text(prompt("Please name your
favorite fruit:",""));
  });
});
</script>

On Jan 19, 7:19 pm, NeonGoby <[email protected]> wrote:
> On a form generated by SQLFORM, I have a drop-down selection box, that
> let's the user selects from a list of fruits.  I would like allow the
> user to specify a fruit not on the list.  I have written the following
> Javascript that would pop-up a prompt box when the user selects the
> Specify... option.
>
> How do I add this Javascript into the form generated by SQLFORM?
>
> Thanks always for your help and suggestions.
>
> NeongGoby
>
> <html>
>
> <head>
>
> <script type="text/javascript">
>
> function promptName()
>
> {
>
>         var x=document.getElementById("mySelect");
>
>         if (x.options[x.selectedIndex].text == "Specify...")
>
>         {
>
>                 var ename=prompt("Please name your favorite fruit:","")
>
>                 x.options[x.selectedIndex].text=ename;
>
>         }
>
> }
>
> </script>
>
> </head>
>
> <body>
>
> <form>
>
> Select your favorite fruit:
>
> <select id="mySelect" onChange="promptName()" >
>
>   <option>Apple</option>
>
>   <option>Orange</option>
>
>   <option>Pineapple</option>
>
>   <option>Banana</option>
>
>   <option>Specify...</option>
>
> </select>
>
> <input type="button" value="Submit">
>
> </form>
>
> </body>
>
> </html>
-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.


Reply via email to