Note that there are some explanatory texts on larger screens.

plurals
  1. POFinding checkbox value, writing to XML result
    primarykey
    data
    text
    <p>I'm creating a weekly HTML email writing template (hence the weird file name) and I'm using ASP and XML as the backend. The XML is prefect but the ASP isn't..</p> <p>What I'm going for here is to create an XMl node that has a value of notchecked and checked depending on if the checkbox on the form is checked or not.</p> <p>I've tried using</p> <pre><code>If Request.QueryString("promotioncheck") = "on" Then Set objField = objDom.createElement("promotioncheck") objField.Text = "checked" objRecord.appendChild objField Else Set objField = objDom.createElement("promotioncheck") objField.Text = "notchecked" objRecord.appendChild objField End If </code></pre> <p>but when I do it doesn't pick up the changes and just outputs notchecked even when the checkbox is checked.</p> <p>Here's my ASP:</p> <pre><code>&lt;% If Request.Form("hidden") = "true" Then Dim objDom Dim objRoot Dim objRecord Dim objField Dim objFieldValue Dim objattID Dim objattTabOrder Dim objPI Dim blnFileExists Dim x Dim z Set objDom = server.CreateObject("Microsoft.XMLDOM") objDom.preserveWhiteSpace = True blnFileExists = objDom.LoadXML(server.mappath("./")&amp; "/eg"&amp;Day(Date)&amp;"_"&amp;Month(Date)&amp;".xml") If blnFileExists = True Then For x = 1 To Request.Form.Count If instr(1,Request.Form.Key(x),"hidden") = 0 Then Set z = objDom.selectNodes("eg/stories/"&amp;Request.Form.Key(x)) Response.Write(Request.Form.Key(x)) z.innerText = Request.Form(x) End If Next Else Set objRoot = objDom.createElement("eg") objDom.appendChild objRoot Set objRecord = objDom.createElement("stories") objRoot.appendChild(objRecord) For x = 1 To Request.Form.Count If instr(1,Request.Form.Key(x),"hidden") = 0 Then Set objField = objDom.createElement(Request.Form.Key(x)) objField.Text = Request.Form(x) objRecord.appendChild objField End If Next If Request.QueryString("promotioncheck") = "on" Then Set objField = objDom.createElement("promotioncheck") objField.Text = "checked" objRecord.appendChild objField Else Set objField = objDom.createElement("promotioncheck") objField.Text = "notchecked" objRecord.appendChild objField End If End If If blnFileExists = False then Set objPI = objDom.createProcessingInstruction("xml", "version='1.0'") objDom.insertBefore objPI, objDom.childNodes(0) End If objDom.save (server.mappath("./")&amp; "/eg"&amp;Day(Date)&amp;"_"&amp;Month(Date)&amp;".xml") Set objDom = Nothing Set objRoot = Nothing Set objRecord = Nothing Set objField = Nothing Set objFieldValue = Nothing Set objattID = Nothing Set objattTabOrder = Nothing Set objPI = Nothing On Error Resume Next End If %&gt; </code></pre> <p>And heres the HTML form that has the checkbox</p> <pre><code> &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;EG Editor&lt;/title&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"&gt; &lt;script type="text/javascript"&gt; var number_of_nibs = 1; function addnib(){ number_of_nibs ++; var title = document.createElement('h2'); title.innerHTML = "Story" + number_of_nibs; var nibformtitle = document.createElement('p'); nibformtitle.innerHTML = "Title:&lt;br&gt;&lt;input type=\"text\" name=\"nib"+ number_of_nibs +"_title\" style=\"width: 400px;\"&gt;"; var nibformcontent = document.createElement('p'); nibformcontent.innerHTML = "Content:&lt;br&gt;&lt;textarea cols=\"22\" rows=\"7\" name=\"nib"+ number_of_nibs + "_content\" style=\"width: 400px;\"&gt;&lt;/textarea&gt;"; var smallnewsdiv = eval("document.getElementById('smallnews')"); smallnewsdiv.appendChild(title); smallnewsdiv.appendChild(nibformtitle); smallnewsdiv.appendChild(nibformcontent); } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;h1&gt;EG Editor&lt;/h1&gt; &lt;p&gt;Welcome to the EG Editor, your one stop shop for making your EG email&lt;/p&gt; &lt;p&gt;Please Fill out the form like you would any other internet form, press save when your done&lt;/p&gt; &lt;p&gt;Once you've saved your content, you can then click on the link to the finished product, save the file as HTML (file-&gt;save as-&gt;html only option when saving), open in word and then Send to yourself (File-&gt;Send To-&gt;Mail Recipient) and biggity-bam you've got your issue of EG&lt;/p&gt; &lt;h2&gt;Main Stories&lt;/h2&gt; &lt;p&gt;Here is where you put in your stuff for your Main stories&lt;/p&gt; &lt;form name="form1" action="Egbuilder.asp" method="post"&gt; &lt;table&gt; &lt;tr&gt; &lt;td&gt;Story One:&lt;/td&gt; &lt;td&gt;Title: &lt;input type="text" name="mainstory1_title" style="width: 220px"&gt;&lt;/td&gt; &lt;td&gt;Content: &lt;textarea cols="22" rows="7" name="mainstory1" style="width: 220px;"&gt; &lt;/textarea&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Story Two:&lt;/td&gt; &lt;td&gt;Title: &lt;input type="text" name="mainstory2_title" style="width: 220px"&gt;&lt;/td&gt; &lt;td&gt;Content: &lt;textarea cols="22" rows="7" name="mainstory2" style="width: 220px;"&gt;&lt;/textarea&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Story Three:&lt;/td&gt; &lt;td&gt;Title: &lt;input type="text" name="mainstory3_title" style="width: 220px"&gt;&lt;/td&gt; &lt;td&gt;Content: &lt;textarea cols="22" rows="7" name="mainstory3" style="width: 220px;"&gt;&lt;/textarea&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Story Four:&lt;/td&gt; &lt;td&gt;Title: &lt;input type="text" name="mainstory4_title" style="width: 220px"&gt;&lt;/td&gt; &lt;td&gt;Content: &lt;textarea cols="22" rows="7" name="mainstory4" style="width: 220px;"&gt;&lt;/textarea&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;h2&gt;Promotions&lt;/h2&gt; &lt;p&gt;If there's a promotion this week then tick the 'show promotion' box, Just pop your words into the box and then copy the Intranet link into the link box.&lt;/p&gt; &lt;p&gt;Show Promotion? &lt;input type="checkbox" name="promotioncheck" &gt;&lt;/p&gt; &lt;p&gt;Banner Text:&lt;br&gt; &lt;textarea cols="22" rows="7" name="promotiontext" style="width: 400px;"&gt;&lt;/textarea&gt;&lt;/p&gt; &lt;p&gt;Intranet Link: &lt;br&gt; &lt;input type="text" name="promotionlink" style="width: 400px"&gt;&lt;/p&gt; &lt;div id="smallnews"&gt; &lt;h2&gt;News in Briefs&lt;/h2&gt; &lt;p&gt;Here is where you add your smaller stories, you can add as many as you want. Just click the green plus button to add another box&lt;/p&gt; &lt;h3&gt;Story 1&lt;/h3&gt; &lt;p&gt;Title:&lt;br&gt; &lt;input type="text" name="nib1_title" style="width: 400px"&gt;&lt;/p&gt; &lt;p&gt;Content:&lt;br&gt; &lt;textarea cols="22" rows="7" name="nib1_content" style="width: 400px;"&gt;&lt;/textarea&gt; &lt;/p&gt; &lt;/div&gt; &lt;p&gt;&lt;a href="Javascript:addnib()" title="Press this button to add another button"&gt;&lt;img src="images/add.jpg" alt="add button" style="width: 30px; height: 30px; border: 0px"&gt;Add another Story&lt;/a&gt;&lt;input type="hidden" name="hidden" value="true"&gt;&lt;input style="margin-left: 200px;" type="submit" value="Save" &gt;&lt;/p&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>I'm sure it's really simple and I've just missed something basic but any help would be appreciated. thank you</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload