0

Sorry if I'm posting this code fence wrong. I am a senior citizen (noob) writing my first html. I am writing a short script to control a ptz ip cam (192.168.1.247) for my raspberry pi.

The ptzLeftSubmit() and ptzRightSubmit() both work when I hit the buttons that call them. The ptzloc1 and ptzloc2 do not work when I hit them. The ptzloc1 and ptzloc2 html param.cgi call works in my browser window but not when I push the button.

Am I not allowed to pass the cmd parameter in a script? What am I doing wrong with ptzloc1 ptzloc2 etc?

function ptzLeftSubmit()
{
    form1.action="http://192.168.1.247/web/cgi-bin/hi3510/ytleft.cgi";
    form1.submit();
}

function ptzRightSubmit()
{
    form1.action="http://192.168.1.247/web/cgi-bin/hi3510/ytright.cgi";
    form1.submit();
}

function ptzloc1()
{
    form1.action="http://192.168.1.247/web/cgi-bin/hi3510/param.cgi?cmd=preset&-act=goto&-status=1&-number=0";
    form1.submit();
}

function ptzloc2()
{
    form1.action="http://192.168.1.247/web/cgi-bin/hi3510/param.cgi?cmd=preset&-act=goto&-status=1&-number=1";
    form1.submit();

#then later I do this

<body onLoad="load()">
<form name="form1" method="get" target="test">
</form>
<div style = "position:absolute; left:80px; top:20px;">   
<p>
<input type="button"; value="&and;" name="B3" onClick="ptzUpSubmit()"> 
<input type="button" ; value="&or;" name="B2" onClick="ptzDownSubmit()"> 
<input type="button" ; value="&lt;" name="B1" onClick="ptzLeftSubmit()"> 
<input type="button" ; value="&gt;" name="B0" onClick="ptzRightSubmit()"> 
<button type="button" ; name="B4" onClick="location.reload()"><script type="text/javascript">document.write("REFRESH");</script></button>
</p>
</div>
<div style = "position:absolute; left:400px; top:20px;">   
<p>
<input type="button"; value="&#49;" name="B4" onClick="ptzloc1()"> 
<input type="button"; value="&#50;" name="B5" onClick="ptzloc2()"> 

#etc....

Pallama
  • 1
  • 1
  • I think you might just need to escape the ampersands in the urls. replace `&` with `&` – 9bO3av5fw5 Dec 30 '20 at 20:13
  • Sorry. Not sure how to use 'code' function. Replacing all & with & has no effect. – Pallama Dec 30 '20 at 20:43
  • backticks will encode here \`&\` for example – 9bO3av5fw5 Dec 30 '20 at 20:44
  • If you paste the url `http://192.168.1.247/web/cgi-bin/hi3510/param.cgi?cmd=preset&-act=goto&-status=1&-number=0` into the browser address bar does that perform the action? – 9bO3av5fw5 Dec 30 '20 at 20:46
  • Actually I'm not sure about your url based on reading page 24 of https://www.themadhermit.net/wp-content/uploads/2013/03/FI9821W-CGI-Commands.pdf Can you try `http://192.168.1.247/web/cgi-bin/hi3510/preset.cgi?-act=goto&-status=1&-number=0` But different cameras prob have different interfaces - what exactly have you got? – 9bO3av5fw5 Dec 30 '20 at 20:49
  • Both of the above commands work in the browser address bar, but neither works in the script. – Pallama Dec 30 '20 at 21:50
  • Okay, I wasn't paying enough attention... See https://stackoverflow.com/questions/1116019/submitting-a-get-form-with-query-string-params-and-hidden-params-disappear for part of the problem. I suspect you just want to cut out the form part of this - you can either create and set some hidden inputs in the form or probably just call the url directly from the button... eg https://stackoverflow.com/questions/5882569/execute-a-cgi-each-time-a-button-was-clicked-without-changing-the-current-html-p – 9bO3av5fw5 Dec 30 '20 at 21:52
  • Calling the onClick="URL" from the button has no effect. I am not sure how to deploy the hidden input when employing buttons to call the cgi. In this case what are the "name" and value"? Are they the same as in my – Pallama Dec 30 '20 at 22:25
  • something like http://jsfiddle.net/06nwofgh/ should work... sorry, don't have time for a fuller answer (see https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest) – 9bO3av5fw5 Dec 30 '20 at 23:30

0 Answers0