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 web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.


Reply via email to