Possible to modify text entered into Static page after submit?

41 views
Skip to first unread message

srowa0

unread,
Dec 2, 2022, 3:15:06 AM12/2/22
to AtoM Users
I am trying to create a static page that provides assisted searching to users, somewhere between basic and advanced searches.

My page will have two search fields, each passing a different value (sq0, sq1) to referenceCode (sf0, sf1) per guidance re: APIs (https://www.accesstomemory.org/en/docs/2.4/dev-manual/api/browse-io/#api-browse-io).  Seems to work OK. 

However what I want to do is modify the entered values on commit, by prefixing a text string ("S" for series, "cons" for consignment).  Can I do this within the HTML Content for the static page eg. by adding a <script type="text/javascript"> function ... </script> or doing something clever in the HTML ?  Or does this require access to source code to implement?

We run AtoM 2.4.x customised for the Australian Series Registration System.

Thanks for any help/hints,

Michael O'Connor
Digital Programs
State Records Office of Western Australia

José Raddaoui

unread,
Dec 2, 2022, 8:52:44 AM12/2/22
to AtoM Users
Hi Michael,

I'm not sure I understand your questions. Are you planning to create a static page including Javascript code to fetch the API or do you intend to do it on the back-end? For the later you'll need access to the source code to implement it, but if you are planning to hit the API from JS code, you should be able to prefix the user input with those values before submitting the request.

Regards,
Radda.

srowa0

unread,
Dec 6, 2022, 1:32:12 AM12/6/22
to AtoM Users
Hi Radda,

Thanks for replying ; but I can't access the back end. Hoping to do the work in the front-end using a static page but I'm not sure how to add JS so it takes the sq0 <input> and adds the prefix.  I guess I need a <script> element before or after the <form/> element? So far I have this:

<form action="/index.php/informationobject/browse&quot;" data-autocomplete="/search/autocomplete" autocomplete="off">
     <input type="hidden" name="topLod" value="0">
     <input type="hidden" name="levels" value="197">
     <input type="hidden" name="sf0" value="referenceCode">
     <input type="text" name="sq0" value="" placeholder="Series">
     <button class="btn btn-default btn-block" style="background-color:#ccc !important; border-color:#333 !important;">Search</button>
</form>

Regards,

Michael

José Raddaoui

unread,
Dec 6, 2022, 5:24:52 AM12/6/22
to AtoM Users
Hi Michael,

I see, I thought you were planning to hit the API and render the JSON response on that static page. Using a form submission to the existing browse page, the following seems to work okay (based on this SO answer):

<script>function DoSubmit(){ document.searchForm.sq0.value = "S" + document.searchForm.sq0.value; return true; }</script>

<form action="/index.php/informationobject/browse" data-autocomplete="/search/autocomplete" autocomplete="off" name="searchForm" onsubmit="DoSubmit();">
     <input type="hidden" name="topLod" value="0">
     <input type="hidden" name="levels" value="197">
     <input type="hidden" name="sf0" value="referenceCode">
     <input type="text" name="sq0" value="" placeholder="Series">
     <button class="btn btn-default btn-block" style="background-color:#ccc !important; border-color:#333 !important;">Search</button>
</form>

I only added the script (which has to be one line to avoid the inclusion of <br/> elements) and the name and onsubmit attributes to the form.

Regards,
Radda.
Reply all
Reply to author
Forward
0 new messages