javascript - Adding Textfields at runtime in php -
I'm new to php and now want to, how can I add a text field to runtime I have a simple dropdown list Have a php page created. The dropdown list contains 1,2,3 numbers and so what I want to do is that whenever a user selects a number from the dropdown list, the same type of text field (with label) appears. Example 1 textfell for 1 (with label), textfield for 2 and so on. If someone can give me a link to example or understand any example, it would be very helpful thanks a lot :)
I will use jquery, suggested Dagon as a JavaScript library. Your HTML first:
& lt; Form & gt; & Lt; Input class = "target" type = "text" value = "field 1" /> & Lt; Select class = "target" & gt; & Lt; Option value = "1" selected = "selected" & gt; Option 1 & lt; / Options & gt; & Lt; Option value = "2" & gt; Option 2 & lt; / Options & gt; & Lt; / Select & gt; & Lt; / Form & gt; & Lt; Div id = "other" & gt; & Lt; / Div & gt; Then your JavaScript (using jQuery):
$ ('. Target'). Change (function () {$ ("Select option: selected" $ (this) .text () + "& lt; / label & gt; & lt; input type = 'text' value = '' / / & Gt; ");})}}}; For your reference:
Comments
Post a Comment