Form of...HTML!

It would probably be easier to create a span or div that was either display: none; or display: block [or inline] depending on a hidden field, or some other form-submitted field.

Edit; actually, with htmlform.ash it'd probably be easier just to make a block of text only print when the form had been previously submitted with a certain button (whose only job was to toggle said text). Hmm...
 
Last edited:
First off, this'd have to be within some <script> tags (don't forget to specify language="JavaScript"). Preferably in your header. Also, it looks like AddTopLink() is a function that you'd also need to find.

StDoodle -- the thing about HTMLForm is that its primary purpose is to create a form in HTML using ASH. Granted, you can use a form to call a JS function, but I think what icon315 has in mind would involve pure JS.
 
StDoodle -- the thing about HTMLForm is that its primary purpose is to create a form in HTML using ASH. Granted, you can use a form to call a JS function, but I think what icon315 has in mind would involve pure JS.

Not really. Just use a special submit button, that if used, sets the text of a paragraph or something, with said text being "" otherwise.
 
You could use write_hidden() to keep track of the current contents of the topmenu, just like my earlier script fragment does.
 
Actually i don't need it for the Top Menu, but for a Charpane

PHP:
string rollover = " You will have total of <b>"+ROadvs+"</b> <img  src='http://i44.tinypic.com/imi4xe.jpg' ALIGN='TOP' /> adventures and "+PVP+" pvp fights after rollover." ;

I would like this to only show up if this
imi4xe.jpg
picture is clicked.
 
charpane.replace_string('doc("adventures")', 'alert('+rollover+')') should work, providing that charpane is the name of your buffer that stores the page's info. That is, assuming you want it to have one of those alert boxes pop up. If not, replace 'alert('+rollover+')' with some function that does all this stuff.

Edit: Of course, this overwrites KoL's documentation regarding adventures and rollover and stuff, which is the default action upon clicking on that image. But anyone who's using Mafia should be very familiar with this stuff anyways, so it's a moot point. Theoretically.
 
Ok i used this

PHP:
	buffer results;
	results.append(visit_url());
	
	string rollover = " You will have total of <b>"+ROadvs+"</b> <img  src='/images/itemimages/hourglass.gif' ALIGN='TOP' /> adventures and "+PVP+" pvp fights after rollover." ; 
	results.replace_string('doc("adventures")', 'alert( ""+ rollover +"") ');

and this is what was in the alert box:

Code:
1270870200
 
Erm, yeah. Silly me forgot to add the double-quotes to start/end the string for the alert. =P

Edit: Also, images don't appear in alert boxes (or they shouldn't), so you might get a bunch of HTML outputted as plaintext. Just a heads up.
 
hourglass.gif

adventures
and 10 pvp
fights after
rollover.") ;'>
195

EDIT:What if instead of making appear by clicking on the picture of the hourglass, we make it appear by clicking on text that says "Rollover Info", and make it appear right below that
 
Last edited:
This line would take the place of the previous one:
HTML:
results.replace_string('</span></td></tr></table>', '</span></td></tr></table><br /><span style="font-size:10" onClick=\'alert("' + rollover + '") \')>Rollover Info</span><br /><br />');

(took some liberties with styling and stuff)
 
Code:
Request from bogus referer ignored
Path: "/images/itemimages/hourglass.gif"
Referer: "http://kolmafia.us/showthread.php?3842-Form-of...HTML!&p=27512"

This appeared in my gCLI, i don't know what it is, but it's funny


EDIT: Also that gave me this:

meat.gif
hourglass.gif

225,018 195

adventures and 10 pvp fights after rollover.") ')>Rollover Info
 
Last edited:
Uhh... can't figure anything out without seeing the code.

My modified version works just fine; see below:
PHP:
void main() {
	buffer results;
	results.append(visit_url());
    int ROadvs = min(200,(my_adventures() +40 + numeric_modifier("Adventures")));
	int PVP = (numeric_modifier("Fights")+10);
    string rollover = "You will have total of "+ROadvs+" adventures and "+PVP+" pvp fights after rollover." ;
    results.replace_string('</span></td></tr></table>', '</span></td></tr></table><br /><span style="font-size:10" onClick=\'alert("' + rollover + '") \')>Rollover Info</span><br /><br />');
	results.write();
}
 
Last edited:
I had some problems with write_check() and finally figured out what was happening. I spend some time getting my head wrapped around writing a Relay ASH script, and ended up doing things this way, since my script involves updating the amount of items in inventory:
  • I build a map of certain inventory items and their quantities.
  • I write the header.
  • I test to see if certain buttons have been used, execute commands and update my item map so the rest of the script can decide what to show.
  • I write the rest of the page accordingly.

I was trying to use check fields, but after hitting a button, the page would be be refreshed with all the checkboxes checked. What was happening was that, by testing for the presence of a field in the fields map, a key for that field was added with the default string value "". I modified write_check() in htmlform.ash, changing
PHP:
if (fields contains name )
to
PHP:
if (fields contains name && fields[name] != "")
as a workaround.

I would like to point people who will use my script to this thread so everyone can download the same htmlform.ash, so I guess my second best workaround (not involving modifying htmlform.ash) would be to remove the empty fields[name] value each time I check for a name that isn't in fields, by doing:
PHP:
if (fields contains name ) {...}
else remove fields[name];

I guess my questions are:
- Should I make a feature request, asking that checking for a key in a map doesn't add the key in said map?
- Is the htmlform.ash in this thread going to be updated/maintained, à la zlib, and can we direct relay script users to download it? Or would it be better to make an accompanying library for each separate script?
 
Last edited:
Creation of keys in a map when they're read is perhaps undesirable, but not easily changed - multidimensional maps rely on that behavior, to create the intermediate levels of the map when needed.

I intended to keep htmlform.ash updated here, just have been busy with other things. Feel free to copy the needed functions directly into your script if you'd rather not rely on my update schedule.
 
I used the second workaround, removing the fields if they weren't already present.

It's nice to know htmlform.ash will be maintained, I will direct users here. Thanks!
 
Is there a way of editing a page's HTML? i tried using replace_string() but that didn't work. Any Help?

Also, sort of unrelated, my scripts info seems to disappear once i open chat, any ideas why?
 
Personally I use insert() and delete() as necessary. replace_string() is only if you want to do both at once!
 
Back
Top