开发者

How to add Script as Field's value?

I need to add this script:

<script language="javascript"> document.write('' + geoip_city() +''); </script>

As the field's value开发者_StackOverflow and as to the onfocus, so it erases it on click.

<input type="text" name="question" value="" style="display:none" onfocus="if (this.value == 'Agregá tu ciudad') {this.value=''}">

How do I do it? Thanks


<script type="text/javascript">
document.write('<input type="text" name="question" value="'+geoip_city()+'" style="display:none" onfocus="if (this.value == \''+geoip_city()+'\') {this.value=\'\'}">');
</script>

This simply prints the whole input through javascript (not nice to read at all, but fulfills the purpose). the default value is the value return by geoip_city. If you click the element the default value will be deleted. I hope I understood you correctly, feel free to provide additional information if this isn't what you're looking for.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜