Question

I'm trying to write a Roman Numeral Converter for php practice that has an input page where the user specifies whether their input is Roman or Numeric, writes the input, and hits submit. This info will then be passed via URL to an output page where the actual conversion happens. Everything for the output is done, but I can't test it because I can't figure out how to open the output php file when the user hits submit. When I change the URL to be opened to a site on the web, it works fine, but even without including the parameters to pass through the URL I just can't get it to open another php file via localhost.

The javascript to go to the output is as follows:

<script type="text/javascript">
function goToOutput(){
    var newURL = "http://localhost/Code/RomanNumeral/RNEnd.php";
    window.open(newURL);
    return false;
    }
</script>

I'll obviously have to later add the variables to the URL in order to execute the conversion, but I'm currently using RNEnd.php (which just writes "success") instead of the actual file just to test the javascript, and its not working. If I just type that newURL into my browser, it opens fine.

Any suggestions? I'd be happy to answer any clarification questions if I wasn't clear.

Thanks

whole code as requested for this specific file is here:

<html>
    <head>
        <link rel="stylesheet" href="RNStyle.css" type="text/css" media="screen"/>
        <title>ROMAN NUMERAL CONVERTER - INPUT</title>

        <script type="text/javascript">
            function goToOutput(){
                var newURL = "http://localhost/Code/RomanNumeral/RNEnd.php";
                window.open(newURL);
                return false;
                }
        </script>
    </head>

    <body background="http://upload.wikimedia.org/wikipedia/commons/5/53/Colosseum_in_Rome,_Italy_-_April_2007.jpg">
        <div id="RomanNumeralInput">
            <h1>ROMAN NUMERAL CONVERTER</h1>
            <P>Select your input type and then enter the number.</P>

            <form name="convertform" onSubmit="return goToOutput();">
                <select name="valuetypes">
                    <option value="R">ROMAN</option>
                    <option value="N">NUMERIC</option>
                </select>
                CONVERT:
                <input type="text" name="numcon">
                <input type="submit" name="convertSubmit" value="CONVERT">
            </form>
        </div>
    </body>
</html>
Was it helpful?

Solution

If you are using HTML form for SUBMIT, then you should specify the output page url in the onSubmit action.

Else if you are trying to do it through Javascript, I would suggest you use AJAX call to pass the parameters along with URL and get the output of the page and display.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top