javascript - 将变量添加到属性

标签 javascript html forms

我需要将 action url 属性设置为由“url”+变量组成。 像这样:

    <script>
    var domain = "@example.com";
    </script>
    <body>
    <form action=("https://login.example.com/&" + domain) id="login_form" method="get">
    <input type="text" name="username">
    <button type="submit" id="submit">Log in</button>
    </form>

我需要制作带有姓氏的标签,并通过此表单将标签发送为lastname@example.com。

最佳答案

你可以试试这个

<script>
    var domain = "@camosoft.cz";
    var url = "https://login.szn.cz//?returnURL=https://email.seznam.cz/&serviceId=email&" + domain
    document.getElementsById("login_form").setAttribute("action", url);
</script>
<body>
<form action="" id="login_form" method="get">

关于javascript - 将变量添加到属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55022541/

相关文章:

html - 如何通过响应式设计将多个表单和标题集群分组以放在同一行和中心?

javascript - 尝试作为 Prop 传递时, react 状态变量意外未定义

javascript - 我可以使用 jquery mobile 优化现有的 HTML、CSS 和 JS 文件吗

javascript - 如何使用普通 Javascript 识别一系列无序列表和/或嵌套列表中的上一个/下一个链接?

html - 如何让 ie8 文本框在包含水印时显示光标?

php - reCaptcha 值未出现在 $_POST 中

javascript - 如何从谷歌表格中获取数据作为字典数组

html - Bootstrap : Navigation points should stack in mobile view and padding inside navigation points should not overlap

javascript - 更改正文背景颜色。单击以在整个站点范围内应用并在刷新时应用?

java - 无法获取使用 jQuery Popconfirm 插件单击的按钮的名称