Jump to content

Creating Inputs


Matty999555

Recommended Posts

I have this form here:

 

<html>
<head>
<script type="text/javascript" language="javascript">

function createDiv() {
var Tag = document.createElement("input");
Tag.id = "url_name[]";
Tag.type = "text";
Tag.value = "Insert Name Here";
Tag.onfocus = "if(this.value=='Insert Name Here')this.value='';";
Tag.onblur = "if(this.value=='')this.value='Insert Name Here';";
        document.getElementById("input").appendChild(Tag);

var Tag = document.createElement("input");
Tag.id = "url_url[]";
Tag.type = "text";
Tag.value = "Insert URL Here";
Tag.onfocus = "if(this.value=='Insert URL Here')this.value='';";
Tag.onblur = "if(this.value=='')this.value='Insert URL Here';";
        document.getElementById("input").appendChild(Tag);

var Tag = document.createElement("br");
        document.getElementById("input").appendChild(Tag);
}
</script>
</head>
<body>

    <p align="center">
        <b>Click this button to create div element dynamically:</b>
        <input id="btn1" type="button" value="create div" onclick="createDiv();" />
    </p>
    <div id="input">
<input id="url_name[]" type="text" value="Insert Name Here" onfocus="if(this.value=='Insert Name Here')this.value='';" 

onblur="if(this.value=='')this.value='Insert Name Here';" />
<input id="url_url[]" type="text" value="Insert URL Here" onfocus="if(this.value=='Insert URL Here')this.value='';" 

onblur="if(this.value=='')this.value='Insert URL Here';" />
<br />
    </div>
    
</body>
</html>

 

It SHOULD create two inputs with onfocus and onblur attributes but It doesn't. Can someone tell me what I am doing wrong.

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/205320-creating-inputs/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.