我需要将表单发布到Salesforce来创建案例。根据单击哪个按钮提交表单之前,我需要更改表单值。
我创建了一个具有两个按钮的,单击第一个按钮时,我将时间设置为当前时间,如果单击第二个按钮,则我选择由客户输入的时间。另外,从后面的代码中,我需要获取帐户ID并将其分配给表单值。
<form runat="server" id="sf_case_form" name="sf_case_form" action="https://test?encoding=UTF-8" method="post">
<input hidden="hidden" id="sf_account_id" maxlength="20" runat="server" name="sf_account_id" size="20" type="text" />
<input type="hidden" id="external" name="external" value="1" />
<input hidden="hidden" type="submit" name="submit"/>
<div class="wrapper wrapper-content p-xs">
<div class="row">
<div class="col-lg-3">
<div class="contact-box center-version">
<div class="ibox float-e-margins">
<div class="ibox-title">
<h5>Request Callback</h5>
</div>
<div class="ibox-content" >
<div class="form-group">
<label class="font-normal">Your phone number</label>
<input id="selected_phone_number" name="selected_phone_number" type="text" class="form-control" data-mask="(999) 999-9999" runat="server" placeholder="(999) 999-9999"/>
</div>
<asp:button style="margin-bottom: 20px" id="btn_call_now" OnClick="call_now_Click" type="button" runat="server" Text="Call me now" CssClass="btn btn-w-m btn-danger"/>
<div class="form-group" id="data_1">
<label class="font-normal">Choose your desired date and time to schedule a call</label>
<div class="input-group date">
<input id="selected_date" name="selected_date" type="text" runat="server" class="form-control" value="03/04/2014"/>
<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
</div>
</div>
<div class="input-group clockpicker" data-autoclose="true">
<input id="selected_time" name="selected_time" type="text" runat="server" class="form-control" value="09:30"/>
<span class="input-group-addon">
<span class="fa fa-clock-o"></span>
</span>
</div>
<div style="margin-top: 20px">
<asp:button id="btn_schedule_call" type="button" runat="server" OnClick="schedule_call_Click" Text="Schedule a call" CssClass="btn btn-w-m btn-primary"/>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</form>
后面的代码
protected void call_now_Click(object sender, EventArgs e)
{
//Set date to current date
selected_date.Value = DateTime.Now.ToString("d");
selected_time.Value = DateTime.Now.ToString("t");
post_form();
}
call_now_Click没有被调用,从后台代码更改值后如何提交表单?
答案 0 :(得分:0)
使用时
<button type="button" onclick="yourFunctionName()">Click Me!</button>
将 ClientIDMode =“ Static” 添加到您的服务器控件中,以使用更简单的ID
<input ClientIDMode="Static" id="selected_date" name="selected_date" type="text" runat="server" class="form-control" value="03/04/2014"/>
添加
在脚本中
<script>
function yourFunctionName() {
document.getElementById('selected_date').value = new Date();
....
....
document.form.submit();
}
</script>